<template>
  <el-dialog
    :visible.sync="visibleProxy"
    :show-close="false"
    :close-on-click-modal="true"
    :close-on-press-escape="true"
    custom-class="member-dialog"
    append-to-body
  >
    <div class="member-dialog-inner">
      <!-- 头部：姓名 + 等级 + 手机 + 门店 + 状态 -->
      <div class="member-header">
        <div class="member-avatar"><span>{{ initials }}</span></div>
        <div class="member-basic">
          <div class="name-line">
            <span class="name">{{ displayName }}</span>
            <span v-if="member.consumeLevelName || member.levelName" class="level-tag">{{ member.consumeLevelName || member.levelName }}</span>
          </div>
          <div class="sub-line">
            <span v-if="member.xb">{{ member.xb }}</span>
            <span v-if="member.sjh"> · {{ member.sjh }}</span>
            <span v-if="member.gsmdName || member.storeName"> · {{ member.gsmdName || member.storeName }}</span>
          </div>
          <div class="status-sub">最后到店：{{ member.lastVisitTime || member.lastVisit || '—' }}</div>
          <div v-if="Array.isArray(member.tags) && member.tags.length" class="tag-row">
            <span v-for="tag in member.tags" :key="tag" class="member-tag">{{ tag }}</span>
          </div>
        </div>
      </div>

      <div class="member-body">
        <div class="row-one">
          <div class="block basic-info">
            <div class="section-title"><i class="el-icon-user section-icon"></i><span>基本信息</span></div>
            <div class="info-grid">
              <div class="info-cell"><span class="l">客户编码</span><span class="v">{{ member.id || '—' }}</span></div>
              <div class="info-cell"><span class="l">档案号</span><span class="v">{{ member.dah || '—' }}</span></div>
              <div class="info-cell"><span class="l">客户名称</span><span class="v">{{ member.khmc || '—' }}</span></div>
              <div class="info-cell"><span class="l">手机号</span><span class="v">{{ member.sjh || '—' }}</span></div>
              <div class="info-cell"><span class="l">性别</span><span class="v">{{ member.xb || '—' }}</span></div>
              <div class="info-cell"><span class="l">归属门店</span><span class="v">{{ member.gsmdName || member.storeName || '—' }}</span></div>
              <div class="info-cell"><span class="l">客户类型</span><span class="v">{{ member.khlxName || '—' }}</span></div>
              <div class="info-cell"><span class="l">注册时间</span><span class="v">{{ member.zcsj || '—' }}</span></div>
              <div class="info-cell"><span class="l">进店渠道</span><span class="v">{{ member.jdqd || '—' }}</span></div>
              <div class="info-cell"><span class="l">推荐人</span><span class="v">{{ member.tjrName || '—' }}</span></div>
              <div class="info-cell"><span class="l">健康师</span><span class="v">{{ member.mainHealthUserName || '—' }}</span></div>
              <div class="info-cell"><span class="l">负责顾问</span><span class="v">{{ member.subHealthUserName || '—' }}</span></div>
              <div class="info-cell"><span class="l">拓客人员</span><span class="v">{{ member.expandUserName || '—' }}</span></div>
              <div class="info-cell"><span class="l">联系地址</span><span class="v">{{ member.lxdz || member.address || '—' }}</span></div>
              <div class="info-cell remark-cell"><span class="l">备注</span><span class="v">{{ member.bz || member.remark || '—' }}</span></div>
            </div>
          </div>
          <div class="block stats-block">
            <div class="section-title"><i class="el-icon-wallet section-icon"></i><span>消费与到店</span></div>
            <div class="stats-mini">
              <div class="s"><span class="sl">耗卡总金额</span><span class="sv">¥{{ formatMoney(member.totalConsumeAmount) }}</span></div>
              <div class="s"><span class="sl">开卡总金额</span><span class="sv">¥{{ formatMoney(member.totalBillingAmount) }}</span></div>
              <div class="s"><span class="sl">剩余权益总金额</span><span class="sv primary">¥{{ formatMoney(member.remainingRightsAmount) }}</span></div>
              <div class="s"><span class="sl">到店天数</span><span class="sv">{{ member.visitDays || 0 }} 天</span></div>
              <div class="s"><span class="sl">沉睡天数</span><span class="sv">{{ member.sleepDays || 0 }} 天</span></div>
              <div class="s"><span class="sl">最后到店</span><span class="sv">{{ member.lastVisitTime || member.lastVisit || '—' }}</span></div>
            </div>
            <div class="section-title section-gap"><i class="el-icon-trophy section-icon"></i><span>等级与生日</span></div>
            <div class="stats-mini">
              <div class="s"><span class="sl">消费等级</span><span class="sv">{{ member.consumeLevelName || member.consumeLevel || '—' }}</span></div>
              <div class="s"><span class="sl">阳历生日</span><span class="sv">{{ member.yanglsr || '—' }}</span></div>
              <div class="s"><span class="sl">阴历生日</span><span class="sv">{{ member.yinlsr || '—' }}</span></div>
              <div class="s"><span class="sl">生美/医美/科技/教育</span><span class="sv">{{ memberTypeSummary }}</span></div>
            </div>
          </div>
        </div>

        <div class="records-area block">
          <div class="records-tabs-header">
            <div class="records-tab-list">
              <div class="records-tab-indicator" :style="recordsTabIndicatorStyle" />
              <button
                v-for="tab in recordTabs"
                :key="tab.key"
                class="records-tab"
                :class="{ 'records-tab--active': recordsTab === tab.key }"
                @click="recordsTab = tab.key"
              >
                <span class="records-tab-label">{{ tab.label }}</span>
              </button>
            </div>
            <div class="records-tabs-search">
              <el-input
                v-model="currentSearch"
                size="mini"
                clearable
                :placeholder="currentSearchPlaceholder"
                class="records-search"
              >
                <i slot="prefix" class="el-icon-search"></i>
              </el-input>
            </div>
          </div>

          <div v-if="recordsTab === 'invite'" class="records-panel">
            <div class="records-table-wrap">
              <el-table :data="filteredInviteRecords" border size="mini" class="record-table" empty-text="暂无邀约记录">
                <el-table-column prop="inviteTime" label="邀约时间" width="150" align="center" />
                <el-table-column prop="inviteContent" label="邀约内容" min-width="140" align="center" />
                <el-table-column prop="inviter" label="邀约人" width="90" align="center" />
                <el-table-column prop="status" label="状态" width="80" align="center" />
              </el-table>
              <div class="records-pagination">
                <el-pagination
                  layout="prev, pager, next"
                  :page-size="pageSize"
                  :total="inviteTotalCount"
                  :current-page.sync="invitePage"
                  small
                  background
                />
              </div>
            </div>
          </div>

          <div v-else-if="recordsTab === 'booking'" class="records-panel">
            <div class="records-table-wrap">
              <el-table :data="filteredBookingRecords" border size="mini" class="record-table" empty-text="暂无预约记录">
                <el-table-column prop="bookingTime" label="预约时间" width="150" align="center" />
                <el-table-column prop="projectName" label="预约项目" min-width="120" align="center" />
                <el-table-column prop="staffName" label="服务人员" width="90" align="center" />
                <el-table-column prop="status" label="状态" width="80" align="center" />
              </el-table>
              <div class="records-pagination">
                <el-pagination
                  layout="prev, pager, next"
                  :page-size="pageSize"
                  :total="bookingTotalCount"
                  :current-page.sync="bookingPage"
                  small
                  background
                />
              </div>
            </div>
          </div>

          <div v-else-if="recordsTab === 'billing'" class="records-panel">
            <div class="records-table-wrap">
              <el-table :data="filteredBillingRecords" border size="mini" class="record-table" empty-text="暂无开单记录">
                <el-table-column prop="orderNo" label="单号" min-width="120" align="center" />
                <el-table-column prop="billingTime" label="开单时间" width="150" align="center" />
                <el-table-column prop="productName" label="项目/产品" min-width="120" align="center" />
                <el-table-column prop="amount" label="金额" width="90" align="center">
                  <template slot-scope="scope">¥{{ formatMoney(scope.row.amount) }}</template>
                </el-table-column>
                <el-table-column prop="operator" label="操作人" width="90" align="center" />
              </el-table>
              <div class="records-pagination">
                <el-pagination
                  layout="prev, pager, next"
                  :page-size="pageSize"
                  :total="billingTotalCount"
                  :current-page.sync="billingPage"
                  small
                  background
                />
              </div>
            </div>
          </div>

          <div v-else-if="recordsTab === 'consume'" class="records-panel">
            <div class="records-table-wrap">
              <el-table :data="filteredConsumeRecords" border size="mini" class="record-table" empty-text="暂无消耗记录">
                <el-table-column prop="consumeTime" label="消耗时间" width="150" align="center" />
                <el-table-column prop="itemName" label="项目名称" min-width="120" align="center" />
                <el-table-column prop="count" label="消耗次数" width="88" align="center" />
                <el-table-column prop="operator" label="操作人" width="90" align="center" />
              </el-table>
              <div class="records-pagination">
                <el-pagination
                  layout="prev, pager, next"
                  :page-size="pageSize"
                  :total="consumeTotalCount"
                  :current-page.sync="consumePage"
                  small
                  background
                />
              </div>
            </div>
          </div>

          <div v-else-if="recordsTab === 'refund'" class="records-panel">
            <div class="records-table-wrap">
              <el-table :data="filteredRefundRecords" border size="mini" class="record-table" empty-text="暂无退卡记录">
                <el-table-column prop="refundTime" label="退卡时间" width="150" align="center" />
                <el-table-column prop="orderNo" label="退卡单号" min-width="130" align="center" />
                <el-table-column prop="projectName" label="退卡项目" min-width="120" align="center" />
                <el-table-column prop="amount" label="退卡金额" width="90" align="center">
                  <template slot-scope="scope">¥{{ formatMoney(scope.row.amount) }}</template>
                </el-table-column>
                <el-table-column prop="operator" label="操作人" width="90" align="center" />
              </el-table>
              <div class="records-pagination">
                <el-pagination
                  layout="prev, pager, next"
                  :page-size="pageSize"
                  :total="refundTotalCount"
                  :current-page.sync="refundPage"
                  small
                  background
                />
              </div>
            </div>
          </div>

          <div v-else-if="recordsTab === 'rights'" class="records-panel">
            <div class="rights-table-wrap">
              <el-table
                :data="filteredRemainingItems"
                border
                size="mini"
                class="rights-table"
                empty-text="暂无权益"
              >
                <el-table-column prop="ItemName" label="项目名称" min-width="110" align="center" />
                <el-table-column prop="ItemPrice" label="单价" width="88" align="center">
                  <template slot-scope="scope">¥{{ formatMoney(scope.row.ItemPrice) }}</template>
                </el-table-column>
                <el-table-column prop="SourceType" label="来源" width="72" align="center" />
                <el-table-column prop="TotalPurchased" label="总购买" width="72" align="center" />
                <el-table-column prop="ConsumedCount" label="已消费" width="72" align="center" />
                <el-table-column prop="RemainingCount" label="剩余" width="72" align="center">
                  <template slot-scope="scope">
                    <span class="num-remaining">{{ scope.row.RemainingCount ?? scope.row.remainingCount ?? 0 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="剩余合计" width="100" align="center">
                  <template slot-scope="scope">
                    <span class="num-total">¥{{ formatMoney(remainingItemTotal(scope.row)) }}</span>
                  </template>
                </el-table-column>
              </el-table>
              <div class="records-pagination">
                <el-pagination
                  layout="prev, pager, next"
                  :page-size="pageSize"
                  :total="rightsTotalCount"
                  :current-page.sync="rightsPage"
                  small
                  background
                />
              </div>
            </div>
          </div>
        </div>
      </div>

      <div class="member-footer">
        <span class="records-op-btn records-op-btn--ghost records-op-btn--invite" @click="emitAction('invite')">去邀约</span>
        <span class="records-op-btn records-op-btn--ghost records-op-btn--booking" @click="emitAction('booking')">去预约</span>
        <span class="records-op-btn records-op-btn--ghost records-op-btn--billing" @click="emitAction('billing')">去开单</span>
        <span class="records-op-btn records-op-btn--ghost records-op-btn--consume" @click="emitAction('consume')">去耗卡</span>
        <span class="records-op-btn records-op-btn--ghost records-op-btn--refund" @click="emitAction('refund')">去退卡</span>
        <span class="records-op-btn records-op-btn--ghost records-op-btn--close" @click="close">关闭</span>
      </div>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: 'MemberProfileDialog',
  props: {
    visible: { type: Boolean, default: false },
    member: { type: Object, default: () => ({}) }
  },
  data() {
    return {
      recordsTab: 'invite',
      searchRights: '',
      searchBilling: '',
      searchConsume: '',
      searchInvite: '',
      searchBooking: '',
      searchRefund: '',
      pageSize: 5,
      rightsPage: 1,
      billingPage: 1,
      consumePage: 1,
      invitePage: 1,
      bookingPage: 1,
      refundPage: 1
    }
  },
  computed: {
    visibleProxy: {
      get() { return this.visible },
      set(val) { this.$emit('update:visible', val) }
    },
    displayName() {
      return this.member.khmc || this.member.name || '会员'
    },
    initials() {
      const n = this.displayName
      return n ? n[0] : '会'
    },
    // 兼容 RemainingItems（PC 接口）与 remainingItems
    remainingItems() {
      const list = this.member.RemainingItems || this.member.remainingItems || []
      return Array.isArray(list) ? list : []
    },
    remainingRightsTotal() {
      const list = this.remainingItems
      return list.reduce((sum, row) => sum + (Number(row.RemainingCount ?? row.remainingCount ?? 0) * Number(row.ItemPrice ?? row.itemPrice ?? 0)), 0)
    },
    memberTypeSummary() {
      const t = []
      if (this.member.isBeautyMember === 1) t.push('生美')
      if (this.member.isMedicalMember === 1) t.push('医美')
      if (this.member.isTechMember === 1) t.push('科技')
      if (this.member.isEducationMember === 1) t.push('教育')
      return t.length ? t.join(' / ') : '—'
    },
    filteredRightsAll() {
      const kw = (this.searchRights || '').trim()
      const list = this.remainingItems
      if (!kw) return list
      return list.filter(row => {
        const name = String(row.ItemName || row.itemName || '')
        return name.includes(kw)
      })
    },
    rightsTotalCount() {
      return this.filteredRightsAll.length
    },
    filteredRemainingItems() {
      const list = this.filteredRightsAll
      const size = this.pageSize
      const maxPage = Math.max(1, Math.ceil((list.length || 1) / size))
      const page = Math.min(this.rightsPage || 1, maxPage)
      const start = (page - 1) * size
      return list.slice(start, start + size)
    },
    billingRecords() {
      const list = this.member.billingRecords || this.member.BillingRecords || []
      return Array.isArray(list) ? list : []
    },
    filteredBillingAll() {
      const kw = (this.searchBilling || '').trim()
      const list = this.billingRecords
      if (!kw) return list
      return list.filter(row => {
        const orderNo = String(row.orderNo || '')
        const product = String(row.productName || '')
        return orderNo.includes(kw) || product.includes(kw)
      })
    },
    billingTotalCount() {
      return this.filteredBillingAll.length
    },
    filteredBillingRecords() {
      const list = this.filteredBillingAll
      const size = this.pageSize
      const maxPage = Math.max(1, Math.ceil((list.length || 1) / size))
      const page = Math.min(this.billingPage || 1, maxPage)
      const start = (page - 1) * size
      return list.slice(start, start + size)
    },
    consumeRecords() {
      const list = this.member.consumeRecords || this.member.ConsumeRecords || []
      return Array.isArray(list) ? list : []
    },
    filteredConsumeAll() {
      const kw = (this.searchConsume || '').trim()
      const list = this.consumeRecords
      if (!kw) return list
      return list.filter(row => {
        const name = String(row.itemName || '')
        return name.includes(kw)
      })
    },
    consumeTotalCount() {
      return this.filteredConsumeAll.length
    },
    filteredConsumeRecords() {
      const list = this.filteredConsumeAll
      const size = this.pageSize
      const maxPage = Math.max(1, Math.ceil((list.length || 1) / size))
      const page = Math.min(this.consumePage || 1, maxPage)
      const start = (page - 1) * size
      return list.slice(start, start + size)
    },
    inviteRecords() {
      const list = this.member.inviteRecords || this.member.InviteRecords || []
      return Array.isArray(list) ? list : []
    },
    filteredInviteAll() {
      const kw = (this.searchInvite || '').trim()
      const list = this.inviteRecords
      if (!kw) return list
      return list.filter(row => {
        const txt = String(row.inviteContent || '')
        const inviter = String(row.inviter || '')
        return txt.includes(kw) || inviter.includes(kw)
      })
    },
    inviteTotalCount() {
      return this.filteredInviteAll.length
    },
    filteredInviteRecords() {
      const list = this.filteredInviteAll
      const size = this.pageSize
      const maxPage = Math.max(1, Math.ceil((list.length || 1) / size))
      const page = Math.min(this.invitePage || 1, maxPage)
      const start = (page - 1) * size
      return list.slice(start, start + size)
    },
    bookingRecords() {
      const list = this.member.bookingRecords || this.member.BookingRecords || []
      return Array.isArray(list) ? list : []
    },
    filteredBookingAll() {
      const kw = (this.searchBooking || '').trim()
      const list = this.bookingRecords
      if (!kw) return list
      return list.filter(row => {
        const project = String(row.projectName || '')
        const staff = String(row.staffName || '')
        return project.includes(kw) || staff.includes(kw)
      })
    },
    bookingTotalCount() {
      return this.filteredBookingAll.length
    },
    filteredBookingRecords() {
      const list = this.filteredBookingAll
      const size = this.pageSize
      const maxPage = Math.max(1, Math.ceil((list.length || 1) / size))
      const page = Math.min(this.bookingPage || 1, maxPage)
      const start = (page - 1) * size
      return list.slice(start, start + size)
    },
    refundRecords() {
      const list = this.member.refundRecords || this.member.RefundRecords || []
      return Array.isArray(list) ? list : []
    },
    filteredRefundAll() {
      const kw = (this.searchRefund || '').trim()
      const list = this.refundRecords
      if (!kw) return list
      return list.filter(row => {
        const orderNo = String(row.orderNo || '')
        const project = String(row.projectName || '')
        return orderNo.includes(kw) || project.includes(kw)
      })
    },
    refundTotalCount() {
      return this.filteredRefundAll.length
    },
    filteredRefundRecords() {
      const list = this.filteredRefundAll
      const size = this.pageSize
      const maxPage = Math.max(1, Math.ceil((list.length || 1) / size))
      const page = Math.min(this.refundPage || 1, maxPage)
      const start = (page - 1) * size
      return list.slice(start, start + size)
    },
    recordTabs() {
      return [
        { key: 'invite', label: '邀约记录' },
        { key: 'booking', label: '预约记录' },
        { key: 'billing', label: '开单记录' },
        { key: 'consume', label: '消耗记录' },
        { key: 'refund', label: '退卡记录' },
        { key: 'rights', label: '剩余权益' }
      ]
    },
    currentSearch: {
      get() {
        switch (this.recordsTab) {
          case 'invite': return this.searchInvite
          case 'booking': return this.searchBooking
          case 'billing': return this.searchBilling
          case 'consume': return this.searchConsume
          case 'refund': return this.searchRefund
          case 'rights': return this.searchRights
          default: return ''
        }
      },
      set(val) {
        switch (this.recordsTab) {
          case 'invite': this.searchInvite = val; break
          case 'booking': this.searchBooking = val; break
          case 'billing': this.searchBilling = val; break
          case 'consume': this.searchConsume = val; break
          case 'refund': this.searchRefund = val; break
          case 'rights': this.searchRights = val; break
        }
      }
    },
    currentSearchPlaceholder() {
      switch (this.recordsTab) {
        case 'invite': return '按内容 / 邀约人搜索'
        case 'booking': return '按项目 / 服务人员搜索'
        case 'billing': return '按单号 / 项目搜索'
        case 'consume': return '按项目名称搜索'
        case 'refund': return '按单号 / 项目搜索'
        case 'rights': return '按项目名称搜索'
        default: return '输入关键字搜索'
      }
    },
    recordsTabIndicatorStyle() {
      const tabs = this.recordTabs
      const count = tabs.length || 1
      const index = Math.max(0, tabs.findIndex(t => t.key === this.recordsTab))
      const width = 100 / count
      return {
        width: `${width}%`,
        // translateX 百分比基于自身宽度，移动一个 tab 宽度用 100% 为一步
        transform: `translateX(${index * 100}%)`
      }
    }
  },
  methods: {
    formatMoney(val) {
      if (val == null || val === '') return '0.00'
      const n = Number(val)
      if (isNaN(n)) return '0.00'
      return n.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ',')
    },
    remainingItemTotal(row) {
      const c = Number(row.RemainingCount ?? row.remainingCount ?? 0)
      const p = Number(row.ItemPrice ?? row.itemPrice ?? 0)
      return c * p
    },
    emitAction(type) {
      this.$emit('action', { type, member: this.member })
    },
    close() {
      this.visibleProxy = false
    }
  }
}
</script>

<style lang="scss" scoped>
.member-dialog-inner {
  padding: 20px 24px 16px;
  display: flex;
  flex-direction: column;
  height: 100%;
  box-sizing: border-box;
}

.member-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.member-body {
  flex: 1;
  overflow-y: auto;
  padding-right: 2px;
  margin-bottom: 14px;
}

.member-avatar {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(145deg, #6366f1, #a855f7);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 500;
  font-size: 20px;
}

.member-basic {
  flex: 1;
  .name-line { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
  .name { font-size: 17px; font-weight: 600; color: #0f172a; }
  .level-tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #fef3c7; color: #c05621; }
  .sub-line { font-size: 12px; color: #64748b; }
  .status-sub { font-size: 11px; color: #94a3b8; margin-top: 2px; }
}

.tag-row {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.member-tag {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(148, 163, 184, 0.16);
  color: #475569;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #111827;
  margin-bottom: 10px;
  .section-icon { font-size: 14px; color: #6366f1; }
  &.section-gap { margin-top: 12px; }
}

/* 第一行：基本信息(左) + 消费到店(右) */
.row-one {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  margin-bottom: 16px;
}

.block {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(248, 250, 252, 0.98));
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  border: 1px solid rgba(226, 232, 240, 0.9);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 24px;
  row-gap: 8px;
}

.info-cell {
  display: flex;
  align-items: center;
  font-size: 12px;
  .l {
    color: #64748b;
    flex: 0 0 72px;
    display: flex;
    align-items: center;
    white-space: nowrap;
  }
  .v { color: #111827; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

.remark-cell {
  grid-column: 1 / -1;
  align-items: flex-start;
}

.remark-cell .v {
  white-space: normal;
}

.stats-mini {
  .s { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 12px; }
  .sl { color: #64748b; }
  .sv { color: #111827; font-weight: 500; }
  .sv.primary { color: #2563eb; }
}

.rights-table-wrap {
  max-height: 260px;
  overflow-y: auto;
}

.rights-block {
  margin-bottom: 0;
}

.rights-table {
  font-size: 12px;
}

.rights-table ::v-deep .el-table th {
  padding: 6px 0;
  font-size: 12px;
  background: #f8fafc;
}

.rights-table ::v-deep .el-table td {
  padding: 5px 0;
}

.num-remaining { font-weight: 600; color: #2563eb; }
.num-total { font-weight: 600; color: #2563eb; }

.records-area {
  margin-top: 4px;
}

.records-tabs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.records-tab-list {
  display: inline-flex;
  flex: 0 1 auto;
  min-width: 0;
  width: 100%;
  max-width: 520px;
  background: rgba(229, 231, 235, 0.82);
  border-radius: 999px;
  padding: 2px;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.records-tab {
  border: none;
  outline: none;
  background: transparent;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 12px;
  color: #4b5563;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
  flex: 1 1 0;
  text-align: center;
  height: 28px;
  line-height: 28px;
  position: relative;
  z-index: 1;
}

.records-tab--active {
  color: #1d4ed8;
  font-weight: 600;
}

.records-tab-indicator {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow:
    0 6px 16px rgba(15, 23, 42, 0.18),
    0 0 0 1px rgba(255,255,255,0.8);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition: transform 0.24s ease;
  z-index: 0;
}

.records-tab-icon {
  font-size: 14px;
  margin-right: 4px;
}

.records-tab-label {
  white-space: nowrap;
}

.member-tag {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(129, 140, 248, 0.12);
  color: #4f46e5;
}

.records-toolbar {
  position: absolute;
  top: 2px;
  right: 10px;
  display: flex;
  align-items: center;
  margin-bottom: 0;
}

.records-title {
  font-size: 12px;
  color: #111827;
}

.records-search {
  width: 220px;
}

.records-search ::v-deep .el-input__inner {
  border-radius: 999px;
  height: 28px;
  line-height: 28px;
}

.records-search ::v-deep .el-input__prefix {
  display: flex;
  align-items: center;
  height: 100%;
}

.records-table-wrap {
  max-height: 260px;
  overflow-y: auto;
}

.records-pagination {
  margin-top: 6px;
  text-align: right;
}

.records-op-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  height: 30px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: color 0.2s ease, box-shadow 0.2s ease, transform 0.12s ease;
}

.records-op-btn--ghost {
  background: rgba(239, 246, 255, 0.9);
  color: #2563eb;
  border: 1px solid rgba(37, 99, 235, 0.18);
}

.records-op-btn:hover {
  transform: translateY(-0.5px);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12);
}
.records-op-btn--ghost:hover {
  color: #ffffff;
}

.records-op-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-size: 200% 100%;
  background-position: 0% 0;
  opacity: 0.9;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  z-index: -1;
}

.records-op-btn:hover::before {
  transform: translateX(0);
}

.records-op-btn--invite::before {
  background-image: linear-gradient(135deg, #0ea5e9, #22c55e);
}

.records-op-btn--booking::before {
  background-image: linear-gradient(135deg, #f97316, #facc15);
}

.records-op-btn--billing::before {
  background-image: linear-gradient(135deg, #3b82f6, #2563eb);
}

.records-op-btn--consume::before {
  background-image: linear-gradient(135deg, #22c55e, #16a34a);
}

.records-op-btn--refund::before {
  background-image: linear-gradient(135deg, #f97316, #ef4444);
}

.records-op-btn--close::before {
  background-image: linear-gradient(135deg, #e5e7eb, #cbd5f5);
}
.record-table { font-size: 12px; }
.record-table ::v-deep .el-table th {
  padding: 6px 0;
  font-size: 12px;
  background: #f8fafc;
}
.record-table ::v-deep .el-table td {
  padding: 5px 0;
}

.member-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

::v-deep .el-dialog {
  width: 1040px;
  max-width: 96vw;
  max-height: 86vh;
  margin-top: 5vh !important;
  border-radius: 24px;
  padding: 0;
  background: radial-gradient(circle at top left, rgba(255,255,255,0.96) 0, rgba(248,250,252,0.98) 38%, rgba(241,245,249,0.98) 100%);
  box-shadow:
    0 32px 60px rgba(15, 23, 42, 0.22),
    0 0 0 0.5px rgba(148, 163, 184, 0.35);
  border: 1px solid rgba(226, 232, 240, 0.9);
  backdrop-filter: blur(26px);
  -webkit-backdrop-filter: blur(26px);
  display: flex;
  flex-direction: column;
}

::v-deep .el-dialog__header { display: none; }
::v-deep .el-dialog__body {
  padding: 0;
  flex: 1;
  overflow: hidden;
}

@media (max-width: 768px) {
  .row-one { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: repeat(2, 1fr); }
}
</style>
