:root {
  color-scheme: light;
  --bg: #eef2f7;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #17202e;
  --muted: #697386;
  --line: #d9e1ec;
  --brand: #604ae3;
  --brand-strong: #4b37c9;
  --success: #0f766e;
  --warning: #b7791f;
  --danger: #c2413b;
  --shadow: 0 16px 40px rgba(28, 37, 46, .08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(96, 74, 227, .10), transparent 34rem),
    linear-gradient(180deg, #f7f9fc 0%, var(--bg) 100%);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.side-nav {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 260px;
  padding: 18px 16px;
  background: linear-gradient(180deg, #ffffff 0%, #f3f0ff 100%);
  border-right: 1px solid rgba(217, 225, 236, .95);
  box-shadow: 12px 0 34px rgba(28, 37, 46, .08);
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  color: var(--ink);
  text-decoration: none;
}

.side-logo {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: #fff;
  background: var(--brand);
  border-radius: 14px;
  font-size: 24px;
  box-shadow: 0 12px 28px rgba(96, 74, 227, .24);
}

.side-brand strong {
  display: block;
  font-size: 19px;
  line-height: 1;
}

.side-brand small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.side-menu {
  display: grid;
  gap: 6px;
  margin-top: 20px;
}

.side-menu a {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  padding: 10px 12px;
  color: #636b7d;
  border-radius: 12px;
  font-weight: 850;
  text-decoration: none;
}

.side-menu a i {
  display: grid;
  place-items: center;
  width: 24px;
  font-size: 20px;
}

.side-menu a.active,
.side-menu a:hover {
  color: var(--brand);
  background: rgba(96, 74, 227, .10);
}

.app {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 18px;
}

.side-nav ~ .app {
  width: calc(100% - 260px);
  max-width: 1280px;
  margin-left: 260px;
  margin-right: 0;
}

.admin-app {
  width: min(100%, 1280px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 72px;
  margin-bottom: 16px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, .86);
  border: 1px solid rgba(217, 225, 236, .9);
  border-radius: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.top-actions,
.button-row,
.item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.top-actions {
  justify-content: flex-end;
}

.eyebrow {
  margin-bottom: 3px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

h1 i {
  color: var(--brand);
}

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

.scanner {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 8.4;
  min-height: 230px;
  background: #101722;
  border: 1px solid #202b3b;
  border-radius: 14px;
  box-shadow: var(--shadow);
}

video,
#reader video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
}

#reader {
  position: absolute;
  inset: 0;
  z-index: 1;
}

#reader__dashboard,
#reader__scan_region > img,
#reader__header_message {
  display: none !important;
}

#reader__scan_region {
  width: 100% !important;
  min-height: 100% !important;
}

.scanner-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.scan-box {
  width: min(72vw, 460px);
  aspect-ratio: 1.85 / 1;
  border: 3px solid rgba(255, 255, 255, .9);
  border-radius: 12px;
  box-shadow: 0 0 0 999px rgba(3, 7, 18, .28), inset 0 0 0 1px rgba(255, 255, 255, .18);
}

.camera-status,
.product-preview {
  margin-top: 10px;
  padding: 10px 12px;
  color: #4b5568;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
}

.camera-status.ok,
.product-preview.ok {
  color: #0f5f57;
  background: #ecfdf5;
  border-color: #b7ebd5;
}

.camera-status.error {
  color: #991b1b;
  background: #fef2f2;
  border-color: #fecaca;
}

.product-preview.warn {
  color: var(--warning);
  background: #fffbeb;
  border-color: #fde68a;
}

.controls,
.login-box {
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.scan-row,
.product-form {
  display: flex;
  align-items: end;
  gap: 10px;
}

.scan-row {
  margin-top: 12px;
}

.button-row {
  margin-top: 12px;
}

.field,
form {
  display: grid;
  gap: 7px;
}

.product-form {
  flex-wrap: wrap;
}

.product-form .field {
  flex: 1 1 190px;
}

.code-field {
  flex: 1 1 220px;
}

.qty-field {
  width: 104px;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

input {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}

input:focus {
  border-color: rgba(96, 74, 227, .65);
  box-shadow: 0 0 0 4px rgba(96, 74, 227, .11);
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 9px 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

button:active,
.button:active {
  transform: translateY(1px);
}

.primary {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
  box-shadow: 0 10px 22px rgba(96, 74, 227, .22);
}

.primary:hover {
  background: var(--brand-strong);
}

.danger {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.summary div {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "icon number"
    "icon label";
  column-gap: 12px;
  align-items: center;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.summary i {
  grid-area: icon;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: var(--brand);
  background: rgba(96, 74, 227, .10);
  border-radius: 12px;
  font-size: 23px;
}

.summary strong {
  grid-area: number;
  font-size: 28px;
  line-height: 1;
}

.summary span {
  grid-area: label;
}

.summary span,
.section-title {
  color: var(--muted);
  font-size: 13px;
}

.section-title {
  margin: 18px 0 10px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.items {
  display: grid;
  gap: 9px;
  margin-top: 10px;
}

.item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 13px;
  background: rgba(255, 255, 255, .92);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.item-code {
  font-size: 17px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.item-name {
  margin-top: 3px;
  font-size: 15px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.item-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.item button {
  min-height: 38px;
  padding: 7px 10px;
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 10;
  min-height: 42px;
  padding: 12px 14px;
  color: #fff;
  background: #1c252e;
  border-radius: 12px;
  box-shadow: 0 18px 36px rgba(15, 23, 42, .24);
}

.dashboard-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 8%, rgba(96, 74, 227, .12), transparent 30rem),
    linear-gradient(180deg, #f6f8fb 0%, #edf2f7 100%);
}

.nav-panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .96) 0%, rgba(245, 247, 251, .96) 100%);
  backdrop-filter: blur(16px);
}

.nav-panel::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  height: 120px;
  background:
    linear-gradient(145deg, rgba(96, 74, 227, .10), rgba(15, 118, 110, .10));
  border: 1px solid rgba(217, 225, 236, .88);
  border-radius: 16px;
  pointer-events: none;
}

.dashboard-main {
  padding: 22px;
}

.page-topbar {
  position: sticky;
  top: 14px;
  z-index: 12;
  min-height: 82px;
  margin-bottom: 18px;
  border-radius: 16px;
}

.dashboard-grid {
  display: grid;
  gap: 14px;
}

.admin-dashboard-grid {
  grid-template-columns: minmax(0, .88fr) minmax(0, 1.12fr);
  align-items: start;
}

.scanner-dashboard-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, .8fr);
  align-items: stretch;
  margin-bottom: 14px;
}

.dashboard-card {
  padding: 16px;
  background: rgba(255, 255, 255, .90);
  border: 1px solid rgba(217, 225, 236, .95);
  border-radius: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.card-head .section-title {
  margin: 0;
}

.card-head p {
  max-width: 620px;
}

.card-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  color: var(--brand);
  background: rgba(96, 74, 227, .10);
  border-radius: 12px;
  font-size: 22px;
}

.metric-grid {
  margin: 0 0 14px;
}

.metric-grid div,
.compact-summary div {
  min-height: 92px;
  border-radius: 16px;
}

.action-strip {
  margin: 0 0 14px;
  padding: 10px;
  background: rgba(255, 255, 255, .72);
  border: 1px solid rgba(217, 225, 236, .95);
  border-radius: 14px;
}

.scan-console {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100%;
}

.scan-console .scanner {
  min-height: 360px;
  aspect-ratio: 16 / 9;
  border-radius: 16px;
}

.operator-panel {
  display: flex;
  flex-direction: column;
}

.operator-panel .button-row {
  margin-top: 14px;
}

.compact-summary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: auto 0 0;
  padding-top: 14px;
}

.items {
  max-height: 54vh;
  overflow: auto;
  padding-right: 2px;
}

.admin-dashboard-grid .items {
  max-height: 58vh;
}

.item {
  transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease;
}

.item:hover {
  border-color: rgba(96, 74, 227, .25);
  box-shadow: 0 12px 28px rgba(28, 37, 46, .07);
  transform: translateY(-1px);
}

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 18px;
}

.login-box {
  width: min(100%, 430px);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  color: #fff;
  background: var(--brand);
  border-radius: 16px;
  font-size: 28px;
  box-shadow: 0 14px 28px rgba(96, 74, 227, .25);
}

.login-box form {
  margin-top: 18px;
}

.login-error {
  margin-top: 12px;
  padding: 10px;
  color: #991b1b;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 10px;
}

.scanner-login {
  min-height: 100vh;
  background:
    radial-gradient(circle at 14% 18%, rgba(96, 74, 227, .34), transparent 24rem),
    radial-gradient(circle at 84% 76%, rgba(15, 118, 110, .28), transparent 24rem),
    linear-gradient(135deg, #101828 0%, #172033 48%, #eef2f7 48.2%, #f8fafc 100%),
    #111827;
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 460px);
  align-items: stretch;
  place-items: stretch;
  gap: 28px;
  width: min(1160px, calc(100% - 36px));
  margin: 0 auto;
  padding: 24px 0;
}

.login-hero,
.pro-login-box {
  position: relative;
  overflow: hidden;
  min-height: 620px;
  border: 1px solid rgba(255, 255, 255, .22);
  box-shadow: 0 24px 70px rgba(6, 14, 28, .30);
}

.login-hero {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 28px;
  color: #fff;
  background:
    radial-gradient(circle at 22% 16%, rgba(96, 74, 227, .46), transparent 22rem),
    linear-gradient(145deg, rgba(17, 24, 39, .80), rgba(15, 23, 42, .62));
  border-radius: 18px;
  backdrop-filter: blur(16px);
}

.login-hero-top,
.login-metrics,
.login-foot,
.login-box-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hero-badge,
.hero-live,
.login-foot span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 850;
}

.hero-badge {
  color: #fff;
  background: rgba(255, 255, 255, .13);
  border: 1px solid rgba(255, 255, 255, .20);
}

.hero-live {
  color: #bbf7d0;
  background: rgba(22, 163, 74, .14);
  border: 1px solid rgba(134, 239, 172, .30);
}

.hero-live i {
  font-size: 9px;
}

.hero-content {
  width: min(100%, 620px);
}

.login-mark {
  margin-bottom: 18px;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .24);
  box-shadow: 0 18px 44px rgba(0, 0, 0, .22);
}

.hero-content .eyebrow {
  color: #c7d2fe;
}

.hero-content h1 {
  display: block;
  max-width: 610px;
  margin-top: 8px;
  color: #fff;
  font-size: 46px;
  line-height: 1.03;
}

.hero-content p:last-child {
  max-width: 560px;
  margin-top: 16px;
  color: rgba(255, 255, 255, .78);
  font-size: 16px;
  line-height: 1.65;
}

.scanner-card {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 16px;
  align-items: center;
  width: min(100%, 440px);
  padding: 14px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 16px;
}

.scan-window {
  position: relative;
  overflow: hidden;
  height: 90px;
  background: rgba(5, 11, 23, .56);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 12px;
}

.scan-window::before {
  content: "";
  position: absolute;
  inset: 18px;
  border: 2px solid rgba(255, 255, 255, .68);
  border-radius: 8px;
}

.scan-window span {
  position: absolute;
  left: 18px;
  right: 18px;
  top: 43px;
  height: 2px;
  background: #6ee7b7;
  box-shadow: 0 0 18px rgba(110, 231, 183, .88);
}

.scanner-card strong,
.scanner-card small {
  display: block;
}

.scanner-card strong {
  color: #fff;
  font-size: 18px;
}

.scanner-card small {
  margin-top: 5px;
  color: rgba(255, 255, 255, .70);
  line-height: 1.45;
}

.login-metrics {
  align-items: stretch;
}

.login-metrics div {
  flex: 1 1 0;
  padding: 13px;
  background: rgba(255, 255, 255, .10);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 14px;
}

.login-metrics strong,
.login-metrics span {
  display: block;
}

.login-metrics strong {
  color: #fff;
  font-size: 18px;
}

.login-metrics span {
  margin-top: 3px;
  color: rgba(255, 255, 255, .68);
  font-size: 12px;
  font-weight: 800;
}

.pro-login-box {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  padding: 34px;
  background: rgba(255, 255, 255, .94);
  border-radius: 18px;
  backdrop-filter: blur(18px);
}

.login-box-head {
  align-items: flex-start;
  margin-bottom: 28px;
}

.login-box-head h2 {
  margin: 3px 0 0;
  font-size: 30px;
  line-height: 1.08;
}

.login-lock {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  color: var(--brand);
  background: rgba(96, 74, 227, .10);
  border-radius: 14px;
  font-size: 24px;
}

.pro-login-form {
  gap: 16px;
}

.input-shell label {
  color: #536075;
  font-size: 13px;
  letter-spacing: 0;
}

.login-input {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: border-color .18s ease, box-shadow .18s ease;
}

.login-input:focus-within {
  border-color: rgba(96, 74, 227, .70);
  box-shadow: 0 0 0 4px rgba(96, 74, 227, .12);
}

.login-input > i {
  color: var(--brand);
  font-size: 20px;
}

.login-input input {
  min-height: 50px;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.login-input input:focus {
  box-shadow: none;
}

.ghost-icon {
  width: 36px;
  min-height: 36px;
  padding: 0;
  color: #64748b;
  background: transparent;
  border: 0;
  border-radius: 9px;
  font-size: 18px;
}

.ghost-icon:hover {
  color: var(--brand);
  background: rgba(96, 74, 227, .09);
}

.login-submit {
  width: 100%;
  min-height: 52px;
  margin-top: 4px;
  border-radius: 12px;
  font-size: 15px;
}

.login-submit:disabled {
  cursor: wait;
  opacity: .78;
}

.pro-login-box .login-error {
  display: flex;
  align-items: center;
  min-height: 44px;
  font-weight: 800;
}

.login-foot {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: #64748b;
}

.login-foot span {
  padding: 0;
  font-size: 12px;
}

@media (max-width: 720px) {
  .side-nav {
    position: sticky;
    inset: 0 0 auto 0;
    width: 100%;
    padding: 10px;
    border-right: 0;
    border-bottom: 1px solid rgba(217, 225, 236, .95);
  }

  .side-brand {
    min-height: 44px;
  }

  .side-logo {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    font-size: 21px;
  }

  .side-menu {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 10px;
  }

  .side-menu a {
    justify-content: center;
    min-height: 40px;
    padding: 8px;
  }

  .side-menu a span {
    font-size: 13px;
  }

  .side-nav ~ .app {
    width: 100%;
    margin-left: 0;
  }

  .app {
    padding: 10px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    border-radius: 12px;
  }

  .top-actions {
    width: 100%;
    justify-content: stretch;
  }

  .top-actions > * {
    flex: 1 1 auto;
  }

  h1 {
    font-size: 21px;
  }

  .scanner {
    aspect-ratio: 4 / 3;
  }

  .scan-row {
    display: grid;
    grid-template-columns: 1fr 92px;
  }

  .scan-row .primary {
    grid-column: 1 / -1;
  }

  .item {
    grid-template-columns: 1fr;
  }

  .item-actions {
    justify-content: stretch;
  }

  .item-actions button {
    flex: 1 1 auto;
  }
}

@media (max-width: 980px) {
  .dashboard-main {
    padding: 12px;
  }

  .page-topbar {
    position: relative;
    top: auto;
  }

  .scanner-dashboard-grid,
  .admin-dashboard-grid {
    grid-template-columns: 1fr;
  }

  .scan-console .scanner {
    min-height: 280px;
  }

  .items,
  .admin-dashboard-grid .items {
    max-height: none;
  }

  .nav-panel::after {
    display: none;
  }

  .login-shell {
    grid-template-columns: 1fr;
    width: min(620px, calc(100% - 24px));
  }

  .login-hero,
  .pro-login-box {
    min-height: auto;
  }

  .pro-login-box {
    order: -1;
  }

  .login-hero {
    gap: 24px;
  }

  .hero-content h1 {
    font-size: 34px;
  }
}

@media (max-width: 560px) {
  .dashboard-card {
    padding: 12px;
    border-radius: 14px;
  }

  .card-head {
    gap: 10px;
  }

  .card-icon {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    font-size: 20px;
  }

  .compact-summary {
    grid-template-columns: 1fr;
  }

  .login-shell {
    width: calc(100% - 20px);
    padding: 10px 0;
  }

  .login-hero {
    padding: 18px;
    border-radius: 14px;
  }

  .login-hero-top,
  .login-metrics,
  .scanner-card,
  .login-foot {
    display: grid;
    grid-template-columns: 1fr;
  }

  .hero-content h1 {
    font-size: 28px;
  }

  .pro-login-box {
    padding: 22px;
    border-radius: 14px;
  }

  .login-box-head h2 {
    font-size: 26px;
  }
}
