/* -------------------------------
   全局基础样式
--------------------------------*/
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}
body {
  background: #e8edf3;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #222;
}
.app-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* -------------------------------
   顶栏导航
--------------------------------*/
.topbar {
  background: #1f2933;
  color: #fff;
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 56px;
}
.top-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.top-left h1 {
  font-size: 18px;
  margin: 0;
}
.store-indicator {
  background: rgba(255,255,255,0.1);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 13px;
}
.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.nav-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
.nav-btn:hover {
  background: rgba(255,255,255,0.3);
}
.nav-link {
  color: #fff;
  text-decoration: none;
  background: rgba(255,255,255,0.15);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 13px;
}
.nav-link:hover {
  background: rgba(255,255,255,0.3);
}

/* -------------------------------
   三栏布局
--------------------------------*/
.pos-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 300px 1fr 240px;
  gap: 12px;
  padding: 12px;
  min-height: 0;
}
section {
  background: #fff;
  border: 1px solid #d1d9e6;
  border-radius: 6px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* -------------------------------
   左栏：扫码 + 小票
--------------------------------*/
.scanner-box {
  border: 1px solid #e0e6ef;
  border-radius: 4px;
  padding: 6px;
  margin-bottom: 10px;
  height: 280px;
  display: flex;
  flex-direction: column;
}
.scanner-box h2 {
  margin: 0 0 4px;
  font-size: 15px;
}
.camera-select { margin-bottom: 4px; }
.camera-select select {
  width: 100%;
  padding: 3px 5px;
}
.scanner-box video {
  width: 100%;
  flex: 1;
  background: #000;
  border-radius: 4px;
  object-fit: cover;
}
.scan-status {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.3;
}
.lastcode {
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.3;
}

.receipt-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.receipt-box h2 { margin-top: 0; }
.receipt-list {
  background: #f5f7fa;
  border: 1px solid #d1d9e6;
  border-radius: 4px;
  flex: 1;
  overflow-y: auto;
}
.receipt-item {
  display: flex;
  justify-content: space-between;
  padding: 4px 6px;
  border-bottom: 1px solid #e0e4eb;
  font-size: 13px;
}
.receipt-empty {
  text-align: center;
  padding: 16px 0;
  color: #999;
}
.receipt-total {
  text-align: right;
  margin-top: 6px;
  font-weight: bold;
}

/* -------------------------------
   中栏：收银表格
--------------------------------*/
.main-pos h2 {
  font-size: 15px;
  margin: 0 0 6px;
}
.manual-add {
  margin-bottom: 6px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.manual-add select {
  flex: 1;
  padding: 3px 5px;
}
.manual-add button {
  padding: 4px 8px;
}

.cart-table-wrap {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.cart-table {
  width: 100%;
  border-collapse: collapse;
}
.cart-table th,
.cart-table td {
  border: 1px solid #e1e4eb;
  padding: 4px;
  text-align: center;
  font-size: 13px;
}
.td-name { text-align: left; }
.td-code { font-size: 10px; color: #777; }
.empty-row { color: #999; text-align: center; }

/* 小按钮 */
button.small {
  padding: 2px 6px;
  font-size: 11px;
  border-radius: 4px;
  border: none;
  background: #ccc;
  cursor: pointer;
}
button.small:hover {
  background: #bbb;
}
button.danger {
  background: #e11d48;
  color: #fff;
}
button.danger:hover {
  background: #be123c;
}

/* -------------------------------
   右栏：商品方块 + 支付
--------------------------------*/
.pay-panel {
  display: flex;
  flex-direction: column;
}
.pay-scanned-panel {
  background: #1d4ed8;
  color: #fff;
  border-radius: 4px;
  padding: 8px;
  margin-bottom: 10px;
}
.pay-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.pay-line.small { font-size: 12px; }

.pay-manual-box {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  padding: 8px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pay-manual-box h4 {
  margin: 0;
  font-size: 13px;
}
.item-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 210px;
  overflow-y: auto;
}
.item-tile {
  flex: 0 0 calc(50% - 3px);
  background: #dbeafe;
  border: 1px solid #94b5f5;
  border-radius: 4px;
  padding: 6px 4px;
  text-align: center;
  min-height: 56px;
  cursor: pointer;
}
.item-tile:hover { background: #bfdbfe; }
.item-name { font-size: 12px; line-height: 1.3; }
.item-price { margin-top: 4px; font-weight: 600; font-size: 12px; }

.pay-actions-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pay-due-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #e0ebff;
  border-radius: 4px;
  padding: 5px 8px;
}
.pay-due-row strong {
  font-size: 16px;
  color: #1d4ed8;
}
.pay-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.pay-btn {
  padding: 10px 4px;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  color: #fff;
  cursor: pointer;
}
.pay-btn.cash { background: #059669; }
.pay-btn.debit { background: #2563eb; }
.pay-btn.credit { background: #7c3aed; }
.pay-btn.other { background: #f97316; }
.pay-btn.wx { background: #10b981; }
.pay-btn.cancel {
  background: #ef4444;
  grid-column: span 2;
}
.pay-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 搜索框 */
.quick-search-input {
  padding: 4px 6px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 12px;
  background: #fff;
}

/* 状态文本 */
.status-ok { color: #059669; }
.status-bad { color: #c00; }

/* -------------------------------
   弹窗通用
--------------------------------*/
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
}
.modal {
  background: #fff;
  border-radius: 6px;
  padding: 16px;
  width: 360px;
  max-width: 90%;
}
.modal-footer {
  text-align: right;
  margin-top: 10px;
}

/* POS 模拟终端 */
.pos-terminal {
  background: #fff;
  border-radius: 10px;
  width: 320px;
  overflow: hidden;
  box-shadow: 0 0 12px rgba(0,0,0,.25);
}
.pos-terminal-head {
  background: #006341;
  color: #fff;
  padding: 8px;
  text-align: center;
  font-weight: bold;
}
.pos-terminal-body { padding: 12px; text-align: center; }
.pos-terminal-screen {
  background: #e1f5ec;
  border: 1px solid #b6ded0;
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 12px;
}
.pos-terminal-sub { font-size: 12px; margin-top: 6px; }
.pos-terminal-tap {
  background: linear-gradient(145deg,#00a35a,#006341);
  color: #fff;
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform .1s ease;
}
.pos-terminal-tap:hover { transform: scale(1.02); }

/* 微信/支付宝弹窗 */
.wxali-modal {
  background: #fff;
  border-radius: 6px;
  padding: 16px;
  width: 360px;
  max-width: 90%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wxali-modal video {
  width: 100%;
  height: 220px;
  background: #000;
  border-radius: 4px;
  object-fit: cover;
}

/* -------------------------------
   商品库页
--------------------------------*/
.db {
  background: #fff;
  border: 1px solid #d1d9e6;
  border-radius: 6px;
  padding: 10px;
  max-width: 700px;
  margin: 0 auto;
}
.db h3 { margin-top: 0; }
.form-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
  align-items: center;
}
.form-row label {
  width: 48px;
}
.form-row input {
  flex: 1;
  padding: 4px 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
}
.form-row input:disabled {
  background: #f3f3f3;
}
.db button {
  padding: 5px 10px;
  border: none;
  background: #2563eb;
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
}
.db button:hover { background: #1e40af; }
.product-list {
  list-style: none;
  padding-left: 0;
  max-height: 300px;
  overflow-y: auto;
  margin-top: 6px;
}
.prod-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid #eee;
  padding: 4px 0;
}

/* 小屏 */
@media (max-width: 1100px) {
  .pos-layout {
    grid-template-columns: 1fr;
  }
  .pay-panel {
    order: 3;
  }
}
