* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: "PingFang SC", "Noto Sans SC", sans-serif; background: #1a0c0c; color: #2b1212; }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; }

.app { min-height: 100%; }
.hidden { display: none !important; }

.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, #7a1d1d, #1a0c0c 60%);
}
.login-card {
  width: 420px;
  max-width: calc(100% - 32px);
  background: #fff;
  border-radius: 16px;
  padding: 28px 28px 22px;
  box-shadow: 0 16px 40px rgba(0,0,0,.28);
}
.login-card h1 { margin: 0 0 6px; font-size: 24px; color: #b42318; }
.login-card p { margin: 0 0 20px; color: #8a6a6a; }
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 6px; font-size: 13px; color: #6b4a4a; }
.field select, .field input {
  width: 100%;
  height: 42px;
  border: 1px solid #ead4d4;
  border-radius: 8px;
  padding: 0 12px;
  background: #fffaf8;
}
.btn {
  height: 44px;
  border: 0;
  border-radius: 10px;
  padding: 0 18px;
  font-weight: 600;
}
.btn-primary { background: #c41e3a; color: #fff; }
.btn-primary:disabled { opacity: .45; }
.btn-ghost { background: #f6eaea; color: #7a2a2a; }
.btn-dark { background: #2b1212; color: #fff; }
.btn-block { width: 100%; }
.err { color: #c41e3a; min-height: 20px; font-size: 13px; margin: 8px 0; }

.cashier { height: 100vh; display: grid; grid-template-rows: 56px 1fr; position: relative; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: #c41e3a;
  color: #fff;
}
.topbar-title { font-weight: 700; }
.topbar-meta { font-size: 13px; opacity: .92; }
.topbar-actions { display: flex; gap: 8px; }
.topbar-actions .btn { height: 34px; }

.main { display: grid; grid-template-columns: 1.4fr 0.9fr; min-height: 0; }
.products {
  padding: 14px;
  overflow: auto;
  background: #f7efe9;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  grid-auto-rows: max-content;
  gap: 12px;
  align-content: start;
  align-items: start;
}
.product {
  display: flex;
  flex-direction: column;
  align-self: start;
  height: auto;
  background: #fff;
  border: 2px solid #e8e4df;
  border-radius: 12px;
  overflow: visible;
  text-align: left;
  padding: 0 0 2px;
  color: #2b1212;
  cursor: pointer;
}
.product.selected {
  border-color: #2c3e50;
  box-shadow: 0 0 0 3px rgba(44, 62, 80, .18);
}
.product .cover {
  background: #f5f2ee;
  overflow: hidden;
  border-radius: 10px 10px 0 0;
}
.product img, .product .ph {
  width: 100%;
  height: 118px;
  object-fit: contain;
  background: #f5f2ee;
  display: block;
}
.product .ph { display: flex; align-items: center; justify-content: center; color: #8a8078; font-size: 12px; }
.product .name {
  padding: 8px 10px 0;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.35;
  color: #1a1210;
}
.product .price {
  margin: 0;
  padding: 4px 10px 10px;
  color: #3d342e;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.side {
  background: #fff;
  border-left: 1px solid #ead4d4;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
}
.scale-panel { padding: 14px 16px 8px; border-bottom: 1px solid #f0e0e0; }
.scale-row { display: flex; justify-content: space-between; align-items: baseline; }
.kg { font-size: 42px; font-weight: 700; color: #1a0c0c; letter-spacing: 1px; }
.kg small { font-size: 16px; font-weight: 500; color: #8a6a6a; }
.status {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: #eee;
}
.status.ok { background: #d7f5d8; color: #167c28; }
.status.warn { background: #fff1c2; color: #8a6200; }
.status.bad { background: #ffd6d6; color: #b42318; }
.scale-actions { display: flex; gap: 8px; margin-top: 10px; }
.scale-actions .btn, .manual input { flex: 1; height: 40px; }
.manual { display: flex; gap: 8px; margin-top: 8px; }
.manual input { width: 100%; border: 1px solid #ead4d4; border-radius: 8px; padding: 0 10px; }

.cart { overflow: auto; padding: 8px 12px; }
.cart-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px dashed #f0e0e0;
}
.cart-item button { height: 32px; padding: 0 10px; }

.totals { padding: 12px 16px 16px; background: #fff8f6; border-top: 1px solid #ead4d4; }
.totals p { display: flex; justify-content: space-between; margin: 4px 0; color: #6b4a4a; }
.totals .pay { font-size: 22px; font-weight: 700; color: #c41e3a; }
.pay-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.pay-actions .btn { height: 48px; font-size: 16px; }

.scan-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  height: 0;
  width: 0;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(26,12,12,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-card {
  width: 420px;
  max-width: 100%;
  background: #fff;
  border-radius: 16px;
  padding: 22px;
  text-align: center;
}
.modal-card img { width: 260px; height: 260px; object-fit: contain; }
.modal-card h2 { margin: 0 0 8px; }
.success-modal { z-index: 30; }
.success-card {
  width: min(640px, calc(100% - 32px));
  min-height: 320px;
  background: #fff;
  border-radius: 24px;
  padding: 48px 36px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,.28);
}
.success-mark {
  width: 96px;
  height: 96px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: #1f9d45;
  color: #fff;
  font-size: 56px;
  line-height: 96px;
  font-weight: 700;
}
.success-card h2 {
  margin: 0;
  font-size: 42px;
  color: #1f9d45;
}
.success-card p {
  margin: 16px 0 0;
  font-size: 36px;
  font-weight: 700;
  color: #c41e3a;
}
.success-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 32px;
}
.success-actions .btn {
  height: 52px;
  font-size: 20px;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #2b1212;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  z-index: 20;
}

.orders {
  position: absolute;
  top: 56px;
  left: 0;
  right: 0;
  bottom: 0;
  background: #f7efe9;
  z-index: 6;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.orders-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #fff;
  border-bottom: 1px solid #ead4d4;
  font-weight: 700;
}
.orders-list { flex: 1; overflow: auto; padding: 12px; }
.order-card {
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  border: 1px solid #ead4d4;
}
.order-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.order-no { font-weight: 700; }
.order-meta { color: #8a6a6a; font-size: 13px; margin-top: 4px; }
.order-items { margin-top: 10px; border-top: 1px dashed #f0e0e0; padding-top: 4px; }
.order-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px 76px 80px;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  font-size: 14px;
  border-bottom: 1px solid #f6ecec;
}
.order-item:last-child { border-bottom: 0; }
.order-item-head {
  color: #8a6a6a;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 0 4px;
  border-bottom: 1px solid #f0e0e0;
}
.order-item-head span:not(:first-child),
.order-item-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.order-item-name {
  min-width: 0;
}
.order-item-name strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.order-item .spec { color: #8a6a6a; font-size: 12px; margin-top: 2px; }
.order-item-sub { font-weight: 600; }
.order-sum {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #ead4d4;
  color: #6b4a4a;
  font-size: 13px;
}
.order-sum strong { color: #c41e3a; font-size: 18px; font-variant-numeric: tabular-nums; }
.orders-more { padding: 8px 14px 16px; text-align: center; }
.orders-empty { text-align: center; color: #8a6a6a; padding: 48px 16px; }

@media (max-width: 900px) {
  .main { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
}
