/* ========== 通用基础样式 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", sans-serif;
  font-size: 14px; color: #333; background: #f0f2f5;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit; font-size: 14px; padding: 8px 10px;
  border: 1px solid #d9d9d9; border-radius: 6px; outline: none; background: #fff;
  transition: border-color .2s;
}
input:focus, select:focus, textarea:focus { border-color: #1677ff; }
textarea { resize: vertical; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border: 1px solid #d9d9d9; border-radius: 6px;
  background: #fff; color: #333; font-size: 14px; line-height: 1.4;
  transition: all .2s;
}
.btn:hover { border-color: #1677ff; color: #1677ff; }
.btn-primary { background: #1677ff; border-color: #1677ff; color: #fff; }
.btn-primary:hover { background: #4096ff; border-color: #4096ff; color: #fff; }
.btn-danger { color: #ff4d4f; }
.btn-danger:hover { border-color: #ff4d4f; color: #ff4d4f; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; padding: 10px; font-size: 15px; }

/* 标签 */
.tag {
  display: inline-block; padding: 2px 10px; border-radius: 10px;
  font-size: 12px; line-height: 20px; white-space: nowrap;
}
.tag-blue   { background: #e6f4ff; color: #1677ff; }
.tag-orange { background: #fff7e6; color: #fa8c16; }
.tag-cyan   { background: #e6fffb; color: #13c2c2; }
.tag-green  { background: #f6ffed; color: #52c41a; }
.tag-red    { background: #fff2f0; color: #ff4d4f; }
.tag-gray   { background: #f5f5f5; color: #8c8c8c; }
.tag-purple { background: #f9f0ff; color: #722ed1; }

/* 表格 */
.table-wrap { background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
table.tb { width: 100%; border-collapse: collapse; }
.tb th {
  background: #fafafa; color: #555; font-weight: 600; text-align: left;
  padding: 12px 14px; border-bottom: 1px solid #f0f0f0; white-space: nowrap;
}
.tb td { padding: 12px 14px; border-bottom: 1px solid #f5f5f5; vertical-align: middle; }
.tb tbody tr:hover { background: #f8fbff; }
.tb tbody tr:last-child td { border-bottom: none; }
.tb .num { text-align: right; font-variant-numeric: tabular-nums; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100;
  display: none; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 40px 16px;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 12px; width: 560px; max-width: 100%;
  box-shadow: 0 8px 30px rgba(0,0,0,.18); animation: modalIn .18s ease;
}
@keyframes modalIn { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid #f0f0f0;
}
.modal-head h3 { font-size: 16px; }
.modal-close { background: none; border: none; font-size: 20px; color: #999; line-height: 1; }
.modal-close:hover { color: #333; }
.modal-body { padding: 20px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid #f0f0f0;
}

/* 表单 */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-item { display: flex; flex-direction: column; gap: 6px; }
.form-item.full { grid-column: 1 / -1; }
.form-item label { font-size: 13px; color: #666; }
.form-item label .req { color: #ff4d4f; margin-right: 2px; }
.form-item input, .form-item select, .form-item textarea { width: 100%; }

/* 材料选择弹窗 */
.mat-picker {
  max-height: 320px; overflow-y: auto; border: 1px solid #e8e8e8; border-radius: 6px;
  background: #fafafa;
}
.mat-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-bottom: 1px solid #f0f0f0; background: #fff;
}
.mat-row:last-child { border-bottom: none; }
.mat-row > input[type="checkbox"] { width: 16px; height: 16px; flex-shrink: 0; accent-color: #1677ff; }
.mat-row .mat-name { flex: 1; min-width: 0; font-size: 14px; }
.mat-row .mat-name em { display: block; font-style: normal; color: #999; font-size: 12px; }
.mat-row input[type="number"] { width: 84px; padding: 6px 8px; font-size: 13px; flex-shrink: 0; }
.mat-row .mat-amount {
  width: 96px; text-align: right; font-size: 13px; color: #333;
  font-variant-numeric: tabular-nums; flex-shrink: 0;
}
.mat-row.mat-head { background: #fafafa; color: #888; font-size: 12px; padding: 7px 12px; }
.mat-row.mat-head .mat-check { width: 16px; flex-shrink: 0; }
.mat-row.mat-head .mat-name { font-size: 12px; }
.mat-row.mat-head .mat-qty-h { width: 84px; flex-shrink: 0; }
.mat-row.mat-head .mat-price-h { width: 84px; flex-shrink: 0; }
.mat-total { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 10px; font-size: 14px; }
.mat-total b { color: #ff4d4f; font-size: 17px; }
.mat-picker .mat-empty { color: #aaa; font-size: 13px; padding: 14px; }

/* 已选材料表格 */
.mat-sel-table { margin-top: 6px; box-shadow: none; border: 1px solid #f0f0f0; }
.mat-sel-table th, .mat-sel-table td { padding: 6px 10px; font-size: 12px; }

/* 弹窗内快速添加材料 */
.mat-quickadd { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.mat-quickadd input { width: auto; }

/* 客户充值 */
.rc-info { background: #fff7e6; border-radius: 6px; padding: 10px 12px; margin-bottom: 14px; font-size: 13px; }
.rc-info .rc-money { color: #fa8c16; font-size: 15px; }
.rc-records { margin-top: 14px; border-top: 1px dashed #eee; padding-top: 10px; max-height: 170px; overflow-y: auto; }
.rc-records .rc-title { font-size: 12px; color: #999; margin-bottom: 6px; }
.rc-records .rc-row {
  display: flex; justify-content: space-between; gap: 8px; font-size: 12px;
  color: #666; padding: 4px 0; border-bottom: 1px solid #f8f8f8;
}
.rc-records .rc-row span:first-child { color: #52c41a; font-weight: 600; white-space: nowrap; }
.rc-records .rc-row span:first-child.neg { color: #ff4d4f; }
.rc-records .rc-row span:last-child { color: #aaa; white-space: nowrap; }

/* 空数据 */
.empty { padding: 48px 0; text-align: center; color: #999; }
.empty svg { opacity: .35; margin-bottom: 8px; }

/* Toast 提示 */
.toast {
  position: fixed; left: 50%; top: 60px; transform: translateX(-50%);
  background: rgba(0,0,0,.78); color: #fff; padding: 10px 22px;
  border-radius: 8px; font-size: 14px; z-index: 999; display: none;
}
.toast.show { display: block; animation: modalIn .2s ease; }
