:root {
  --bg: #0f1220;
  --surface: #1a1f36;
  --surface-2: #232946;
  --border: #2e3557;
  --text: #eef1ff;
  --muted: #9aa3c7;
  --accent: #6c8cff;
  --accent-ink: #0b0e1a;
  --price: #7ee0a8;
  --radius: 14px;
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.case-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.case-header__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 16px 14px;
}

.case-header__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.btn-staff {
  flex: none;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}
.btn-staff:active { transform: translateY(1px); }
.btn-staff.is-active {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

/* A class selector's display would otherwise beat the default [hidden] rule,
   so keep hidden elements hidden regardless of later display declarations. */
[hidden] { display: none !important; }

.staff-banner {
  position: sticky;
  top: 74px;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 16px;
  font-size: 0.85rem;
  color: var(--accent-ink);
  background: var(--accent);
}
.staff-banner strong { font-weight: 800; }

.btn-staff-exit {
  flex: none;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-ink);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

/* When staff mode is active, drop the sticky controls below the banner. */
body.staff-mode .case-controls { top: 116px; }

.btn-sold {
  margin-top: 8px;
  width: 100%;
  padding: 10px;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  color: #fff;
  background: #d9455f;
  border: none;
  border-radius: 10px;
  cursor: pointer;
}
.btn-sold:active { transform: translateY(1px); }
.btn-sold:disabled { opacity: 0.6; cursor: default; }

.case-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.case-subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Location switcher. Deliberately not sticky: the header height is what the
   sticky offsets below are measured against, so this scrolls away instead. */
.case-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 16px 0;
}

.case-nav__link {
  padding: 7px 13px;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.case-nav__link:active { transform: translateY(1px); }
.case-nav__link--show { color: #ffd479; border-color: rgba(255, 176, 32, 0.4); }
.case-nav__link.is-current {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

/* Landing page listing every case (the generic "all cases" QR target). */
.case-index {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}
.case-index__lead { margin: 0 0 16px; color: var(--muted); font-size: 0.95rem; }
.case-index__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.case-index__item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 16px;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.case-index__item:active { transform: translateY(1px); }
.case-index__name { font-weight: 800; font-size: 1.05rem; }
.case-index__hint { color: var(--muted); font-size: 0.8rem; }

.case-footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px 32px;
  color: var(--muted);
  font-size: 0.8rem;
}

.case-controls {
  position: sticky;
  top: 74px;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 16px;
  background: var(--bg);
}

.control { display: flex; align-items: center; }
.control--search { flex: 1 1 100%; }
.control--price { gap: 6px; }
.control--price .dash { color: var(--muted); }

.case-controls input,
.case-controls select {
  width: 100%;
  padding: 11px 12px;
  font-size: 16px; /* 16px avoids iOS zoom-on-focus */
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
}
.case-controls input::placeholder { color: var(--muted); }
.case-controls input:focus,
.case-controls select:focus { border-color: var(--accent); }

.control--price input { width: 96px; }

.btn-clear {
  padding: 11px 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}
.btn-clear:active { transform: translateY(1px); }

.case-count,
.case-status {
  max-width: 1100px;
  margin: 4px auto 0;
  padding: 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.case-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  max-width: 1100px;
  margin: 12px auto 0;
  padding: 0 16px 40px;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.card__imgwrap {
  aspect-ratio: 63 / 88; /* standard trading-card ratio */
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card__body {
  padding: 10px 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.card__name {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.2;
}

.card__meta {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.25;
}

.card__row {
  margin-top: auto;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding-top: 6px;
}

.card__price {
  color: var(--price);
  font-weight: 800;
  font-size: 1.05rem;
}
.card__price--ask {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
}

.card__qty {
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}

.badge-condition {
  align-self: flex-start;
  font-size: 0.68rem;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(108, 140, 255, 0.12);
  border: 1px solid rgba(108, 140, 255, 0.3);
  border-radius: 6px;
  padding: 1px 6px;
}

/* Which store a pooled show-case card belongs to. Staff mode only. */
.card__origin {
  align-self: flex-start;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
}

/* Staff "Add to sale" button (replaces the old one-tap Sold). */
.btn-add {
  margin-top: 8px;
  width: 100%;
  padding: 10px;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  color: var(--accent-ink);
  background: var(--accent);
  border: none;
  border-radius: 10px;
  cursor: pointer;
}
.btn-add:active { transform: translateY(1px); }
.btn-add:disabled { opacity: 0.5; cursor: default; }
.btn-add.in-cart { background: var(--price); }

/* Staff "do not pull for PSA" toggle. Off = quiet outline, on = warning fill. */
.btn-nopsa {
  margin-top: 6px;
  width: 100%;
  padding: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}
.btn-nopsa:active { transform: translateY(1px); }
.btn-nopsa:disabled { opacity: 0.5; cursor: default; }
.btn-nopsa.is-on {
  color: #ffd479;
  background: rgba(255, 176, 32, 0.14);
  border-color: rgba(255, 176, 32, 0.5);
}

/* ---- Cart / sale tracker (staff only) ---- */
.cart {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.45);
}

.cart__handle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 16px;
  font-size: 0.95rem;
  color: var(--text);
  background: transparent;
  border: none;
  cursor: pointer;
}
.cart__handle-label { font-weight: 800; }
.cart__handle-count { color: var(--muted); font-size: 0.85rem; }
.cart__handle-total {
  margin-left: auto;
  color: var(--price);
  font-weight: 800;
  font-size: 1.15rem;
}
.cart__handle-caret { color: var(--muted); transition: transform 0.15s ease; }
.cart__handle[aria-expanded="true"] .cart__handle-caret { transform: rotate(180deg); }

.cart__panel {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px 16px;
  max-height: 55vh;
  overflow-y: auto;
}

.cart__lines { list-style: none; margin: 0; padding: 0; }

.cart__line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.cart__line-main { flex: 1; min-width: 0; }
.cart__line-name {
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cart__line-meta { color: var(--muted); font-size: 0.76rem; }

.cart__stepper { display: flex; align-items: center; gap: 6px; flex: none; }
.cart__step-btn {
  width: 30px;
  height: 30px;
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.cart__step-btn:disabled { opacity: 0.4; cursor: default; }
.cart__qty { min-width: 22px; text-align: center; font-weight: 700; }

.cart__price-input {
  width: 74px;
  padding: 7px 8px;
  font-size: 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 8px;
  outline: none;
}
.cart__line-total {
  flex: none;
  min-width: 66px;
  text-align: right;
  color: var(--price);
  font-weight: 800;
}
.cart__remove {
  flex: none;
  width: 28px;
  height: 28px;
  font-size: 1rem;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.cart__summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 0 10px;
  font-size: 1rem;
  font-weight: 700;
}
.cart__summary-total { color: var(--price); font-size: 1.4rem; font-weight: 800; }

.cart__actions { display: flex; gap: 10px; }
.btn-cart-clear {
  flex: none;
  padding: 12px 16px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}
.btn-cart-complete {
  flex: 1;
  padding: 12px;
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
  background: #1f9d57;
  border: none;
  border-radius: 10px;
  cursor: pointer;
}
.btn-cart-complete:active { transform: translateY(1px); }
.btn-cart-complete:disabled { opacity: 0.6; cursor: default; }

.cart__msg { margin: 10px 0 0; font-size: 0.85rem; color: var(--muted); }
.cart__msg.is-error { color: #ff9aa8; }

/* Keep the grid clear of the fixed cart bar when it's open. */
body.cart-open .case-grid { padding-bottom: 120px; }

@media (min-width: 640px) {
  .control--search { flex: 1 1 auto; }
  .case-title { font-size: 1.8rem; }
}
