<template>
  <el-dialog
    :visible.sync="visibleProxy"
    :show-close="false"
    width="1200px"
    :close-on-click-modal="false"
    custom-class="consume-dialog"
    append-to-body
  >
    <div class="consume-dialog-inner">
      <div class="consume-header">
        <div class="consume-title-wrap">
          <div class="consume-title">新建消耗</div>
          <div class="consume-subtitle" v-if="form.memberName">{{ form.memberName }}</div>
        </div>
        <span class="consume-close" @click="handleCancel">
          <i class="el-icon-close"></i>
        </span>
      </div>

      <div class="consume-content">
        <el-form
          ref="form"
          :model="form"
          :rules="rules"
          label-width="96px"
          size="small"
          class="consume-form"
        >
          <!-- ===== 左栏：基础信息 ===== -->
          <div class="consume-left">
            <div class="section-title"><i class="el-icon-document"></i> 基础信息</div>

            <el-form-item label="会员" prop="memberId">
              <el-select v-model="form.memberId" placeholder="搜索会员" filterable clearable @change="onMemberChange">
                <el-option v-for="m in memberOptions" :key="m.value" :label="`${m.label}（${m.phone}）`" :value="m.value" />
              </el-select>
            </el-form-item>

            <el-form-item label="耗卡日期" prop="consumeDate">
              <el-date-picker v-model="form.consumeDate" type="date" placeholder="选择日期" style="width:100%" />
            </el-form-item>

            <el-form-item label="消费金额">
              <el-input :value="totalConsumeAmount" readonly>
                <template slot="prepend">¥</template>
              </el-input>
            </el-form-item>

            <el-form-item label="手工费用">
              <el-input :value="totalLaborCost" readonly>
                <template slot="prepend">¥</template>
              </el-input>
            </el-form-item>

            <el-form-item label="是否加班">
              <el-checkbox v-model="form.isOvertime">加班</el-checkbox>
              <el-select
                v-if="form.isOvertime"
                v-model="form.overtimeCoefficient"
                placeholder="选择加班系数"
                style="width: 140px; margin-left: 12px;"
              >
                <el-option :value="0.5" label="0.5" />
                <el-option :value="1" label="1" />
              </el-select>
            </el-form-item>

            <el-form-item label="备注">
              <el-input v-model="form.remark" type="textarea" :rows="2" placeholder="请输入备注信息" />
            </el-form-item>
          </div>

          <!-- ===== 右栏：品项明细 ===== -->
          <div class="consume-right">
            <div class="section-title"><i class="el-icon-goods"></i> 品项明细</div>

            <div
              v-for="(item, idx) in form.items"
              :key="'item-' + idx"
              class="item-card"
            >
              <div class="item-card-head">
                <span class="item-card-no">品项 {{ idx + 1 }}</span>
                <el-button
                  v-if="form.items.length > 1"
                  type="text"
                  class="item-remove-btn"
                  @click="removeItem(idx)"
                >
                  <i class="el-icon-delete"></i> 删除
                </el-button>
              </div>

              <el-form-item
                label="品项"
                :prop="'items.' + idx + '.projectId'"
                :rules="[{ required: true, message: '请选择品项', trigger: 'change' }]"
                label-width="56px"
              >
                <el-select
                  v-model="item.projectId"
                  placeholder="搜索品项"
                  filterable
                  clearable
                  @change="onProjectChange(idx)"
                >
                  <el-option v-for="p in availableItems" :key="p.value" :label="p.label" :value="p.value" />
                </el-select>
              </el-form-item>

              <!-- 品项信息展示 -->
              <div v-if="item.projectId" class="px-info-panel">
                <el-row :gutter="8">
                  <el-col :span="8"><span class="px-tag">单价</span> <b>¥{{ item.price }}</b></el-col>
                  <el-col :span="8"><span class="px-tag">总购买</span> <b>{{ item.totalPurchased }}</b></el-col>
                  <el-col :span="8"><span class="px-tag">已消费</span> <b>{{ item.consumed }}</b></el-col>
                </el-row>
                <el-row :gutter="8" style="margin-top:4px">
                  <el-col :span="8"><span class="px-tag">剩余</span> <b class="remaining">{{ item.remaining }}</b></el-col>
                  <el-col :span="8"><span class="px-tag">来源</span> <b>{{ item.sourceType || '无' }}</b></el-col>
                  <el-col :span="8"><span class="px-tag">健康师手工费</span> <b>{{ item.healthCoachLaborCost }}</b></el-col>
                </el-row>
                <el-row :gutter="8" style="margin-top:4px" v-if="item.qt2 === '科美'">
                  <el-col :span="8"><span class="px-tag">科美手工费</span> <b>{{ item.techBeautyLaborCost }}</b></el-col>
                </el-row>
              </div>

              <el-row :gutter="12" style="margin-top:8px">
                <el-col :span="12">
                  <el-form-item label="次数" label-width="56px">
                    <el-input-number
                      v-model="item.count"
                      :min="1"
                      :max="item.remaining || 999"
                      controls-position="right"
                      style="width:100%"
                      @change="onCountChange(idx)"
                    />
                  </el-form-item>
                </el-col>
              </el-row>

              <!-- 健康师业绩分配 -->
              <div class="worker-section">
                <div class="worker-label">
                  <span>健康师业绩分配</span>
                  <el-button type="text" size="mini" @click="addWorker(idx)">
                    <i class="el-icon-plus"></i> 添加健康师
                  </el-button>
                </div>
                <div v-for="(w, wi) in item.workers" :key="'w-' + wi" class="worker-row">
                  <el-select v-model="w.workerId" placeholder="选择健康师" filterable size="mini" class="worker-select">
                    <el-option v-for="h in healthWorkerOptions" :key="h.value" :label="h.label" :value="h.value" />
                  </el-select>
                  <el-input :value="w.performance" readonly placeholder="业绩" size="mini" class="worker-field">
                    <template slot="prepend">¥</template>
                  </el-input>
                  <el-input :value="w.laborCost" readonly placeholder="手工费" size="mini" class="worker-field" />
                  <el-input :value="w.count" readonly placeholder="次数" size="mini" class="worker-field-sm" />
                  <el-button
                    v-if="item.workers.length > 1"
                    type="text"
                    size="mini"
                    class="worker-remove"
                    @click="removeWorker(idx, wi)"
                  >
                    <i class="el-icon-close"></i>
                  </el-button>
                </div>
              </div>

              <!-- 科技部老师（仅科美品项显示） -->
              <div class="worker-section" v-if="item.qt2 === '科美'">
                <div class="worker-label">
                  <span>科技部老师</span>
                  <el-button type="text" size="mini" @click="addTechTeacher(idx)">
                    <i class="el-icon-plus"></i> 添加科技部老师
                  </el-button>
                </div>
                <div v-for="(t, ti) in item.techTeachers" :key="'t-' + ti" class="worker-row">
                  <el-select v-model="t.teacherId" placeholder="选择老师" filterable size="mini" class="worker-select">
                    <el-option v-for="tt in techTeacherOptions" :key="tt.value" :label="tt.label" :value="tt.value" />
                  </el-select>
                  <el-input :value="t.performance" readonly placeholder="业绩" size="mini" class="worker-field">
                    <template slot="prepend">¥</template>
                  </el-input>
                  <el-input :value="t.laborCost" readonly placeholder="手工费" size="mini" class="worker-field" />
                  <el-input :value="t.count" readonly placeholder="次数" size="mini" class="worker-field-sm" />
                  <el-button
                    type="text"
                    size="mini"
                    class="worker-remove"
                    @click="removeTechTeacher(idx, ti)"
                  >
                    <i class="el-icon-close"></i>
                  </el-button>
                </div>
              </div>

              <!-- 陪同健康师（仅 isAllowAccompanied == 1 时显示） -->
              <div class="worker-section" v-if="item.isAllowAccompanied == 1">
                <div class="worker-label">
                  <span>陪同健康师</span>
                  <el-button type="text" size="mini" @click="addAccompanied(idx)">
                    <i class="el-icon-plus"></i> 添加陪同健康师
                  </el-button>
                </div>
                <div v-for="(a, ai) in item.accompanied" :key="'a-' + ai" class="worker-row">
                  <el-select v-model="a.workerId" placeholder="选择健康师" filterable size="mini" class="worker-select">
                    <el-option v-for="h in healthWorkerOptions" :key="h.value" :label="h.label" :value="h.value" />
                  </el-select>
                  <el-input-number v-model="a.count" :min="1" controls-position="right" size="mini" style="width:100px" />
                  <el-button
                    type="text"
                    size="mini"
                    class="worker-remove"
                    @click="removeAccompanied(idx, ai)"
                  >
                    <i class="el-icon-close"></i>
                  </el-button>
                </div>
              </div>
            </div>

            <div class="add-btn-row">
              <el-button type="text" @click="addItem">
                <i class="el-icon-circle-plus-outline"></i> 添加品项
              </el-button>
            </div>
          </div>
        </el-form>
      </div>

      <div class="consume-footer">
        <div class="footer-summary">
          <span>消费金额合计 <b class="highlight">¥{{ totalConsumeAmount }}</b></span>
          <span>手工费合计 <b>¥{{ totalLaborCost }}</b></span>
        </div>
        <div class="footer-actions">
          <el-button size="small" @click="handleCancel">取 消</el-button>
          <el-button type="primary" size="small" :loading="submitting" @click="handleSubmit">
            {{ submitting ? '提交中...' : '确认提交' }}
          </el-button>
        </div>
      </div>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: 'ConsumeDialog',
  props: {
    visible: { type: Boolean, default: false },
    prefill: { type: Object, default: () => ({}) }
  },
  data() {
    return {
      submitting: false,
      form: this.createEmptyForm(),
      memberOptions: [
        { value: 'cust001', label: '林小纤', phone: '13800138000' },
        { value: 'cust002', label: '王丽', phone: '13800138001' },
        { value: 'cust003', label: '张敏', phone: '13800138002' }
      ],
      memberItemsMap: {
        'cust001': [
          { value: 'item001', label: '面部深层护理（次卡）', price: 380, remaining: 6, totalPurchased: 10, consumed: 4, sourceType: '购买', qt2: '', healthCoachLaborCost: 50, techBeautyLaborCost: 0, isAllowAccompanied: 0 },
          { value: 'item002', label: '肩颈调理（疗程）', price: 268, remaining: 3, totalPurchased: 5, consumed: 2, sourceType: '购买', qt2: '科美', healthCoachLaborCost: 30, techBeautyLaborCost: 40, isAllowAccompanied: 0 },
          { value: 'item003', label: '眼周护理套餐', price: 198, remaining: 3, totalPurchased: 4, consumed: 1, sourceType: '赠送', qt2: '', healthCoachLaborCost: 25, techBeautyLaborCost: 0, isAllowAccompanied: 1 }
        ],
        'cust002': [
          { value: 'item004', label: '面部深层护理（次卡）', price: 380, remaining: 4, totalPurchased: 8, consumed: 4, sourceType: '购买', qt2: '', healthCoachLaborCost: 50, techBeautyLaborCost: 0, isAllowAccompanied: 0 }
        ],
        'cust003': [
          { value: 'item005', label: '肩颈调理（疗程）', price: 268, remaining: 5, totalPurchased: 5, consumed: 0, sourceType: '购买', qt2: '科美', healthCoachLaborCost: 30, techBeautyLaborCost: 40, isAllowAccompanied: 1 }
        ]
      },
      healthWorkerOptions: [
        { value: 'jks001', label: '张健康师' },
        { value: 'jks002', label: '李健康师' },
        { value: 'jks003', label: '王健康师' }
      ],
      techTeacherOptions: [
        { value: 'kjb001', label: '赵科技老师' },
        { value: 'kjb002', label: '钱科技老师' }
      ],
      availableItems: [],
      rules: {
        memberId: [{ required: true, message: '请选择会员', trigger: 'change' }],
        consumeDate: [{ required: true, message: '请选择耗卡日期', trigger: 'change' }]
      }
    }
  },
  computed: {
    visibleProxy: {
      get() { return this.visible },
      set(val) { this.$emit('update:visible', val) }
    },
    totalConsumeAmount() {
      return this.form.items.reduce((sum, it) => {
        if (it.projectId && it.price) {
          return sum + (it.price * (it.count || 0))
        }
        return sum
      }, 0).toFixed(2)
    },
    totalLaborCost() {
      return this.form.items.reduce((sum, it) => {
        if (!it.projectId) return sum
        const count = it.count || 0
        if (it.qt2 === '科美' && it.beautyType !== 'cell') {
          return sum + (it.techBeautyLaborCost || 0) * count
        } else if (it.qt2 === '科美' && it.beautyType === 'cell') {
          if (it.techTeachers && it.techTeachers.length > 0) {
            return sum + (it.techBeautyLaborCost || 0) * count
          }
          return sum + (it.healthCoachLaborCost || 0) * count
        }
        return sum + (it.healthCoachLaborCost || 0) * count
      }, 0).toFixed(2)
    }
  },
  watch: {
    visible(val) {
      if (val) this.applyPrefill()
    },
    prefill: {
      deep: true,
      handler() {
        if (this.visible) this.applyPrefill()
      }
    }
  },
  methods: {
    createEmptyForm() {
      return {
        memberId: '',
        memberName: '',
        consumeDate: new Date(),
        isOvertime: false,
        overtimeCoefficient: 0.5,
        remark: '',
        items: [this.createEmptyItem()]
      }
    },
    createEmptyItem() {
      return {
        projectId: '',
        price: 0,
        remaining: 0,
        totalPurchased: 0,
        consumed: 0,
        sourceType: '',
        qt2: '',
        beautyType: '',
        healthCoachLaborCost: 0,
        techBeautyLaborCost: 0,
        isAllowAccompanied: 0,
        count: 1,
        workers: [{ workerId: '', performance: '', laborCost: '', count: '' }],
        techTeachers: [],
        accompanied: []
      }
    },
    applyPrefill() {
      this.form = this.createEmptyForm()
      this.availableItems = []
      if (this.prefill && this.prefill.memberId) {
        this.form.memberId = this.prefill.memberId
        this.form.memberName = this.prefill.name || ''
        this.loadMemberItems(this.prefill.memberId)
      }
      if (this.prefill && this.prefill.consumeDate) {
        const d = this.prefill.consumeDate instanceof Date ? this.prefill.consumeDate : new Date(this.prefill.consumeDate)
        if (!Number.isNaN(d.getTime())) this.form.consumeDate = d
      }
      if (this.prefill && this.prefill.remark) {
        this.form.remark = this.prefill.remark
      }
      this.$nextTick(() => {
        // 预填品项（用于“预约消耗单 -> 转消耗”闭环，mock 预填即可）
        const preItems = (this.prefill && Array.isArray(this.prefill.items)) ? this.prefill.items : null
        if (preItems && preItems.length) {
          this.form.items = preItems.map(pi => {
            const it = this.createEmptyItem()
            it.projectId = pi.projectId || ''
            it.count = pi.count || 1
            return it
          })
          // 触发品项信息填充与业绩分配
          this.form.items.forEach((_, idx) => {
            if (this.form.items[idx].projectId) this.onProjectChange(idx)
          })
        }

        // 预填健康师（把 therapistIds 映射到每个品项的 workers）
        const tids = (this.prefill && Array.isArray(this.prefill.therapistIds)) ? this.prefill.therapistIds : null
        if (tids && tids.length) {
          this.form.items.forEach((item, idx) => {
            item.workers = tids.map(tid => ({ workerId: tid, performance: '', laborCost: '', count: '' }))
            this.redistributeWorkers(idx)
          })
        }
        this.$refs.form && this.$refs.form.clearValidate()
      })
    },
    onMemberChange(val) {
      const m = this.memberOptions.find(o => o.value === val)
      this.form.memberName = m ? m.label : ''
      this.form.items = [this.createEmptyItem()]
      this.loadMemberItems(val)
    },
    loadMemberItems(memberId) {
      const items = this.memberItemsMap[memberId] || []
      this.availableItems = items.map(it => ({
        ...it,
        label: `${it.label}（剩余${it.remaining}次）`
      }))
    },
    onProjectChange(idx) {
      const item = this.form.items[idx]
      const p = this.availableItems.find(o => o.value === item.projectId)
      if (p) {
        item.price = p.price
        item.remaining = p.remaining
        item.totalPurchased = p.totalPurchased
        item.consumed = p.consumed
        item.sourceType = p.sourceType
        item.qt2 = p.qt2
        item.healthCoachLaborCost = p.healthCoachLaborCost
        item.techBeautyLaborCost = p.techBeautyLaborCost
        item.isAllowAccompanied = p.isAllowAccompanied
        item.count = 1
        item.workers = [{ workerId: '', performance: '', laborCost: '', count: '' }]
        item.techTeachers = []
        item.accompanied = []
      }
      this.redistributeWorkers(idx)
    },
    onCountChange(idx) {
      this.redistributeWorkers(idx)
      this.redistributeTechTeachers(idx)
    },
    redistributeWorkers(idx) {
      const item = this.form.items[idx]
      if (!item.workers || item.workers.length === 0) return
      const totalCount = item.count || 0
      const totalPerf = item.price * totalCount
      const isKemei = item.qt2 === '科美' && item.beautyType !== 'cell'
      const isCell = item.qt2 === '科美' && item.beautyType === 'cell'
      const hasTech = item.techTeachers && item.techTeachers.length > 0
      const n = item.workers.length
      if (isKemei || (isCell && hasTech)) {
        item.workers.forEach(w => {
          w.performance = (totalPerf / n).toFixed(2)
          w.laborCost = '0.00'
          w.count = '0'
        })
      } else {
        const totalLabor = (item.healthCoachLaborCost || 0) * totalCount
        item.workers.forEach(w => {
          w.performance = (totalPerf / n).toFixed(2)
          w.laborCost = (totalLabor / n).toFixed(2)
          w.count = (totalCount / n).toFixed(2)
        })
      }
    },
    redistributeTechTeachers(idx) {
      const item = this.form.items[idx]
      if (!item.techTeachers || item.techTeachers.length === 0) return
      const totalCount = item.count || 0
      const totalPerf = item.price * totalCount
      const totalLabor = (item.techBeautyLaborCost || 0) * totalCount
      const n = item.techTeachers.length
      item.techTeachers.forEach(t => {
        t.performance = (totalPerf / n).toFixed(2)
        t.laborCost = (totalLabor / n).toFixed(2)
        t.count = (totalCount / n).toFixed(2)
      })
      this.redistributeWorkers(idx)
    },
    addItem() {
      this.form.items.push(this.createEmptyItem())
    },
    removeItem(idx) {
      this.form.items.splice(idx, 1)
    },
    addWorker(idx) {
      this.form.items[idx].workers.push({ workerId: '', performance: '', laborCost: '', count: '' })
      this.redistributeWorkers(idx)
    },
    removeWorker(idx, wi) {
      this.form.items[idx].workers.splice(wi, 1)
      this.redistributeWorkers(idx)
    },
    addTechTeacher(idx) {
      this.form.items[idx].techTeachers.push({ teacherId: '', performance: '', laborCost: '', count: '' })
      this.redistributeTechTeachers(idx)
    },
    removeTechTeacher(idx, ti) {
      this.form.items[idx].techTeachers.splice(ti, 1)
      this.redistributeTechTeachers(idx)
    },
    addAccompanied(idx) {
      this.form.items[idx].accompanied.push({ workerId: '', count: 1 })
    },
    removeAccompanied(idx, ai) {
      this.form.items[idx].accompanied.splice(ai, 1)
    },
    resetForm() {
      this.form = this.createEmptyForm()
      this.availableItems = []
      this.$nextTick(() => {
        this.$refs.form && this.$refs.form.clearValidate()
      })
    },
    handleCancel() {
      this.visibleProxy = false
      this.resetForm()
    },
    handleSubmit() {
      this.$refs.form.validate(valid => {
        if (!valid) return
        this.submitting = true
        setTimeout(() => {
          this.submitting = false
          this.$message.success('消耗记录已保存（示例）')
          this.$emit('submitted', this.form)
          this.visibleProxy = false
          this.resetForm()
        }, 800)
      })
    }
  }
}
</script>

<style lang="scss" scoped>
/* ====== 弹窗外壳 ====== */
::v-deep .consume-dialog {
  max-width: 1200px;
  margin-top: 5vh !important;
  border-radius: 20px;
  padding: 0;
  background: radial-gradient(
    circle at 0 0,
    rgba(255, 255, 255, 0.96) 0,
    rgba(248, 250, 252, 0.98) 40%,
    rgba(241, 245, 249, 0.98) 100%
  );
  box-shadow:
    0 24px 48px rgba(15, 23, 42, 0.18),
    0 0 0 1px rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

::v-deep .consume-dialog .el-dialog__header {
  display: none;
}

::v-deep .consume-dialog .el-dialog__body {
  padding: 0;
}

/* ====== 内部结构 ====== */
.consume-dialog-inner {
  display: flex;
  flex-direction: column;
  max-height: 85vh;
}

.consume-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 22px 0;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(219, 234, 254, 0.96);
}

.consume-title-wrap {
  flex: 1;
}

.consume-title {
  font-size: 17px;
  font-weight: 600;
  color: #0f172a;
}

.consume-subtitle {
  font-size: 12px;
  color: #475569;
  margin-top: 2px;
}

.consume-close {
  flex-shrink: 0;
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: #64748b;
  transition: all 0.15s;

  &:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #0f172a;
  }
}

/* ====== 双栏主体 ====== */
.consume-content {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
}

.consume-form {
  display: flex;
  flex: 1;
  min-height: 0;
}

.consume-left {
  flex: 0 0 440px;
  overflow-y: auto;
  padding: 10px 16px 10px 22px;
  border-right: 1px solid rgba(229, 231, 235, 0.6);
  min-height: 0;
}

.consume-right {
  flex: 1;
  overflow-y: auto;
  padding: 10px 22px 10px 16px;
  min-height: 0;
}

/* ====== 分区标题 ====== */
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  margin: 14px 0 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(241, 245, 249, 0.7);

  i {
    margin-right: 4px;
    color: #2563eb;
  }

  &:first-child {
    margin-top: 4px;
  }
}

/* ====== 品项卡片 ====== */
.item-card {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 10px 12px 4px;
  margin-bottom: 10px;
  background: rgba(255, 255, 255, 0.6);
  transition: border-color 0.15s;

  &:hover {
    border-color: #93c5fd;
  }
}

.item-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.item-card-no {
  font-size: 12px;
  font-weight: 600;
  color: #2563eb;
}

.item-remove-btn {
  color: #ef4444 !important;
  font-size: 12px;
  padding: 0;
}

/* ====== 品项信息面板 ====== */
.px-info-panel {
  margin: 4px 0 6px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(241, 245, 249, 0.5);
  font-size: 12px;
  color: #475569;
  line-height: 1.8;

  .px-tag {
    color: #94a3b8;
    margin-right: 2px;
  }

  b {
    color: #0f172a;
    font-weight: 600;
  }

  .remaining {
    color: #2563eb;
  }
}

/* ====== 健康师 / 科技部老师 / 陪同行 ====== */
.worker-section {
  margin: 2px 0 6px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(241, 245, 249, 0.5);
}

.worker-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 12px;
  color: #475569;
  font-weight: 500;
}

.worker-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.worker-select {
  flex: 1;
}

.worker-field {
  width: 120px;
  flex-shrink: 0;
}

.worker-field-sm {
  width: 70px;
  flex-shrink: 0;
}

.worker-remove {
  color: #ef4444 !important;
  padding: 0;
}

/* ====== 添加按钮行 ====== */
.add-btn-row {
  text-align: center;
  margin-bottom: 6px;
}

/* ====== footer ====== */
.consume-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 22px 14px;
  border-top: 1px solid rgba(229, 231, 235, 0.6);
}

.footer-summary {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: #64748b;

  b {
    color: #0f172a;
  }

  .highlight {
    color: #2563eb;
    font-size: 14px;
  }
}

.footer-actions {
  display: flex;
  gap: 10px;
}

/* ====== 统一输入框 / 按钮风格 ====== */
::v-deep .consume-dialog .el-form-item__label {
  white-space: nowrap;
}

::v-deep .consume-dialog .el-input__inner {
  border-radius: 999px;
  height: 32px;
  line-height: 32px;
  border-color: #e5e7eb;
  background-color: #f9fafb;
}

::v-deep .consume-dialog .el-input__inner:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.18);
}

::v-deep .consume-dialog .el-input-group__prepend {
  border-radius: 999px 0 0 999px;
  background: #f1f5f9;
  border-color: #e5e7eb;
  padding: 0 10px;
  color: #64748b;
}

::v-deep .consume-dialog .el-input-group .el-input__inner {
  border-radius: 0 999px 999px 0;
}

::v-deep .consume-dialog .el-textarea__inner {
  border-radius: 12px;
  border-color: #e5e7eb;
  background-color: #f9fafb;
}

::v-deep .consume-dialog .el-textarea__inner:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.18);
}

::v-deep .consume-dialog .el-input-number {
  .el-input__inner {
    border-radius: 999px;
  }
}

::v-deep .consume-dialog .el-button--primary {
  border-radius: 999px;
  padding: 0 20px;
  height: 30px;
  line-height: 30px;
  background: #2563eb;
  border-color: #2563eb;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35);
  font-size: 12px;
}

::v-deep .consume-dialog .el-button--primary.is-disabled {
  box-shadow: none;
}

::v-deep .consume-dialog .el-button--default {
  border-radius: 999px;
  padding: 0 18px;
  height: 30px;
  line-height: 30px;
  background: rgba(239, 246, 255, 0.9);
  color: #2563eb;
  border-color: rgba(37, 99, 235, 0.18);
  font-size: 12px;
}

::v-deep .consume-dialog .el-button--default:hover {
  background: rgba(219, 234, 254, 0.95);
  color: #1d4ed8;
}

::v-deep .consume-dialog .el-checkbox__input.is-checked .el-checkbox__inner {
  border-color: #2563eb;
  background: #2563eb;
}

::v-deep .consume-dialog .el-checkbox__input.is-checked + .el-checkbox__label {
  color: #2563eb;
}

::v-deep .consume-dialog .el-form-item {
  margin-bottom: 12px;
}

::v-deep .consume-dialog .el-picker-panel {
  border-radius: 12px;
}

::v-deep .consume-dialog .el-select {
  width: 100%;
}
</style>
