* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #1677ff;
  --primary-dark: #0958d9;
  --success: #52c41a;
  --danger: #ff4d4f;
  --bg: #f0f2f5;
  --card-bg: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #666666;
  --text-light: #999999;
  --border: #e8e8e8;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ============ 通用 ============ */
.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-primary:disabled {
  background: #a0c4ff;
  cursor: not-allowed;
}

.btn-outline {
  background: #fff;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-outline:hover {
  background: #f0f5ff;
}

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

/* 主操作大按钮（入库入口） */
.main-btn {
  width: 100%;
  padding: 16px;
  font-size: 18px;
  margin-top: 12px;
}

.input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

.input:focus {
  border-color: var(--primary);
}

/* ============ 首页 ============ */
.home-header {
  text-align: center;
  padding: 40px 20px 30px;
}

.home-header h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
}

.home-header p {
  color: var(--text-secondary);
  font-size: 15px;
}

.demo-badge {
  display: inline-block;
  background: #fff7e6;
  color: #fa8c16;
  border: 1px solid #ffd591;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  margin-top: 12px;
}

.config-badge {
  display: inline-block;
  background: #f6ffed;
  color: #52c41a;
  border: 1px solid #b7eb8f;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  margin-top: 12px;
}

.info-section {
  margin-top: 24px;
}

.info-section h3 {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.info-list {
  list-style: none;
}

.info-list li {
  padding: 8px 0;
  font-size: 14px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

.info-list li:last-child {
  border-bottom: none;
}

.info-list li span {
  color: var(--text);
  font-weight: 500;
}

/* ============ 扫码入库页 ============ */
.scan-header {
  background: var(--primary);
  color: #fff;
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
}

.scan-header .back-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

.scan-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.scan-body {
  padding: 16px;
  padding-bottom: 100px;
}

.order-summary {
  margin-bottom: 16px;
}

.order-summary .main-order {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.order-summary .sub-count {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.operator-row {
  margin-bottom: 16px;
}

.operator-row label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* 入库类型选择 */
.type-section {
  margin-bottom: 16px;
}

.type-section .type-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.type-section .type-label .type-tip {
  font-size: 12px;
  font-weight: 400;
  color: #8c8c8c;
  margin-left: 6px;
}

.type-options {
  display: flex;
  gap: 10px;
}

.type-btn {
  flex: 1;
  padding: 14px 0;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.type-btn:active {
  transform: scale(0.97);
}

.type-btn.active {
  border-color: var(--primary);
  background: #e8f1ff;
  color: var(--primary-dark);
}

/* 子订单卡片 */
.order-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.order-card .order-number-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.order-card .order-number {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

/* 产品类型徽章：中性展示，不代表部门 */
.type-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  background: #6b7280;
}

/* 入库历史信息条：库存累计 + 扫码已入 + 还差 */
.inbound-history {
  background: #e6f7ff;
  border: 1px solid #91d5ff;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: #0958d9;
  margin-bottom: 10px;
}

.inbound-history .ih-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.inbound-history .ih-bottom {
  margin-top: 4px;
  color: #d46b08;
  font-weight: 600;
}

.inbound-history .ih-sep {
  color: #91d5ff;
  font-weight: 700;
}

.inbound-history b {
  font-size: 15px;
}

.inbound-history .remain-done {
  color: #389e0d;
  font-weight: 700;
}

.inbound-history.done {
  background: #f6ffed;
  border-color: #b7eb8f;
}

/* 行级入库类型选择 */
.record-type {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.record-type .rt-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.record-type .rt-label .rt-hint {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: #8c8c8c;
  margin-top: 2px;
}

.record-type .rt-options {
  display: flex;
  gap: 6px;
  flex: 1;
}

.rt-btn {
  flex: 1;
  padding: 7px 0;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.rt-btn:active {
  transform: scale(0.96);
}

.rt-btn.active {
  border-color: var(--primary);
  background: #e8f1ff;
  color: var(--primary-dark);
}

/* 入库类型必选提示 */
.record-type .rt-label .rt-required {
  color: #e5484d;
  font-weight: 600;
}

/* 提交时未选类型的高亮提醒 */
.order-card.type-missing {
  border-color: #e5484d;
  box-shadow: 0 0 0 2px rgba(229, 72, 77, 0.15);
}

.order-card.type-missing .rt-btn {
  border-color: #f1aeb5;
}

/* 操作人未填的高亮提醒 */
.input.input-missing {
  border-color: #e5484d;
  box-shadow: 0 0 0 2px rgba(229, 72, 77, 0.15);
}

.order-card .order-info {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-bottom: 12px;
}

.order-card .order-info-item {
  font-size: 13px;
  display: flex;
  align-items: baseline;
  gap: 4px;
  background: var(--bg);
  padding: 3px 8px;
  border-radius: 6px;
}

.order-card .order-info-item .info-label {
  color: var(--text-secondary);
  font-size: 12px;
  flex-shrink: 0;
}

.order-card .order-info-item .info-value {
  color: var(--text);
  font-weight: 600;
  word-break: break-all;
}

.order-card .qty-section {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.order-card .qty-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.qty-control {
  display: flex;
  align-items: center;
  gap: 0;
  margin-left: auto;
}

.qty-btn {
  width: 44px;
  height: 44px;
  border: 2px solid var(--border);
  background: #fff;
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  user-select: none;
}

.qty-btn:first-child {
  border-radius: 8px 0 0 8px;
}

.qty-btn:last-child {
  border-radius: 0 8px 8px 0;
}

.qty-btn:active {
  background: var(--primary);
  color: #fff;
}

.qty-input {
  width: 70px;
  height: 44px;
  border: 2px solid var(--border);
  border-left: none;
  border-right: none;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  outline: none;
  color: var(--text);
}

.qty-input:focus {
  border-color: var(--primary);
}

/* 底部提交栏 */
.submit-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 100;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
}

.submit-bar .total {
  flex: 1;
}

.submit-bar .total-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.submit-bar .total-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.submit-bar .total-value .unit {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-left: 2px;
}

.submit-bar .btn {
  padding: 14px 32px;
  font-size: 17px;
}

/* ============ 加载 / 状态 ============ */
.loading {
  text-align: center;
  padding: 60px 20px;
}

.loading .spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e8e8e8;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading p {
  color: var(--text-secondary);
  font-size: 15px;
}

.loading .loading-tip {
  font-size: 13px;
  color: var(--text-tertiary, #999);
  margin-top: 8px;
}

.summary-warning {
  background: #fff7e6;
  border: 1px solid #ffd591;
  color: #ad6800;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 16px;
  line-height: 1.6;
}

.error-state {
  text-align: center;
  padding: 60px 20px;
}

.error-state .icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.error-state h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.error-state p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 20px;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 20px;
}

/* ============ 成功页 ============ */
.success-page {
  text-align: center;
  padding: 60px 20px;
}

.success-page .check-icon {
  width: 80px;
  height: 80px;
  background: var(--success);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  font-size: 40px;
  color: #fff;
}

.success-page h2 {
  font-size: 24px;
  margin-bottom: 12px;
}

.success-page .success-stock {
  display: inline-block;
  background: #e6f7ff;
  border: 1px solid #91d5ff;
  border-radius: var(--radius);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  color: #0958d9;
  margin-bottom: 4px;
}

.success-page .success-info {
  background: #f6ffed;
  border: 1px solid #b7eb8f;
  border-radius: var(--radius);
  padding: 16px 24px;
  margin: 20px auto;
  display: inline-block;
}

.success-page .success-info .num {
  font-size: 32px;
  font-weight: 700;
  color: var(--success);
}

.success-page .success-info .label {
  font-size: 14px;
  color: var(--text-secondary);
}

.success-page .actions {
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

/* ============ 手动输入 ============ */
.manual-input {
  padding: 40px 20px;
}

.manual-input h3 {
  font-size: 18px;
  margin-bottom: 16px;
  text-align: center;
}

.manual-input p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 20px;
  text-align: center;
}

.manual-input .input {
  margin-bottom: 16px;
}

/* ============ 打印样式 ============ */
@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
}

/* ============ 出库页（复用扫码页样式，补充少量专属） ============ */
.inbound-history.warn .ih-bottom {
  color: #c03030;
}

.avail-num {
  color: var(--primary, #1a66ff);
  font-size: 15px;
}
