/* EuroBazar — POS + admin */
:root {
  --ink: #14141c;
  --ink-soft: #5c5c6b;
  --paper: #f4f5f8;
  --surface: #ffffff;
  --line: rgba(20, 20, 28, 0.08);
  --brand: #0f6b63;
  --brand-deep: #0a4f49;
  --brand-soft: rgba(15, 107, 99, 0.12);
  --ok: #059669;
  --ok-soft: rgba(5, 150, 105, 0.12);
  --warn: #d97706;
  --warn-soft: rgba(217, 119, 6, 0.14);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Noto Sans SC", "IBM Plex Sans", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "IBM Plex Mono", "Noto Sans SC", ui-monospace, monospace;
  --shadow: 0 10px 30px rgba(20, 20, 40, 0.06);
  --topbar-h: 64px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

html:has(body.pos-body) {
  height: var(--app-h, 100%);
  overflow: hidden;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button {
  cursor: pointer;
  border: 0;
  background: none;
  -webkit-tap-highlight-color: transparent;
}
button:disabled { opacity: 0.4; cursor: not-allowed; }
img { max-width: 100%; display: block; }

/* Floating demo chip — always bottom-left (never top) */
.demo-chip {
  position: fixed;
  left: max(0.75rem, env(safe-area-inset-left));
  bottom: var(--demo-chip-bottom, max(1rem, calc(env(safe-area-inset-bottom) + 0.85rem)));
  right: auto;
  top: auto;
  z-index: 130;
  display: inline-flex;
  align-items: center;
  background: #fff;
  color: #1a1a1a;
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  padding: 0.45rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  border-radius: 4px;
  white-space: nowrap;
  text-decoration: none;
  text-transform: none;
  transition: box-shadow 180ms ease, transform 160ms ease, bottom 160ms ease, opacity 160ms ease;
}

.demo-chip:hover {
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
  transform: translateY(-1px);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: transform 0.15s ease, background 0.15s ease;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-deep); }
.btn-ghost {
  background: var(--surface);
  border: 1px solid var(--line);
}
.btn-soft { background: var(--brand-soft); color: var(--brand-deep); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-wide { width: 100%; }

.lang-switch {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(20, 20, 28, 0.06);
}
.lang-switch button {
  min-width: 40px;
  height: 32px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.lang-switch button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}


/* —— POS —— */
.pos-body {
  --app-h: 100svh;
  --demo-chip-bottom: max(1rem, calc(env(safe-area-inset-bottom) + 0.85rem));
  background: #0f1218;
  color: #eef1f7;
  height: var(--app-h);
  max-height: var(--app-h);
  overflow: hidden;
  display: block;
}
.pos-shell {
  height: 100%;
  max-height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.85fr);
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}
.pos-topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: #151a22;
  flex-shrink: 0;
}
.pos-brand { font-weight: 800; letter-spacing: -0.02em; }
.pos-brand small {
  display: block;
  font-weight: 500;
  color: rgba(238, 241, 247, 0.55);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.pos-topbar .pos-link { margin-left: auto; }
.pos-link {
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(238, 241, 247, 0.85);
}
.pos-main {
  grid-column: 1;
  grid-row: 2;
  display: grid;
  grid-template-columns: 1fr;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.pos-left {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 0.65rem;
  padding: 0.75rem;
  min-height: 0;
  overflow: hidden;
}
.scanner {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius);
  background: #1a2130;
  border: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}
.scanner.is-ok { border-color: rgba(5, 150, 105, 0.55); box-shadow: 0 0 0 3px var(--ok-soft); }
.scanner.is-err { border-color: rgba(220, 38, 38, 0.55); box-shadow: 0 0 0 3px var(--danger-soft); }

.scanner-cam {
  display: none;
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  background: #0a0e14;
  aspect-ratio: 4 / 3;
  max-height: min(42vh, 320px);
}
.scanner-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0a0e14;
}
.scanner-cam-frame {
  pointer-events: none;
  position: absolute;
  inset: 14% 16% 24% 16%;
  border: 2px solid rgba(125, 211, 252, 0.85);
  border-radius: 10px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.35);
}
.scanner-cam-idle {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  gap: 0.55rem;
  padding: 1rem;
  background: linear-gradient(160deg, #121826, #1a2130);
  text-align: center;
}
.scanner-cam.is-live .scanner-cam-idle { display: none; }
.scanner-cam-hint {
  margin: 0 auto;
  font-size: 0.78rem;
  color: rgba(238, 241, 247, 0.55);
  line-height: 1.4;
  max-width: 16rem;
}
.scanner-cam-alt {
  justify-self: center;
  min-height: 40px;
  padding: 0.45rem 0.9rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #eef1f7;
}
.scanner-cam-actions {
  position: absolute;
  left: 50%;
  bottom: 0.5rem;
  z-index: 3;
  transform: translateX(-50%);
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: 0.45rem;
  width: max-content;
  max-width: calc(100% - 0.85rem);
}
.scanner-cam-actions[hidden] {
  display: none !important;
}
.scanner-cam-fallback,
.scanner-cam-stop {
  position: static;
  flex: 0 0 auto;
  min-height: 2.1rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 650;
  white-space: nowrap;
}

.scanner-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: center;
}
.scanner-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(56, 189, 248, 0.15);
  color: #7dd3fc;
  font-size: 1.1rem;
}
.scanner-copy { min-width: 0; }
.scanner-copy strong {
  display: block;
  font-size: 0.9rem;
  line-height: 1.25;
}
.scanner-copy > span {
  display: block;
  font-size: 0.75rem;
  color: rgba(238, 241, 247, 0.55);
  margin-top: 0.12rem;
  line-height: 1.3;
}
.scanner-head .btn {
  min-height: 40px;
  padding: 0.45rem 0.85rem;
  white-space: nowrap;
}
.scanner-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.45rem;
  align-items: stretch;
}
.scanner-input {
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  border: 1px dashed rgba(125, 211, 252, 0.45);
  background: rgba(0, 0, 0, 0.28);
  color: #fff;
  font-family: var(--mono);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
}
.scanner-input:focus {
  outline: none;
  border-style: solid;
  border-color: #2dd4bf;
}
.scanner-row .btn {
  min-height: 44px;
  padding: 0.5rem 0.95rem;
  white-space: nowrap;
}

.last-scan {
  display: none;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 0.65rem 0.85rem;
  align-items: center;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius);
  background: rgba(5, 150, 105, 0.12);
  border: 1px solid rgba(5, 150, 105, 0.28);
  flex-shrink: 0;
}
.last-scan.is-on { display: grid; }
.last-scan-swatch {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: linear-gradient(145deg, hsl(var(--hue) 45% 40%), hsl(var(--hue) 55% 58%));
}
.last-scan-copy { min-width: 0; }
.last-scan .meta {
  margin: 0 0 0.25rem;
  font-size: 0.72rem;
  opacity: 0.65;
  letter-spacing: 0.04em;
}
.last-scan h3 { margin: 0; font-size: 0.92rem; }
.last-scan-copy > p:not(.meta):not(.last-scan-stock) {
  margin: 0.15rem 0 0;
  font-size: 0.72rem;
  color: rgba(238, 241, 247, 0.65);
  font-family: var(--mono);
}
.last-scan-stock {
  margin: 0.35rem 0 0;
  text-align: left;
  font-weight: 700;
  color: #34d399;
  font-size: 0.78rem;
}
.last-scan-qty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.45rem;
  width: 100%;
  min-width: 0;
}
.last-scan-stepper {
  display: grid;
  grid-template-columns: 3.25rem minmax(0, 1fr) 3.25rem;
  gap: 0.55rem;
  align-items: center;
  width: 100%;
}
.last-scan-stepper .qty-btn {
  box-sizing: border-box;
  aspect-ratio: 1 / 1;
  width: 3.25rem !important;
  height: 3.25rem !important;
  min-width: 3.25rem;
  max-width: 3.25rem;
  min-height: 3.25rem;
  max-height: 3.25rem;
  padding: 0;
  border-radius: 10px;
  font-size: 1.35rem;
  line-height: 1;
  flex: none;
}
.last-qty-input {
  box-sizing: border-box;
  width: 100%;
  height: 3.25rem;
  min-height: 3.25rem;
  max-height: 3.25rem;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 800;
  font-family: var(--mono);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #0f141e;
  color: #fff;
}

.pos-catalog {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 0.65rem;
  min-height: 0;
  overflow: hidden;
}
.pos-cats {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  overflow: auto;
}
.pos-cat {
  text-align: left;
  padding: 0.7rem 0.65rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(238, 241, 247, 0.7);
  font-size: 0.8rem;
  font-weight: 600;
}
.pos-cat.is-active {
  background: var(--brand);
  color: #fff;
}
.pos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 0.55rem;
  overflow: auto;
  align-content: start;
  padding-right: 0.15rem;
}
.pos-tile {
  position: relative;
  text-align: left;
  padding: 0.7rem;
  border-radius: 12px;
  background: #1a2130;
  border: 1px solid rgba(255, 255, 255, 0.06);
  min-height: 118px;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.pos-tile:hover:not(:disabled) { border-color: rgba(56, 189, 248, 0.4); }
.pos-tile:disabled { opacity: 0.35; }
.pos-tile-stock {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.1);
}
.pos-tile-stock.is-low { background: var(--warn-soft); color: #fbbf24; }
.pos-tile strong { font-size: 0.82rem; line-height: 1.25; padding-right: 2.2rem; }
.pos-tile-brand {
  display: block;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  color: rgba(147, 197, 253, 0.85);
  padding-right: 2.2rem;
}
.pos-tile-es {
  display: block;
  font-size: 0.68rem;
  line-height: 1.25;
  color: rgba(238, 241, 247, 0.5);
  padding-right: 2.2rem;
}
.pos-tile em {
  margin-top: auto;
  font-style: normal;
  font-weight: 800;
  color: #93c5fd;
}

.pos-cart {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  background: #121722;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.pos-cart-toggle {
  display: none;
}
.pos-cart-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.pos-cart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  background: transparent !important;
}
.pos-cart-head h2 { margin: 0; font-size: 1rem; }
.pos-cart-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0.65rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.pos-empty {
  margin: 2rem 0.5rem;
  text-align: center;
  color: rgba(238, 241, 247, 0.45);
  font-size: 0.9rem;
}
.cart-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 0.75rem;
  padding: 0.7rem 0.75rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
}
.cart-line strong { font-size: 0.88rem; }
.cart-line .meta {
  font-size: 0.72rem;
  color: rgba(238, 241, 247, 0.5);
  font-family: var(--mono);
}
.cart-line-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  grid-column: 1 / -1;
}
.qty-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  font-weight: 700;
}
.cart-line-total { font-weight: 800; color: #93c5fd; }
.pos-cart-foot {
  padding: 0.75rem 1rem 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  flex-shrink: 0;
}
.totals { display: grid; gap: 0.25rem; font-size: 0.88rem; }
.totals div { display: flex; justify-content: space-between; color: rgba(238, 241, 247, 0.65); }
.totals .grand { color: #fff; font-size: 1.15rem; font-weight: 800; margin-top: 0.2rem; }
.pay-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.45rem; }

.ticket-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 1rem;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  align-items: safe center;
}

.ticket-backdrop[hidden] {
  display: none !important;
}

.ticket {
  width: min(380px, 100%);
  max-height: min(92dvh, 920px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  color: #111;
  border-radius: 12px;
  padding: 1.25rem 1.1rem 0;
  font-family: var(--mono);
  font-size: 0.82rem;
}
.ticket-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.35rem;
}
.ticket h3 { margin: 0 0 0.35rem; font-family: var(--font); }
.demo-end-kicker {
  margin: 0 0 0.25rem;
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #3d6b55;
}
.ticket .muted { color: #666; margin: 0 0 0.85rem; }
.ticket-lines { border-top: 1px dashed #ccc; border-bottom: 1px dashed #ccc; padding: 0.65rem 0; margin-bottom: 0.65rem; }
.ticket-line { display: flex; justify-content: space-between; gap: 0.5rem; margin: 0.2rem 0; }
.ticket-verifactu {
  margin-top: 0.95rem;
  padding-top: 0.85rem;
  border-top: 1px dashed #ccc;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  text-align: center;
}
.ticket-verifactu-mark {
  margin: 0;
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #111;
}
.ticket-verifactu-qr {
  width: 140px;
  height: 140px;
  display: block;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  image-rendering: pixelated;
}
.ticket-verifactu-note {
  margin: 0;
  font-family: var(--font);
  font-size: 0.68rem;
  color: #888;
  line-height: 1.35;
  max-width: 16rem;
}
.ticket-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 0.45rem;
  margin-top: 0;
  padding: 0.85rem 0 calc(0.85rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #eee;
  background: #fff;
  z-index: 2;
}
.ticket-actions .btn { flex: 1; min-height: 48px; }

@media (min-width: 721px) {
  .scanner-cam {
    display: none !important;
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  z-index: 70;
  padding: 0.65rem 1rem;
  border-radius: 999px;
  background: rgba(20, 20, 28, 0.92);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
}

.toast[hidden] {
  display: none !important;
}

/* —— Admin —— */
.admin-shell { min-height: 100dvh; }
.admin-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}
.admin-bar h1 { margin: 0; font-size: 1.05rem; }
.admin-bar .spacer { flex: 1; }
.admin-body { max-width: 1100px; margin: 0 auto; padding: 1rem 1rem 2.5rem; }
.admin-cam {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  background: #0a0e14;
  aspect-ratio: 16 / 9;
  max-height: min(36vh, 280px);
  margin-bottom: 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.admin-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0a0e14;
}
.admin-cam-frame {
  pointer-events: none;
  position: absolute;
  inset: 18% 22%;
  border: 2px solid rgba(125, 211, 252, 0.85);
  border-radius: 10px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.35);
}
.admin-cam-idle {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  gap: 0.55rem;
  padding: 1rem;
  background: linear-gradient(160deg, #121826, #1a2130);
  text-align: center;
}
.admin-cam.is-live .admin-cam-idle { display: none; }
.admin-cam-hint {
  margin: 0 auto;
  font-size: 0.78rem;
  color: rgba(238, 241, 247, 0.55);
  line-height: 1.4;
  max-width: 18rem;
}
.admin-scan {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 0.55rem;
  align-items: end;
  margin-bottom: 0.85rem;
  padding: 0.85rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}
.admin-qty-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--ink-soft);
  min-width: 4.5rem;
}
.admin-qty {
  width: 4.5rem;
  min-height: 44px;
  padding: 0.45rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--paper);
  font: inherit;
  font-family: var(--mono);
  font-weight: 650;
}
.low-banner {
  display: none;
  margin-bottom: 0.85rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  color: #92400e;
  font-weight: 600;
  font-size: 0.9rem;
}
.low-banner.is-on { display: block; }

.search {
  width: 100%;
  min-height: 44px;
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--paper);
}

.toolbar {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  padding: 0.85rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  background: var(--paper);
  border: 1px solid var(--line);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.chip.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.admin-brand strong { display: block; font-weight: 650; }
.admin-brand span {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.admin-table-wrap {
  overflow: auto;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
}
table.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.admin-table th,
.admin-table td {
  padding: 0.7rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.admin-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  background: #fafafa;
}
.admin-table tr.is-low td { background: rgba(217, 119, 6, 0.06); }
.admin-table tr.is-out td { background: rgba(220, 38, 38, 0.05); }
.stock-pill {
  display: inline-flex;
  min-width: 2.2rem;
  justify-content: center;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-weight: 800;
  font-family: var(--mono);
  background: var(--brand-soft);
  color: var(--brand-deep);
}
.stock-pill.is-low { background: var(--warn-soft); color: #92400e; }
.stock-pill.is-out { background: var(--danger-soft); color: var(--danger); }
.row-actions { display: flex; gap: 0.3rem; }
.admin-name-zh { display: block; font-weight: 650; }
.admin-name-es {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

@media (max-width: 960px) {
  .admin-scan { grid-template-columns: 1fr 1fr; }
  .admin-scan .search { grid-column: 1 / -1; }
  .admin-qty-label { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; }
}

@media (max-width: 720px) {
  /*
   * Mobile cart: fixed bottom sheet (peek bar + drag via --cart-ty).
   * --app-h is set from window.innerHeight so DevTools / iOS chrome cannot
   * push the bar below the visible frame.
   */
  .pos-body {
    --demo-chip-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
    /* Must be ≥ real cart toggle height + small gap, or last-scan sits under the sheet. */
    --cart-peek: calc(5.75rem + env(safe-area-inset-bottom, 0px));
  }
  .pos-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    padding-bottom: var(--cart-peek);
  }
  .pos-topbar {
    grid-column: 1;
    grid-row: 1;
  }
  .pos-main {
    grid-column: 1;
    grid-row: 2;
    min-height: 0;
  }
  .pos-left {
    height: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.55rem 0.65rem 0.75rem;
    overflow: hidden;
    min-height: 0;
  }
  .pos-catalog {
    display: none !important;
  }
  .scanner {
    padding: 0.7rem 0.75rem;
    gap: 0.55rem;
    flex: 1 1 50%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .scanner-cam {
    display: block;
    flex: 1 1 auto;
    width: 100%;
    min-height: 7.5rem;
    max-height: none;
    aspect-ratio: auto;
    height: auto;
  }
  .scanner-cam-idle {
    gap: 0.65rem;
  }
  .scanner-cam-alt {
    display: inline-flex;
  }
  .scanner-cam-frame {
    inset: 12% 14% 26% 14%;
  }
  .scanner-row--desktop {
    display: none;
  }
  .scanner-head {
    display: none;
  }
  .last-scan,
  .last-scan.is-on {
    display: flex !important;
    flex-direction: column;
    flex: 0 0 50%;
    height: 50%;
    max-height: 50%;
    min-height: 0;
    gap: 0.65rem;
    align-items: stretch;
    padding: 0.85rem 0.85rem 0.95rem;
    overflow: hidden;
    /* Kill desktop grid tracks that squeezed copy into 48px. */
    grid-template-columns: none;
  }
  .last-scan:not(.is-on) {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
  }
  .last-scan:not(.is-on) .last-scan-swatch {
    background: rgba(255, 255, 255, 0.08);
  }
  .last-scan:not(.is-on) .last-scan-stock {
    color: rgba(238, 241, 247, 0.35);
  }
  .last-scan-swatch {
    display: none;
  }
  .last-scan-copy {
    min-width: 0;
    width: 100%;
    flex: 1 1 auto;
    overflow: auto;
  }
  .last-scan-copy h3 {
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .last-scan-qty {
    margin-top: auto;
    width: 100%;
    min-width: 0;
    padding-top: 0.15rem;
    flex: 0 0 auto;
    grid-column: auto;
  }
  .last-scan-stepper {
    width: 100%;
    grid-template-columns: 3.25rem minmax(0, 1fr) 3.25rem;
    align-items: center;
  }
  .last-scan-stepper .qty-btn {
    width: 3.25rem !important;
    height: 3.25rem !important;
    min-width: 3.25rem;
    max-width: 3.25rem;
    min-height: 3.25rem;
    max-height: 3.25rem;
    font-size: 1.35rem;
  }
  .last-qty-input {
    height: 3.25rem;
    min-height: 3.25rem;
    max-height: 3.25rem;
    font-size: 1.25rem;
  }
  .last-scan .meta {
    font-size: 0.72rem !important;
    margin-bottom: 0.4rem;
  }
  .last-scan h3 {
    font-size: 1.05rem;
    line-height: 1.3;
  }
  .last-scan-copy > p:not(.meta):not(.last-scan-stock) {
    font-size: 0.72rem;
    line-height: 1.4;
    word-break: break-word;
  }
  .last-scan-stock {
    margin-top: 0.4rem;
    font-size: 0.8rem;
  }

  /*
   * Fixed bottom sheet. Closed = peek bar only (translateY).
   * Drag sets --cart-ty in px so the sheet follows the finger.
   */
  .pos-cart {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    width: 100%;
    /* Fill almost the whole app height (leave a thin top gap). */
    height: calc(var(--app-h, 100svh) - 0.35rem);
    max-height: calc(var(--app-h, 100svh) - 0.35rem);
    display: flex;
    flex-direction: column;
    border-left: 0;
    border-top: 0;
    border-radius: 14px 14px 0 0;
    background: #1c2534;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.35);
    overflow: hidden;
    transform: translate3d(0, var(--cart-ty, calc(100% - var(--cart-peek))), 0);
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
    will-change: transform;
    touch-action: none;
  }
  .pos-cart.is-dragging {
    transition: none !important;
  }

  /* Cart open / dragging: collapse camera so the sheet is usable. */
  .pos-shell:has(.pos-cart.is-open) .pos-main,
  .pos-body.cart-sheet-open .pos-main {
    min-height: 0;
  }
  .pos-shell:has(.pos-cart.is-open) .pos-left,
  .pos-body.cart-sheet-open .pos-left {
    overflow: hidden;
  }
  .pos-shell:has(.pos-cart.is-open) .scanner,
  .pos-body.cart-sheet-open .scanner {
    flex: 0 0 auto;
    padding: 0.45rem 0.65rem;
    gap: 0;
  }
  .pos-shell:has(.pos-cart.is-open) .scanner-cam,
  .pos-body.cart-sheet-open .scanner-cam,
  .pos-shell:has(.pos-cart.is-open) .scanner-video,
  .pos-body.cart-sheet-open .scanner-video,
  .pos-shell:has(.pos-cart.is-open) .last-scan,
  .pos-body.cart-sheet-open .last-scan {
    display: none !important;
  }
  .pos-cart-toggle {
    position: relative;
    display: flex !important;
    align-items: center;
    gap: 0.75rem;
    flex: 0 0 auto;
    width: 100%;
    min-height: 3.75rem;
    margin: 0;
    padding: 1.15rem 1rem calc(0.85rem + env(safe-area-inset-bottom, 0px));
    border: 0;
    background: #243044;
    color: #eef1f7;
    text-align: left;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
  }
  .pos-cart-toggle:active { cursor: grabbing; }
  .pos-cart.is-open .pos-cart-toggle {
    min-height: 0;
    padding: 1.15rem 1rem 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: #1c2534;
  }
  .pos-cart-toggle-handle {
    position: absolute;
    top: 0.45rem;
    left: 50%;
    z-index: 2;
    width: 2.75rem;
    height: 5px;
    margin-left: -1.375rem;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.4);
    pointer-events: auto;
  }
  /* Large hit target for the grab bar */
  .pos-cart-toggle-handle::before {
    content: '';
    position: absolute;
    left: -56px;
    right: -56px;
    top: -16px;
    bottom: -22px;
  }
  .pos-cart-toggle-copy {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
    flex: 1;
    padding-top: 0.45rem;
  }
  .pos-cart-toggle-copy strong { font-size: 0.95rem; }
  .pos-cart-toggle-copy span {
    font-size: 0.8rem;
    color: rgba(238, 241, 247, 0.55);
    font-family: var(--mono);
  }
  .pos-cart-toggle-action {
    flex-shrink: 0;
    margin-top: 0.45rem;
    width: 2.35rem;
    height: 2.35rem;
    display: grid;
    place-items: center;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: rgba(238, 241, 247, 0.85);
    background: rgba(255, 255, 255, 0.06);
  }
  .pos-cart-chevron {
    display: block;
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  }
  .pos-cart.is-open .pos-cart-chevron {
    transform: rotate(180deg);
  }
  .pos-cart-panel {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    opacity: 1;
    overflow: hidden;
    pointer-events: none;
  }
  .pos-cart.is-open .pos-cart-panel {
    pointer-events: auto;
  }
  .pos-cart-panel {
    position: relative;
  }
  .pos-cart-head { display: none; }
  .pos-cart.is-open .pos-cart-head,
  .pos-cart.is-dragging .pos-cart-head {
    display: block;
    position: absolute;
    top: 0.45rem;
    right: 0.75rem;
    z-index: 5;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    pointer-events: none;
  }
  .pos-cart.is-open .pos-cart-head h2,
  .pos-cart.is-dragging .pos-cart-head h2 { display: none; }
  .pos-cart.is-open .pos-cart-head .pos-link,
  .pos-cart.is-dragging .pos-cart-head .pos-link,
  .pos-cart.is-open #cart-clear {
    pointer-events: auto;
    margin: 0;
    min-height: 2rem;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(28, 37, 52, 0.88);
    color: #eef1f7;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    font-size: 0.78rem;
    font-weight: 650;
  }
  .pos-cart-list {
    flex: 1 1 auto;
    min-height: 7rem;
    max-height: none;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    padding: 3rem 1rem 0.85rem;
    gap: 0.65rem;
  }
  .pos-cart-foot {
    flex-shrink: 0;
    padding: 0.85rem 1rem calc(1.15rem + env(safe-area-inset-bottom, 0px));
    background: #121722;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }
  .cart-line {
    gap: 0.45rem 0.85rem;
    padding: 0.95rem 0.9rem;
  }
  .cart-line strong { font-size: 0.92rem; }
  .cart-line .meta { margin-top: 0.2rem; line-height: 1.35; }
  .cart-line-controls { margin-top: 0.35rem; gap: 0.5rem; }
  .qty-btn { width: 36px; height: 36px; }
  .pos-empty {
    margin: 1.25rem 0.75rem;
    font-size: 0.88rem;
    line-height: 1.5;
  }
  .totals { gap: 0.35rem; font-size: 0.9rem; }
  .pay-row { gap: 0.55rem; margin-top: 0.15rem; }
  .pay-row .btn { min-height: 44px; }

  .demo-chip {
    top: max(0.55rem, env(safe-area-inset-top, 0px)) !important;
    right: max(0.55rem, env(safe-area-inset-right, 0px)) !important;
    bottom: auto !important;
    left: auto !important;
    z-index: 80;
    opacity: 1;
    pointer-events: auto;
  }
  .pos-body:has(.pos-cart.is-open) .demo-chip,
  .pos-body.cart-sheet-open .demo-chip {
    opacity: 0;
    pointer-events: none;
  }
}
