@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  --bg: #ffffff;
  --surface: #f2f6f2;
  --surface-raised: #e7efe7;
  --ink: #16241b;
  --muted: #66766c;
  --accent: #2fae4e;
  --accent-ink: #ffffff;
  --good: #1f9d52;
  --bad: #d1372a;
  --border: #d9e3d9;
  --radius: 10px;
  --tap: 56px;
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: 'IBM Plex Sans', -apple-system, sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

input, textarea { user-select: text; -webkit-user-select: text; }

.mono { font-family: 'IBM Plex Mono', monospace; }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Top status bar ---- */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 10px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
}
.topbar .brand .brand-mark {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 8px;
  flex-shrink: 0;
}
.topbar .brand .brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.topbar .brand .brand-text .name {
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.1px;
}
.topbar .brand .brand-text .by {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.2px;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  padding: 4px 9px;
  border-radius: 20px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.status-pill.wh-pill { cursor: pointer; font-weight: 600; color: var(--ink); }
.status-pill.wh-pill:active { background: var(--surface-raised); }
.status-pill.online .status-dot { background: var(--good); }
.status-pill.demo .status-dot { background: var(--accent); }
.status-pill.offline .status-dot { background: var(--bad); }

/* ---- Topbar icon button (Sign Out, next to the mode pill) ---- */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn:active { background: var(--surface-raised); }
.icon-btn img { width: 15px; height: 15px; object-fit: contain; }

/* ---- Screen header (back + title) ---- */
.screen-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 4px;
}
.screen-header h1 {
  font-size: 20px;
  margin: 0;
  font-weight: 600;
}
.back-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 18px;
  cursor: pointer;
}

main.screen {
  flex: 1;
  padding: 12px 16px 100px;
  overflow-y: auto;
}

/* ---- Home grid: big thumb-reachable tiles ---- */
.home-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 6px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 12px 10px;
  min-height: 84px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.tile:active { background: var(--surface-raised); }
.tile .glyph { font-size: 22px; }
.tile .glyph-img { width: 32px; height: 32px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.tile.wide .glyph-img { width: 28px; height: 28px; }
.tile .label { font-size: 13.5px; font-weight: 600; }
.tile .sub { font-size: 11px; color: var(--muted); }
.tile.wide { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: flex-start; gap: 12px; min-height: 60px; padding: 10px 12px; }

/* ---- Cards / lists ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
  min-height: var(--tap);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.list-row:last-child { border-bottom: none; }
.list-row .title { font-weight: 600; font-size: 15px; }
.list-row .meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.list-row .chev { color: var(--muted); font-size: 18px; }

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
  font-size: 14px;
}
.empty-state .glyph { font-size: 34px; display: block; margin-bottom: 10px; }

/* ---- Scan input: the primary interaction ---- */
.scan-field {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 14px;
}
.scan-field.active { border-color: var(--accent); }
.scan-field .glyph { font-size: 20px; color: var(--accent); }
.scan-field input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ink);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 16px;
  letter-spacing: 0.3px;
}
.scan-field input::placeholder { color: var(--muted); font-family: 'IBM Plex Sans', sans-serif; }
.scan-hint { font-size: 11.5px; color: var(--muted); margin: -8px 0 14px 4px; }

/* ---- Quantity stepper ---- */
.qty-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.qty-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.qty-stepper button {
  width: 42px; height: 42px;
  background: var(--surface-raised);
  border: none;
  color: var(--ink);
  font-size: 20px;
  cursor: pointer;
}
.qty-stepper input {
  width: 60px;
  text-align: center;
  border: none;
  background: var(--bg);
  color: var(--ink);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 16px;
  height: 42px;
}

/* ---- Unit-of-measure select (next to a qty-stepper) ---- */
.uom-select {
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-raised);
  color: var(--ink);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13.5px;
  font-weight: 600;
  padding: 0 8px;
  flex-shrink: 0;
}
.uom-equiv { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: var(--radius);
  border: none;
  font-size: 15.5px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  position: relative;
  overflow: hidden;
}

/* ---- Tap ripple ----
   Applied by app.js's global click-feedback listener to any element
   matching a "rippleable" selector (.tile, .list-row, .btn, .menu-tile,
   [data-go], [data-id], [data-select], etc.) — a small circle that expands
   and fades from wherever the person actually tapped, so every click
   anywhere in the menu/app visibly shows where it landed. */
.tap-ripple {
  position: absolute;
  border-radius: 50%;
  transform: scale(0);
  background: currentColor;
  opacity: 0.35;
  pointer-events: none;
  animation: tap-ripple-anim 500ms ease-out;
}
@keyframes tap-ripple-anim {
  to { transform: scale(2.6); opacity: 0; }
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-secondary { background: var(--surface-raised); color: var(--ink); border: 1px solid var(--border); }
.btn-danger { background: transparent; color: var(--bad); border: 1px solid var(--bad); }
.btn-good { background: var(--good); color: #ffffff; }
.btn:disabled { opacity: 0.4; }
.btn-sm { min-height: 40px; font-size: 13.5px; padding: 0 12px; width: auto; }

.action-bar {
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  padding: 16px 0 6px;
  display: flex;
  gap: 10px;
}

/* ---- Badges ---- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge-good { background: rgba(31,157,82,0.12); color: var(--good); }
.badge-warn { background: rgba(47,174,78,0.12); color: var(--accent); }
.badge-bad { background: rgba(209,55,42,0.12); color: var(--bad); }
.badge-muted { background: rgba(102,118,108,0.12); color: var(--muted); }

/* ---- Form fields (Settings) ---- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select {
  width: 100%;
  min-height: 48px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14.5px;
  padding: 0 12px;
}

/* ---- Toast ---- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  max-width: 90%;
  text-align: center;
  z-index: 50;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.good { border-color: var(--good); }
#toast.bad { border-color: var(--bad); }

.section-label {
  font-size: 12px;
  text-transform: none;
  color: var(--muted);
  margin: 18px 4px 8px;
}

.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ---- Directed putaway bin (the system-suggested destination) ---- */
.directed-bin {
  text-align: center;
  padding: 20px 16px;
  background: var(--surface-raised);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  margin-bottom: 14px;
}
.directed-bin .label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.directed-bin .bin-code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 32px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 1px;
}
.directed-bin .zone { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

/* ---- Receiving-into banner: informational, not actionable (that's why it's
   muted, not accent-colored like .directed-bin) — just shows where a receipt
   physically lands before putaway even starts. ---- */
.receiving-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
}
.receiving-banner .label { font-size: 11.5px; color: var(--muted); }
.receiving-banner .bin-code { font-family: 'IBM Plex Mono', monospace; font-size: 15px; font-weight: 700; }

.bin-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 14px;
}
.bin-check.match { background: rgba(31,157,82,0.12); color: var(--good); }
.bin-check.mismatch { background: rgba(209,55,42,0.12); color: var(--bad); }

/* ---- Occupancy bar (Locations screen: current qty vs. stocking limit) ---- */
.occupancy-bar {
  height: 6px;
  border-radius: 4px;
  background: var(--border);
  overflow: hidden;
  margin-top: 7px;
}
.occupancy-bar-fill { height: 100%; background: var(--accent); border-radius: 4px; }
.occupancy-bar-fill.full { background: var(--bad); }

.location-group-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  margin: 18px 4px 8px;
}
.location-group-label:first-child { margin-top: 0; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
