
:root {
  --bg:#f4f6f8;
  --panel:#fff;
  --ink:#17222e;
  --muted:#788491;
  --line:#e7ebef;
  --nav:#16232c;
  --accent:#ed713d;
  --green:#1b8a66;
  --amber:#c28523;
  --red:#c54f4f;
  --shadow:0 3px 12px #1525360a}
* {
  box-sizing:border-box}
body {
  margin:0;
  background:var(--bg);
  font-family:'DM Sans',sans-serif;
  color:var(--ink)}
button,input,select {
  font:inherit}
button {
  cursor:pointer}
.layout {
  display:flex;
  min-height:100vh}
.sidebar {
  background:var(--nav);
  color:#fff;
  width:240px;
  padding:25px 16px;
  display:flex;
  flex-direction:column;
  flex-shrink:0}
.brand {
  display:flex;
  flex-direction:column;
  align-items:stretch;
  gap:8px;
  padding:0 0 26px}
.brand-logo {
  display:block;
  width:168px;
  max-width:100%;
  height:auto;
  margin:0 auto;
  border-radius:9px}
.brand-caption {
  padding-left:0;
  text-align:center;
  color:#91a0aa;
  font-size:9px;
  letter-spacing:1.35px;
  font-weight:700}
.brandmark {
  width:38px;
  height:38px;
  border-radius:11px;
  background:#263741;
  display:grid;
  place-items:center;
  flex-shrink:0}
.brandmark svg {
  width:31px;
  height:31px;
  overflow:visible}
.brand b {
  font:800 16px Manrope;
  letter-spacing:-.4px}
.brand small {
  display:block;
  color:#91a0aa;
  font-size:10px;
  letter-spacing:1.15px;
  margin-top:2px}
.nav-label {
  color:#7f8f99;
  font-size:10px;
  letter-spacing:1.3px;
  font-weight:700;
  padding:0 12px 9px;
  margin-top:10px}
.nav-item {
  border:0;
  background:transparent;
  color:#aebac1;
  width:100%;
  text-align:left;
  padding:11px 12px;
  border-radius:8px;
  display:flex;
  gap:12px;
  align-items:center;
  margin:2px 0;
  font-size:13px}
.nav-item:hover,.nav-item.active {
  background:#273740;
  color:white}
.nav-item.active {
  box-shadow:inset 3px 0 var(--accent)}
.ico {
  width:18px;
  text-align:center;
  font-size:16px}
.store-card {
  margin-top:auto;
  border:1px solid #34444d;
  border-radius:10px;
  padding:12px;
  color:#b7c1c7;
  font-size:11px;
  line-height:1.6}
.store-card strong {
  color:#fff;
  display:block;
  font-size:12px}
.online {
  color:#72c89b}
.main {
  flex:1;
  min-width:0}
.topbar {
  height:70px;
  background:#fff;
  border-bottom:1px solid var(--line);
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 34px}
.crumb {
  font-size:12px;
  color:var(--muted)}
.crumb b {
  color:var(--ink);
  font-weight:600}
.top-right {
  display:flex;
  align-items:center;
  gap:19px;
  color:#89939d;
  font-size:12px}
.avatar {
  width:31px;
  height:31px;
  border-radius:50%;
  background:#f4dfd4;
  color:#a95932;
  display:grid;
  place-items:center;
  font-weight:700}
.content {
  max-width:1320px;
  margin:auto;
  padding:30px 34px 54px}
.pagehead {
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  margin-bottom:23px}
.eyebrow {
  font-size:10px;
  letter-spacing:1.4px;
  color:var(--accent);
  font-weight:700;
  margin-bottom:7px}
.pagehead h1 {
  font:700 25px Manrope;
  margin:0;
  letter-spacing:-.7px}
.sub {
  font-size:12px;
  color:var(--muted);
  margin-top:6px}
.btn {
  border:1px solid var(--line);
  background:#fff;
  color:var(--ink);
  border-radius:7px;
  padding:9px 13px;
  font-size:12px;
  font-weight:600;
  display:inline-flex;
  align-items:center;
  gap:7px}
.btn:hover {
  background:#f8fafb}
.btn-primary {
  background:var(--accent);
  border-color:var(--accent);
  color:#fff}
.btn-primary:hover {
  background:#d96030}
.btn-small {
  padding:6px 9px;
  font-size:11px}
.stats {
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:14px;
  margin-bottom:20px}
.stat {
  background:#fff;
  border:1px solid var(--line);
  border-radius:9px;
  padding:17px 18px;
  box-shadow:var(--shadow)}
.stat-top {
  display:flex;
  justify-content:space-between;
  align-items:center;
  color:var(--muted);
  font-size:11px}
.stat-ico {
  width:30px;
  height:30px;
  border-radius:8px;
  background:#fff2ec;
  color:var(--accent);
  display:grid;
  place-items:center;
  font-size:14px}
.stat-num {
  font:700 24px Manrope;
  margin-top:9px;
  letter-spacing:-.7px}
.stat-note {
  font-size:10px;
  color:#98a2aa;
  margin-top:3px}
.stat-note.warn {
  color:var(--amber)}
.panel {
  background:#fff;
  border:1px solid var(--line);
  border-radius:9px;
  box-shadow:var(--shadow);
  margin-bottom:18px}
.panel-head {
  padding:17px 19px;
  border-bottom:1px solid var(--line);
  display:flex;
  align-items:center;
  justify-content:space-between}
.panel-title {
  font:700 13px Manrope}
.panel-caption {
  font-size:10px;
  color:var(--muted);
  margin-top:3px}
.toolbar {
  display:flex;
  gap:8px;
  align-items:center}
.search {
  position:relative}
.search input {
  padding:8px 10px 8px 30px;
  border:1px solid var(--line);
  border-radius:7px;
  width:220px;
  font-size:11px;
  outline:none}
.search span {
  position:absolute;
  left:10px;
  top:7px;
  color:#929ca5}
.filter {
  border:1px solid var(--line);
  border-radius:7px;
  padding:8px 10px;
  font-size:11px;
  color:#53616c;
  background:#fff}
.tablewrap {
  overflow:auto}
table {
  width:100%;
  border-collapse:collapse;
  min-width:760px}
th {
  text-align:left;
  padding:11px 18px;
  color:#929ca5;
  font-weight:600;
  font-size:9px;
  letter-spacing:.75px;
  border-bottom:1px solid var(--line)}
td {
  padding:12px 18px;
  border-bottom:1px solid #f0f2f4;
  font-size:11px}
tr:last-child td {
  border-bottom:0}
.prod {
  display:flex;
  gap:10px;
  align-items:center}
.prod-icon {
  width:32px;
  height:32px;
  border-radius:7px;
  background:#f1f4f5;
  display:grid;
  place-items:center;
  font-size:16px}
.prod-name {
  font-weight:600;
  font-size:11px}
.prod-code {
  font-size:9px;
  color:#98a2aa;
  margin-top:3px}
.qty {
  font-weight:700;
  font-size:12px}
.unit {
  font-size:10px;
  color:var(--muted);
  margin-left:3px}
.badge {
  padding:4px 7px;
  border-radius:20px;
  background:#eaf6f0;
  color:#21825f;
  font-size:9px;
  font-weight:600;
  white-space:nowrap}
.badge.low {
  background:#fff3df;
  color:#ac7219}
.badge.out {
  background:#fdecec;
  color:#bb4545}
.barcode-mini {
  height:22px;
  width:66px;
  object-fit:contain}
.actions {
  display:flex;
  gap:5px}
.icon-btn {
  border:1px solid var(--line);
  background:#fff;
  color:#697681;
  border-radius:5px;
  width:27px;
  height:27px;
  font-size:12px}
.icon-btn:hover {
  color:var(--accent);
  border-color:#f0b89f}
.empty {
  padding:36px;
  text-align:center;
  color:var(--muted);
  font-size:12px}
.lower {
  display:grid;
  grid-template-columns:1.15fr .85fr;
  gap:18px}
.list-row {
  padding:12px 18px;
  border-bottom:1px solid #f0f2f4;
  display:flex;
  align-items:center;
  gap:10px}
.list-row:last-child {
  border:0}
.event-icon {
  width:29px;
  height:29px;
  border-radius:50%;
  display:grid;
  place-items:center;
  font-size:13px;
  background:#eaf6f0;
  color:#21825f}
.event-icon.out {
  background:#fff1e9;
  color:#d16a3b}
.event-desc {
  flex:1;
  font-size:10px;
  line-height:1.5}
.event-desc b {
  font-size:11px}
.event-time {
  font-size:9px;
  color:#98a2aa;
  margin-top:2px}
.event-qty {
  font-weight:700;
  font-size:11px}
.positive {
  color:var(--green)}
.negative {
  color:#cc6742}
.empty-state {
  text-align:center;
  padding:25px;
  color:#99a2aa;
  font-size:11px}
.modal-back {
  position:fixed;
  inset:0;
  background:#13202b77;
  display:none;
  align-items:center;
  justify-content:center;
  padding:16px;
  z-index:10}
.modal-back.show {
  display:flex}
.modal {
  background:white;
  border-radius:12px;
  width:min(470px,100%);
  box-shadow:0 22px 70px #0003;
  overflow:hidden}
.modal-head {
  padding:18px 21px;
  border-bottom:1px solid var(--line);
  display:flex;
  justify-content:space-between;
  align-items:center}
.modal-head h2 {
  font:700 15px Manrope;
  margin:0}
.close {
  border:0;
  background:transparent;
  color:#77838d;
  font-size:20px}
.modal-body {
  padding:19px 21px}
.field {
  margin-bottom:13px}
.field label {
  display:block;
  font-size:10px;
  font-weight:700;
  color:#586570;
  margin-bottom:6px}
.field input,.field select {
  width:100%;
  border:1px solid #dfe4e8;
  border-radius:6px;
  padding:9px 10px;
  outline:none;
  font-size:12px}
.field input:focus,.field select:focus {
  border-color:#e99771;
  box-shadow:0 0 0 2px #ed713d18}
.formgrid {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px}
.modal-foot {
  padding:13px 21px;
  border-top:1px solid var(--line);
  display:flex;
  justify-content:flex-end;
  gap:8px}
.toast {
  position:fixed;
  bottom:20px;
  left:50%;
  transform:translate(-50%,20px);
  background:#1c2a33;
  color:white;
  padding:10px 16px;
  border-radius:8px;
  font-size:12px;
  opacity:0;
  transition:.2s;
  pointer-events:none;
  z-index:30}
.toast.show {
  opacity:1;
  transform:translate(-50%,0)}
.hide {
  display:none!important}
.page {
  display:none}
.page.active {
  display:block}
.history-filters {
  display:flex;
  flex-wrap:wrap;
  justify-content:flex-end;
  gap:8px}
.label-preview {
  text-align:center;
  border:1px dashed #d9dfe3;
  padding:12px;
  margin-top:12px;
  border-radius:7px}
.label-preview svg {
  max-width:100%}
.label-preview strong {
  display:block;
  font-size:11px;
  margin-top:8px}
.qr-mini {
  width:34px;
  height:34px;
  display:grid;
  place-items:center;
  overflow:hidden;
  background:#fff}
.qr-mini canvas,.qr-mini img {
  width:34px!important;
  height:34px!important;
  image-rendering:pixelated}
.label-preview #qrCode {
  display:flex;
  justify-content:center}
.label-preview #qrCode img,.label-preview #qrCode canvas {
  width:150px!important;
  height:150px!important}
.label-preview small {
  color:#89939d;
  font-size:9px}
.app-footer {
  text-align:center;
  border-top:1px solid var(--line);
  padding:17px 12px;
  color:#8b969f;
  font-size:10px;
  background:#fff}
.mobile-menu {
  display:none}

@media(max-width:850px) {
  .sidebar {
  width:65px;
  padding:20px 8px}
.brand {
  padding:0 0 24px;
  align-items:center}
.brand-logo {
  width:48px}
.brand-caption {
  display:none}
.brand b,.brand small,.nav-label,.nav-item span:not(.ico),.store-card {
  display:none}
.nav-item {
  justify-content:center;
  padding:12px 0}
.content {
  padding:24px 18px}
.topbar {
  padding:0 18px}
.stats {
  grid-template-columns:repeat(2,1fr)}
.lower {
  grid-template-columns:1fr}
}

@media(max-width:560px) {
  .topbar {
  height:58px}
.top-right .user-label,.top-right .date-label {
  display:none}
.content {
  padding:20px 12px}
.pagehead {
  align-items:center}
.pagehead h1 {
  font-size:21px}
.pagehead .btn {
  padding:9px}
.stats {
  gap:8px}
.stat {
  padding:13px}
.stat-num {
  font-size:21px}
.toolbar {
  flex-wrap:wrap}
.search input {
  width:170px}
.panel-head {
  padding:14px}
.formgrid {
  grid-template-columns:1fr 1fr}
}

.form-hint { color:var(--muted); font-size:11px; line-height:1.5; margin:8px 0 0 }
.account-card { background:#f4f6f8; border:1px solid var(--line); border-radius:10px; padding:14px; margin-bottom:12px }
.account-name { font-family:Manrope,sans-serif; font-size:16px; font-weight:800; margin-bottom:4px }
.confirm-line { display:flex; gap:8px; align-items:flex-start; color:var(--ink); font-size:12px; line-height:1.5; margin-top:12px }
.confirm-line input { margin-top:2px }
.modal { max-height:calc(100vh - 32px); overflow:auto }

/* Keep the scanned-stock dialog inside the visible viewport, including mobile safe areas. */
#moveModal {
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
#moveModal .modal {
  width: min(500px, 100%);
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#moveModal #moveForm {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
#moveModal .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
#moveModal .modal-foot {
  flex-shrink: 0;
  padding-bottom: max(13px, env(safe-area-inset-bottom));
}

/* Lightweight phone-first screen opened by QR scan; dashboard loads only on request. */
body.scan-mode { min-height: 100dvh; background: #f3f5f6; }
body.scan-mode .layout { display: none !important; }
.scan-screen { display: none; }
.scan-screen.show {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: max(18px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: radial-gradient(ellipse at 50% 0, #fff 0, #f3f5f6 70%);
}
.scan-card {
  width: min(460px, 100%);
  max-height: calc(100vh - 36px);
  max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 36px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: clamp(20px, 6vw, 34px);
  border: 1px solid #e5e9ed;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 18px 55px #14253618;
}
.scan-brand { display: flex; align-items: center; gap: 11px; padding-bottom: 20px; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.scan-brand img { width: 46px; height: 46px; object-fit: cover; border-radius: 9px; }
.scan-brand span { color: #66737d; font-size: 10px; font-weight: 800; letter-spacing: 1.1px; }
.scan-eyebrow { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: 1.15px; }
.scan-card h1 { margin: 8px 0; font: 800 clamp(21px, 5vw, 27px)/1.2 Manrope, sans-serif; overflow-wrap: anywhere; }
.scan-code { color: #73808a; font: 12px/1.5 monospace; }
.scan-stock { margin: 18px 0 22px; padding: 13px 15px; border-radius: 10px; background: #f4f6f8; color: #273640; font-size: 14px; font-weight: 700; }
.scan-movement-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin: 0 0 17px; border: 1px solid #e5e9ed; border-radius: 11px; background: #f4f6f8; }
.scan-movement-toggle button { min-height: 42px; border: 0; border-radius: 8px; background: transparent; color: #66737d; font-size: 13px; font-weight: 700; }
.scan-movement-toggle button.selected { background: #fff; color: #17222e; box-shadow: 0 1px 5px #16232c18; }
.scan-card .field { margin-bottom: 16px; }
.scan-card .field label { font-size: 12px; }
.scan-card .field input { min-height: 46px; font-size: 16px; }
.scan-error { min-height: 0; margin: 0 0 12px; color: #bc4141; font-size: 12px; line-height: 1.5; }
.scan-submit { width: 100%; min-height: 48px; justify-content: center; }
.scan-submit:disabled { opacity: .7; cursor: wait; }
.scan-dashboard-error { width: 100%; margin-top: 10px; }
.scan-success-icon { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 18px; border-radius: 50%; background: #e5f5ef; color: #16835f; font-size: 27px; font-weight: 800; }
.scan-result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 22px 0; }
.scan-result-grid > div { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 11px; background: #f8f9fa; }
.scan-result-grid span { display: block; margin-bottom: 7px; color: #73808a; font-size: 11px; }
.scan-result-grid strong { display: block; color: #17222e; font: 800 19px Manrope, sans-serif; overflow-wrap: anywhere; }
@media (max-height: 620px) {
  .scan-screen.show { place-items: start center; }
  .scan-card { margin: auto 0; }
}
