:root{
  --bg:#f5f7fb;
  --card:#ffffff;
  --text:#111827;
  --muted:#6b7280;
  --line:#e5e7eb;
  --primary:#111827;
  --danger:#b91c1c;
  --ok:#166534;
  --warn:#92400e;
}
*{box-sizing:border-box}
body{
  margin:0;
  font-family:Arial,sans-serif;
  background:var(--bg);
  color:var(--text);
}
.wrap{
  max-width:720px;
  margin:0 auto;
  padding:12px;
  padding-bottom:120px;
}
.topbar,.card{
  background:var(--card);
  border-radius:16px;
  padding:14px;
  box-shadow:0 4px 18px rgba(0,0,0,.06);
  margin-bottom:12px;
}
.title{
  font-size:22px;
  font-weight:700;
  margin:0 0 6px;
}
.sub{
  font-size:13px;
  color:var(--muted);
}
.badge{
  display:inline-block;
  font-size:12px;
  font-weight:700;
  padding:6px 10px;
  border-radius:999px;
  background:#fef3c7;
  color:var(--warn);
  margin-top:8px;
}
.label{
  font-size:12px;
  font-weight:700;
  color:var(--muted);
  margin-bottom:6px;
  text-transform:uppercase;
  letter-spacing:.04em;
}
.row{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}
.row > *{
  flex:1;
  min-width:0;
}
.row-search > input{
  flex:2;
}
input, select, button{
  width:100%;
  min-height:46px;
  border-radius:12px;
  border:1px solid var(--line);
  padding:10px 12px;
  font-size:16px;
  background:#fff;
}
button{
  border:none;
  background:var(--primary);
  color:#fff;
  font-weight:700;
  cursor:pointer;
}
button.secondary{
  background:#e5e7eb;
  color:#111827;
}
button.danger{
  background:var(--danger);
}
button:disabled{
  opacity:.6;
  cursor:not-allowed;
}
.list{
  display:flex;
  flex-direction:column;
  gap:10px;
}
.item{
  border:1px solid var(--line);
  border-radius:14px;
  padding:12px;
  background:#fff;
}
.item-title{
  font-weight:700;
  margin-bottom:4px;
}
.item-sub{
  color:var(--muted);
  font-size:13px;
  margin-bottom:8px;
  word-break:break-word;
}
.small{
  font-size:13px;
  color:var(--muted);
  margin-top:8px;
}
.cart-line{
  border:1px solid var(--line);
  border-radius:14px;
  padding:12px;
  margin-bottom:10px;
}
.cart-head{
  display:flex;
  justify-content:space-between;
  gap:10px;
  margin-bottom:10px;
}
.cart-title{
  font-weight:700;
  font-size:15px;
}
.cart-code{
  font-size:12px;
  color:var(--muted);
}
.grid-3{
  display:grid;
  grid-template-columns:1fr 1fr 1fr;
  gap:8px;
}
.total-box{
  position:fixed;
  left:0;
  right:0;
  bottom:0;
  background:#fff;
  border-top:1px solid var(--line);
  box-shadow:0 -6px 20px rgba(0,0,0,.08);
  padding:10px 12px calc(10px + env(safe-area-inset-bottom));
}
.total-inner{
  max-width:720px;
  margin:0 auto;
}
.total-row{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
}
.total-label{
  font-size:13px;
  color:var(--muted);
}
.total-value{
  font-size:28px;
  font-weight:800;
}
.actions-bottom{
  width:230px;
  display:flex;
  gap:8px;
}
.actions-bottom > *{
  flex:1;
}
.status{
  margin-top:10px;
  padding:12px;
  border-radius:12px;
  font-size:14px;
  display:none;
  white-space:pre-wrap;
}
.status.ok{
  display:block;
  background:#ecfdf5;
  color:var(--ok);
  border:1px solid #bbf7d0;
}
.status.error{
  display:block;
  background:#fef2f2;
  color:var(--danger);
  border:1px solid #fecaca;
}
.empty{
  color:var(--muted);
  font-size:14px;
  text-align:center;
  padding:16px 8px;
}
.scanner-modal{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.88);
  z-index:9999;
  display:none;
  align-items:center;
  justify-content:center;
  padding:14px;
}
.scanner-box{
  width:100%;
  max-width:560px;
  background:#111827;
  border-radius:18px;
  overflow:hidden;
  color:#fff;
}
.scanner-head{
  padding:12px 14px;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  border-bottom:1px solid rgba(255,255,255,.12);
}
.scanner-title{
  font-weight:700;
  font-size:16px;
}
.scanner-body{
  position:relative;
  background:#000;
}
#scannerVideo{
  width:100%;
  height:auto;
  display:block;
  background:#000;
}
.scanner-guide{
  position:absolute;
  left:10%;
  right:10%;
  top:35%;
  height:80px;
  border:2px solid #22c55e;
  border-radius:12px;
  box-shadow:0 0 0 9999px rgba(0,0,0,.15);
  pointer-events:none;
}
.scanner-foot{
  padding:12px 14px;
  font-size:13px;
  color:#d1d5db;
}
.scanner-close{
  width:auto;
  min-height:38px;
  padding:8px 12px;
  border-radius:10px;
  background:#ef4444;
  color:#fff;
  border:none;
  font-weight:700;
}
@media (max-width:640px){
  .grid-3{
    grid-template-columns:1fr;
  }
  .total-row{
    flex-direction:column;
    align-items:stretch;
  }
  .actions-bottom{
    width:100%;
  }
}