:root {
  --bg: #07040f;
  --bg-elev: #100a1c;
  --bg-soft: #161026;
  --bg-card: rgba(22, 16, 38, 0.88);
  --line: rgba(184, 122, 255, 0.22);
  --line-strong: rgba(232, 204, 122, 0.35);
  --text: #f3eefc;
  --muted: #b4b2c8;
  --purple: #b87aff;
  --purple-deep: #7a3fd4;
  --gold: #e8cc7a;
  --gold-deep: #c9a04a;
  --danger: #ff7a9a;
  --ok: #8dffc1;
  --ink: #0a0612;
  --radius: 20px;
  --font-display: "Cinzel", Georgia, serif;
  --font-script: "Great Vibes", cursive;
  --font-body: "Outfit", system-ui, sans-serif;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  --glow-purple: 0 0 40px rgba(184, 122, 255, 0.28);
  --glow-gold: 0 0 28px rgba(232, 204, 122, 0.22);
}

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

html, body {
  margin: 0;
  min-height: 100%;
  width: 100%;
  overflow-x: hidden;
  color: var(--text);
  font-family: var(--font-body);
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(184, 122, 255, 0.22), transparent 55%),
    radial-gradient(700px 420px at 100% 20%, rgba(201, 160, 74, 0.1), transparent 50%),
    radial-gradient(600px 400px at 0% 80%, rgba(122, 63, 212, 0.16), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.35;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, rgba(232, 204, 122, 0.7), transparent),
    radial-gradient(1px 1px at 28% 62%, rgba(243, 238, 252, 0.45), transparent),
    radial-gradient(1.5px 1.5px at 72% 24%, rgba(184, 122, 255, 0.65), transparent),
    radial-gradient(1px 1px at 86% 78%, rgba(232, 204, 122, 0.55), transparent),
    radial-gradient(1px 1px at 48% 40%, rgba(255, 255, 255, 0.35), transparent),
    radial-gradient(1.5px 1.5px at 64% 88%, rgba(184, 122, 255, 0.4), transparent);
}

body > *:not(.noise) {
  position: relative;
  z-index: 1;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 8px;
  width: min(1100px, 100%);
  margin: 0 auto;
  box-sizing: border-box;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.odoo-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(16, 10, 28, 0.9);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  white-space: nowrap;
}

.odoo-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.odoo-status.checking .dot {
  background: var(--gold);
  box-shadow: 0 0 10px rgba(232, 204, 122, 0.55);
  animation: blink 1s ease-in-out infinite;
}

.odoo-status.online {
  border-color: rgba(141, 255, 193, 0.35);
  color: var(--ok);
}

.odoo-status.online .dot {
  background: var(--ok);
  box-shadow: 0 0 10px rgba(141, 255, 193, 0.65);
}

.odoo-status.offline {
  border-color: rgba(255, 122, 154, 0.4);
  color: var(--danger);
}

.odoo-status.offline .dot {
  background: var(--danger);
  box-shadow: 0 0 10px rgba(255, 122, 154, 0.55);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.mobile-only {
  display: block;
}

@media (min-width: 900px) {
  .mobile-only {
    display: none !important;
  }
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background:
    linear-gradient(145deg, rgba(184, 122, 255, 0.35), rgba(232, 204, 122, 0.18)),
    var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  box-shadow: var(--glow-purple);
}

.brand h1 {
  margin: 0;
  font-family: var(--font-script);
  font-size: clamp(1.55rem, 7vw, 2.6rem);
  font-weight: 400;
  line-height: 0.9;
  letter-spacing: 0.01em;
  color: var(--text);
  text-shadow:
    0 0 18px rgba(184, 122, 255, 0.55),
    0 0 40px rgba(184, 122, 255, 0.25);
}

.brand p {
  margin: 4px 0 0;
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

@media (max-width: 699px) {
  .odoo-status {
    padding: 7px 9px;
  }

  .odoo-status-text {
    display: none;
  }

  .icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }

  .top-actions {
    gap: 5px;
  }
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--glow-purple);
  transition: border-color 0.2s ease, transform 0.15s ease;
}

.icon-btn:active {
  transform: scale(0.96);
}

main {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 8px 16px calc(72px + env(safe-area-inset-bottom));
  display: grid;
  gap: 14px;
  box-sizing: border-box;
}

.scan-zone {
  background:
    linear-gradient(165deg, rgba(184, 122, 255, 0.1), transparent 45%),
    var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 100%;
}

.cam-hint {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(232, 204, 122, 0.35);
  background: rgba(232, 204, 122, 0.1);
  color: var(--gold);
  font-size: 0.8rem;
  line-height: 1.35;
  word-break: break-word;
}

.scan-idle {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scan-title {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
}

.scan-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  width: 100%;
}

.scan-actions .btn {
  width: 100%;
  max-width: none;
  min-height: 48px;
  border-radius: 14px;
}

.reader {
  display: none;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid var(--line);
  width: 100%;
  background: #000;
}

.reader.is-on {
  display: block;
}

.reader-stage {
  position: relative;
  width: 100%;
  height: min(42vh, 320px);
  background: #000;
}

.reader video {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  display: block !important;
  background: #000;
}

.scan-guide {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 78%;
  height: 32%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  border: 2px solid rgba(232, 204, 122, 0.85);
  border-radius: 10px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.28);
}

.scan-guide span {
  display: none;
}

.stop-scan {
  margin: 8px 0 0;
  width: 100%;
  max-width: none;
  min-height: 44px;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 14px 20px;
  font: 600 0.95rem/1 var(--font-body);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  color: var(--ink);
  width: 100%;
  max-width: 320px;
  box-shadow: var(--glow-gold);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  width: 100%;
  max-width: 320px;
  margin-top: 0;
}

.scan-actions .btn-ghost,
.scan-actions .btn-primary {
  margin-top: 0;
  max-width: none;
}

.btn-ghost:hover {
  border-color: var(--purple);
  color: var(--text);
}

.btn-soft {
  background: rgba(184, 122, 255, 0.08);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 14px;
  flex: 1;
}

.btn-soft.danger {
  color: var(--danger);
  border-color: rgba(255, 122, 154, 0.35);
  background: rgba(255, 122, 154, 0.08);
}

.btn-sell {
  background: linear-gradient(135deg, var(--purple), var(--purple-deep));
  color: #fff;
  border-radius: 16px;
  flex: 2;
  font-size: 1.05rem;
  padding: 16px 18px;
  box-shadow: var(--glow-purple);
}

.btn-sell-alt {
  background: rgba(7, 4, 15, 0.55);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 16px;
  flex: 1;
}

.stop-scan {
  margin: 12px auto 0;
  display: block;
}

.product-card {
  background:
    linear-gradient(160deg, rgba(184, 122, 255, 0.12), transparent 40%),
    var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  animation: rise 0.35s ease;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.product-head {
  display: flex;
  gap: 14px;
  align-items: center;
}

.product-thumb {
  width: 66px;
  height: 66px;
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(184, 122, 255, 0.2), rgba(232, 204, 122, 0.1));
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  color: var(--gold);
  font-size: 0.78rem;
  border: 1px solid var(--line);
}

.product-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  line-height: 1.25;
  font-weight: 600;
}

.meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.stock-display {
  margin: 18px 0 14px;
  padding: 18px;
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(184, 122, 255, 0.18), rgba(232, 204, 122, 0.08));
  border: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.stock-display .label {
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stock-display strong {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 11vw, 3.4rem);
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--gold);
  text-shadow: 0 0 24px rgba(232, 204, 122, 0.35);
}

.actions-sell,
.actions-manual,
.set-row {
  display: flex;
  gap: 8px;
}

.actions-manual {
  margin-top: 12px;
  flex-wrap: wrap;
}

.stepper {
  display: flex;
  align-items: center;
  background: rgba(7, 4, 15, 0.55);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  min-width: 140px;
}

.stepper .step {
  width: 42px;
  height: 46px;
  border: 0;
  background: transparent;
  color: var(--gold);
  font-size: 1.35rem;
  cursor: pointer;
}

.stepper input {
  width: 54px;
  height: 46px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: center;
  font: 700 1rem var(--font-body);
}

.set-stock {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.set-stock label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 10px;
}

.set-row input,
#search,
#manual-barcode {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(7, 4, 15, 0.65);
  color: var(--text);
  border-radius: 14px;
  padding: 13px 14px;
  font: 500 1rem var(--font-body);
}

.set-row .btn {
  white-space: nowrap;
  border-radius: 14px;
  width: auto;
  max-width: none;
}

.list-zone {
  margin-top: 2px;
}

.list-head {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.list-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}

.category-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 2px 12px;
  margin-bottom: 4px;
  max-width: 100%;
}

@media (max-width: 699px) {
  .category-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .category-chips::-webkit-scrollbar {
    display: none;
  }
}

.chip {
  flex: 0 0 auto;
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(16, 10, 28, 0.85);
  color: var(--muted);
  border-radius: 999px;
  padding: 9px 14px;
  font: 600 0.82rem/1 var(--font-body);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.chip.active {
  border-color: rgba(232, 204, 122, 0.55);
  color: var(--ink);
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  box-shadow: var(--glow-gold);
}

.product-list {
  display: grid;
  gap: 22px;
  width: 100%;
  min-width: 0;
}

.category-group {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.category-title {
  margin: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 0.92rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--purple);
}

.category-title em {
  font-style: normal;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.78rem;
  letter-spacing: 0;
  text-transform: none;
}

.product-list-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  min-width: 0;
}

.product-list-items li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  cursor: pointer;
  min-width: 0;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

@media (max-width: 699px) {
  .product-list-items li {
    padding: 9px 11px;
  }

  .product-list-items .name {
    font-size: 0.9rem;
  }

  .product-list-items .qty {
    font-size: 1.05rem;
  }

  .list-zone {
    margin-top: 0;
  }
}

.product-list-items li > div:first-child {
  min-width: 0;
  overflow: hidden;
}

.product-list-items li:active {
  transform: scale(0.99);
}

.product-list-items li.active {
  border-color: var(--line-strong);
  box-shadow: var(--glow-gold);
}

.product-list-items .name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-list-items .sub {
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 3px;
}

.product-list-items .qty {
  font-family: var(--font-display);
  font-size: 1.2rem;
  min-width: 36px;
  text-align: right;
  color: var(--gold);
  flex-shrink: 0;
}

.product-list-items .qty.low {
  color: var(--danger);
}

@media (min-width: 700px) {
  .product-list-items {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
}

@media (min-width: 980px) {
  .product-list-items {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .product-list-items li {
    padding: 12px 13px;
  }
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 18px 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(16, 10, 28, 0.95);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 13px 18px;
  border-radius: 999px;
  font-weight: 600;
  box-shadow: var(--shadow), var(--glow-purple);
  z-index: 50;
  max-width: calc(100% - 32px);
  animation: rise 0.25s ease;
  backdrop-filter: blur(12px);
}

.toast.ok { border-color: rgba(141, 255, 193, 0.4); }
.toast.err { border-color: rgba(255, 122, 154, 0.5); }

.hidden { display: none !important; }

dialog {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--bg-elev);
  color: var(--text);
  padding: 20px;
  width: min(420px, calc(100% - 32px));
  box-shadow: var(--shadow), var(--glow-purple);
}

dialog::backdrop {
  background: rgba(7, 4, 15, 0.78);
  backdrop-filter: blur(4px);
}

dialog h3 {
  margin: 0 0 14px;
  font-family: var(--font-display);
  color: var(--gold);
  letter-spacing: 0.06em;
}

.dialog-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.dialog-actions .btn {
  flex: 1;
  max-width: none;
  margin: 0;
  border-radius: 14px;
}

input:focus {
  outline: 2px solid rgba(184, 122, 255, 0.55);
  outline-offset: 1px;
}

@media (min-width: 700px) {
  main {
    padding-top: 18px;
  }

  .scan-actions {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 699px) {
  html, body {
    overflow-x: hidden;
  }

  .top {
    padding: 8px 10px 4px;
    gap: 6px;
    align-items: center;
  }

  .brand {
    min-width: 0;
    flex: 1;
  }

  .brand h1 {
    font-size: 1.3rem;
    line-height: 1;
  }

  .brand p {
    font-size: 0.55rem;
    letter-spacing: 0.08em;
    margin-top: 2px;
  }

  .top-actions {
    gap: 4px;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    box-shadow: none;
  }

  .odoo-status {
    padding: 0;
    width: 36px;
    height: 36px;
    justify-content: center;
    border-radius: 10px;
  }

  .odoo-status-text {
    display: none;
  }

  main {
    padding: 4px 10px calc(88px + env(safe-area-inset-bottom));
    gap: 10px;
    width: 100%;
  }

  .scan-zone {
    padding: 8px;
    border-radius: 12px;
  }

  .cam-hint {
    margin-bottom: 6px;
    padding: 8px 10px;
    font-size: 0.72rem;
  }

  .reader-stage {
    height: min(34vh, 240px);
  }

  .scan-guide {
    width: 88%;
    height: 40%;
  }

  .list-head h3 {
    font-size: 0.85rem;
  }

  .category-chips {
    margin: 0 -10px;
    padding: 0 10px 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .chip {
    padding: 7px 11px;
    font-size: 0.74rem;
  }

  .product-list-items {
    grid-template-columns: 1fr !important;
    gap: 6px;
  }

  .product-list-items li {
    padding: 9px 11px;
    border-radius: 12px;
  }

  .product-card {
    padding: 12px;
    border-radius: 14px;
  }

  .stock-display {
    margin: 12px 0 10px;
    padding: 12px;
  }

  .stock-display strong {
    font-size: 2rem;
  }

  .actions-sell {
    gap: 6px;
  }

  .btn-sell,
  .btn-sell-alt {
    padding: 12px 10px;
    font-size: 0.9rem;
  }

  .toast {
    bottom: calc(70px + env(safe-area-inset-bottom));
  }
}
