<!-- 财务看板页 — 忠于 H5 原型结构 -->

<!-- 加载态（toast 浮层，不白屏） -->
<view class="g-toast-loading" wx:if="{{pageState === 'loading'}}">
  <view class="g-toast-loading-inner">
    <t-loading theme="circular" size="40rpx" />
    <text class="g-toast-loading-text">加载中...</text>
  </view>
</view>

<!-- 空状态 -->
<view class="page-empty" wx:elif="{{pageState === 'empty'}}">
  <t-empty description="暂无财务数据" />
</view>

<!-- 错误态 -->
<view class="page-error" wx:elif="{{pageState === 'error'}}">
  <t-empty description="加载失败" />
  <view class="retry-btn" bindtap="onRetry">
    <text class="retry-btn-text">点击重试</text>
  </view>
</view>

<!-- 正常态 -->
<block wx:else>
  <!-- 顶部看板 Tab 导航 -->
  <view class="board-tabs">
    <view class="board-tab board-tab--active" data-tab="finance">
      <text>财务</text>
    </view>
    <view class="board-tab" data-tab="customer" bindtap="onTabChange">
      <text>客户</text>
    </view>
    <view class="board-tab" data-tab="coach" bindtap="onTabChange">
      <text>助教</text>
    </view>
  </view>

  <!-- 筛选区域 -->
  <!-- CHANGE 2026-03-13 | intent: H5 原型筛选按钮与吸顶板块头共存于同一容器，通过 opacity/scaleX 动画切换；目录按钮始终可见，只有筛选按钮和环比开关淡出 -->
  <view class="filter-bar">
    <view class="filter-bar-inner">
      <!-- 目录按钮（始终可见，不受吸顶头影响） -->
      <view class="toc-btn" bindtap="toggleToc">
        <t-icon name="view-list" size="40rpx" color="#ffffff" />
      </view>

      <!-- 时间筛选（吸顶头显示时淡出） -->
      <view class="filter-item {{stickyHeaderVisible ? 'filter-item--hidden' : ''}}">
        <filter-dropdown
          label="本月"
          options="{{timeOptions}}"
          value="{{selectedTime}}"
          bind:change="onTimeChange"
        />
      </view>

      <!-- 区域筛选（吸顶头显示时淡出） -->
      <view class="filter-item {{stickyHeaderVisible ? 'filter-item--hidden' : ''}}">
        <filter-dropdown
          label="全部区域"
          options="{{areaOptions}}"
          value="{{selectedArea}}"
          bind:change="onAreaChange"
        />
      </view>

      <!-- 环比开关（始终可见，不受吸顶头影响） -->
      <view class="compare-switch" bindtap="toggleCompare">
        <text class="compare-label">环比</text>
        <view class="compare-toggle {{compareEnabled ? 'compare-toggle--active' : ''}}">
          <view class="compare-toggle-dot"></view>
        </view>
      </view>
    </view>

    <!-- 吸顶板块头（滚动到非首屏时从左滑入，覆盖在筛选按钮上方） -->
    <view class="sticky-section-header {{stickyHeaderVisible ? 'sticky-section-header--show' : ''}}">
      <text class="sticky-header-emoji">{{stickyHeaderEmoji}}</text>
      <view class="sticky-header-content">
        <text class="sticky-header-title">{{stickyHeaderTitle}}</text>
        <text class="sticky-header-desc">{{stickyHeaderDesc}}</text>
      </view>
      <view class="sticky-header-tags">
        <text class="sticky-header-tag" wx:if="{{selectedTimeText !== '本月'}}">{{selectedTimeText}}</text>
        <text class="sticky-header-tag" wx:if="{{selectedAreaText !== '全部区域'}}">{{selectedAreaText}}</text>
      </view>
    </view>
  </view>

  <!-- 内容区（页面自然滚动） -->
  <view class="board-content">

    <!-- ===== 板块 1: 经营一览（深色） ===== -->
    <view id="section-overview" class="card-section section-dark">
      <view class="card-header-dark">
        <text class="card-header-emoji">📈</text>
        <view class="card-header-text">
          <text class="card-header-title-dark">经营一览</text>
          <text class="card-header-desc-dark">快速了解收入与现金流的整体健康度</text>
        </view>
      </view>

      <!-- 收入概览 -->
      <view class="sub-section-label">
        <text class="sub-label-text">收入概览</text>
        <text class="sub-label-desc">记账口径收入与优惠</text>
      </view>

      <view class="overview-grid-3">
        <view class="overview-cell">
          <view class="cell-label-row">
            <text class="cell-label-light">发生额/正价</text>
            <view class="help-icon-light" data-key="occurrence" bindtap="onHelpTap">?</view>
          </view>
          <text class="cell-value-white">{{overview.occurrence}}</text>
          <view class="compare-row" wx:if="{{compareEnabled}}">
            <text class="compare-text-up">↑{{overview.occurrenceCompare}}</text>
          </view>
        </view>
        <view class="overview-cell">
          <view class="cell-label-row">
            <text class="cell-label-light">总优惠</text>
            <view class="help-icon-light" data-key="discount" bindtap="onHelpTap">?</view>
          </view>
          <text class="cell-value-red">{{overview.discount}}</text>
          <view class="compare-row" wx:if="{{compareEnabled}}">
            <text class="compare-text-down">↓{{overview.discountCompare}}</text>
          </view>
        </view>
        <view class="overview-cell">
          <view class="cell-label-row">
            <text class="cell-label-light">优惠占比</text>
          </view>
          <text class="cell-value-gray">{{overview.discountRate}}</text>
          <view class="compare-row" wx:if="{{compareEnabled}}">
            <text class="compare-text-down">↓{{overview.discountRateCompare}}</text>
          </view>
        </view>
      </view>

      <!-- 成交/确认收入 -->
      <view class="confirmed-row">
        <view class="confirmed-left">
          <text class="confirmed-label">成交/确认收入</text>
          <view class="help-icon-light" data-key="confirmed" bindtap="onHelpTap">?</view>
        </view>
        <view class="confirmed-right">
          <text class="confirmed-value">{{overview.confirmedRevenue}}</text>
          <view class="compare-row-inline" wx:if="{{compareEnabled}}">
            <text class="compare-text-up">↑{{overview.confirmedCompare}}</text>
          </view>
        </view>
      </view>

      <view class="section-divider-light"></view>

      <!-- 现金流水概览 -->
      <view class="sub-section-label">
        <text class="sub-label-text">现金流水概览</text>
        <text class="sub-label-desc">往期为已结算 本期为截至当前的发生额</text>
      </view>

      <view class="overview-grid-2">
        <view class="overview-cell-bg">
          <view class="cell-label-row">
            <text class="cell-label-light">实收/现金流入</text>
            <view class="help-icon-light" data-key="cashIn" bindtap="onHelpTap">?</view>
          </view>
          <text class="cell-value-white-sm">{{overview.cashIn}}</text>
          <view class="compare-row" wx:if="{{compareEnabled}}">
            <text class="compare-text-up">↑{{overview.cashInCompare}}</text>
          </view>
        </view>
        <view class="overview-cell-bg">
          <view class="cell-label-row">
            <text class="cell-label-light">现金支出</text>
            <view class="help-icon-light" data-key="cashOut" bindtap="onHelpTap">?</view>
          </view>
          <text class="cell-value-gray-sm">{{overview.cashOut}}</text>
          <view class="compare-row" wx:if="{{compareEnabled}}">
            <text class="compare-text-up">↑{{overview.cashOutCompare}}</text>
          </view>
        </view>
        <view class="overview-cell-bg">
          <view class="cell-label-row">
            <text class="cell-label-light">现金结余</text>
            <view class="help-icon-light" data-key="balance" bindtap="onHelpTap">?</view>
          </view>
          <text class="cell-value-white-sm">{{overview.cashBalance}}</text>
          <view class="compare-row" wx:if="{{compareEnabled}}">
            <text class="compare-text-up">↑{{overview.cashBalanceCompare}}</text>
          </view>
        </view>
        <view class="overview-cell-bg">
          <view class="cell-label-row">
            <text class="cell-label-light">结余率</text>
          </view>
          <text class="cell-value-white-sm">{{overview.balanceRate}}</text>
          <view class="compare-row" wx:if="{{compareEnabled}}">
            <text class="compare-text-up">↑{{overview.balanceRateCompare}}</text>
          </view>
        </view>
      </view>

      <!-- AI 洞察 -->
      <!-- CHANGE 2026-03-12 | intent: H5 原型使用 SVG 机器人图标，不可用 emoji 替代；规范要求内联 SVG 导出为文件用 image 引用 -->
      <view class="ai-insight-section">
        <view class="ai-insight-header">
          <view class="ai-insight-icon">
            <image src="/assets/icons/ai-robot.svg" mode="aspectFit" class="ai-insight-icon-img" />
          </view>
          <text class="ai-insight-title">AI 智能洞察</text>
        </view>
        <view class="ai-insight-body">
          <text class="ai-insight-line"><text class="ai-insight-dim">优惠率Top：</text>团购(5.2%) / 大客户(3.1%) / 赠送卡(2.5%)</text>
          <text class="ai-insight-line"><text class="ai-insight-dim">差异最大：</text>酒水(+18%) / 台桌(-5%) / 包厢(+12%)</text>
          <!-- CHANGE 2026-03-12 | intent: H5 原型第三行"充值高但消耗低"有 underline 样式 -->
          <text class="ai-insight-line"><text class="ai-insight-dim">建议关注：</text><text class="ai-insight-underline">充值高但消耗低</text>，会员活跃度需提升</text>
        </view>
      </view>
    </view>

    <!-- ===== 板块 2: 预收资产（仅"全部区域"时显示） ===== -->
    <view id="section-recharge" class="card-section" wx:if="{{selectedArea === 'all'}}">
      <view class="card-header-light">
        <text class="card-header-emoji">💳</text>
        <view class="card-header-text">
          <text class="card-header-title-light">预收资产</text>
          <text class="card-header-desc-light">会员卡充值与余额 掌握资金沉淀 辅助会员运营策略定制</text>
        </view>
      </view>

      <!-- 储值卡统计 -->
      <view class="section-body">
      <!-- 全类别会员卡余额合计 -->
        <!-- CHANGE 2026-03-13 | intent: H5 中 label 和 help-icon 在同一行（flex items-center mb-1），MP 需要用 view 包裹实现同行布局 -->
        <view class="total-balance-row">
          <view class="total-balance-left">
            <view class="total-balance-label">
              <text>全类别会员卡余额合计</text>
              <view class="help-icon-dark" data-key="allCardBalance" bindtap="onHelpTap">?</view>
            </view>
            <text class="total-balance-note">仅经营参考，非财务属性</text>
          </view>
          <view class="total-balance-right">
            <text class="total-balance-value">{{recharge.allCardBalance}}</text>
            <view class="compare-row-inline" wx:if="{{compareEnabled}}">
              <text class="compare-text-up-sm">↑{{recharge.allCardBalanceCompare}}</text>
            </view>
          </view>
        </view>
        <text class="card-section-title">储值卡统计</text>
        <view class="table-bordered">
          <!-- 行1：储值卡充值实收 -->
          <view class="table-row table-row--highlight">
            <view class="table-row-left">
              <text class="table-row-label-bold">储值卡充值实收</text>
              <view class="help-icon-dark" data-key="rechargeActual" bindtap="onHelpTap">?</view>
            </view>
            <view class="table-row-right">
              <text class="table-row-value-lg">{{recharge.actualIncome}}</text>
              <view class="compare-row-inline" wx:if="{{compareEnabled}}">
                <text class="compare-text-up-sm">↑{{recharge.actualCompare}}</text>
              </view>
            </view>
          </view>
          <!-- 行2：首充/续费/消耗 三列 -->
          <view class="table-row-grid3">
            <view class="grid-cell">
              <view class="cell-label-row-sm">
                <text class="cell-label-sm">首充</text>
                <view class="help-icon-dark-sm" data-key="firstCharge" bindtap="onHelpTap">?</view>
              </view>
              <text class="cell-value-sm">{{recharge.firstCharge}}</text>
              <view class="compare-row" wx:if="{{compareEnabled}}">
                <text class="compare-text-up-xs">↑{{recharge.firstChargeCompare}}</text>
              </view>
            </view>
            <view class="grid-cell">
              <view class="cell-label-row-sm">
                <text class="cell-label-sm">续费</text>
                <view class="help-icon-dark-sm" data-key="renewCharge" bindtap="onHelpTap">?</view>
              </view>
              <text class="cell-value-sm">{{recharge.renewCharge}}</text>
              <view class="compare-row" wx:if="{{compareEnabled}}">
                <text class="compare-text-up-xs">↑{{recharge.renewChargeCompare}}</text>
              </view>
            </view>
            <view class="grid-cell">
              <view class="cell-label-row-sm">
                <text class="cell-label-sm">消耗</text>
                <view class="help-icon-dark-sm" data-key="consume" bindtap="onHelpTap">?</view>
              </view>
              <text class="cell-value-sm">{{recharge.consumed}}</text>
              <view class="compare-row" wx:if="{{compareEnabled}}">
                <text class="compare-text-up-xs">↑{{recharge.consumedCompare}}</text>
              </view>
            </view>
          </view>
          <!-- 行3：储值卡总余额 -->
          <view class="table-row table-row--footer">
            <view class="table-row-left">
              <text class="table-row-label-bold">储值卡总余额</text>
              <view class="help-icon-dark" data-key="cardBalance" bindtap="onHelpTap">?</view>
            </view>
            <view class="table-row-right">
              <text class="table-row-value-lg">{{recharge.cardBalance}}</text>
              <view class="compare-row-inline" wx:if="{{compareEnabled}}">
                <text class="compare-text-up-sm">↑{{recharge.cardBalanceCompare}}</text>
              </view>
            </view>
          </view>
        </view>

        <!-- 赠送卡统计详情 -->
        <text class="card-section-title" style="margin-top: 35rpx;">赠送卡统计详情</text>
        <view class="table-bordered">
          <!-- 表头 -->
          <view class="gift-table-header">
            <text class="gift-col gift-col--name">类型</text>
            <text class="gift-col">酒水卡</text>
            <text class="gift-col">台费卡</text>
            <text class="gift-col">抵用券</text>
          </view>
          <!-- 数据行（新增/消费/余额） -->
          <view class="gift-table-row {{compareEnabled ? 'gift-table-row--compare' : ''}}" wx:for="{{recharge.giftRows}}" wx:key="label">
            <!-- 左列：标题 + 环比 / 总金额 -->
            <view class="gift-col gift-col--name">
              <view class="gift-label-line">
                <text class="gift-row-label">{{item.label}}</text>
                <text class="compare-text-up-xs" wx:if="{{compareEnabled}}">↑{{item.totalCompare}}</text>
              </view>
              <text class="gift-row-total">{{item.total}}</text>
            </view>
            <!-- 酒水卡 -->
            <view class="gift-col">
              <text class="gift-col-val">{{item.wine}}</text>
              <view class="gift-label-line" wx:if="{{compareEnabled}}">
                <text class="compare-text-up-xs">↑{{item.wineCompare}}</text>
              </view>
            </view>
            <!-- 台费卡 -->
            <view class="gift-col">
              <text class="gift-col-val">{{item.table}}</text>
              <view class="gift-label-line" wx:if="{{compareEnabled}}">
                <text class="compare-text-up-xs">↑{{item.tableCompare}}</text>
              </view>
            </view>
            <!-- 抵用券 -->
            <view class="gift-col">
              <text class="gift-col-val">{{item.coupon}}</text>
              <view class="gift-label-line" wx:if="{{compareEnabled}}">
                <text class="compare-text-up-xs">↑{{item.couponCompare}}</text>
              </view>
            </view>
          </view>
        </view>

        
      </view>
      <!-- 底部锯齿（模拟 H5 card-section::after） -->
      <view class="card-tear"></view>
    </view>

    <!-- ===== 板块 3: 应计收入确认 ===== -->
    <view id="section-revenue" class="card-section">
      <view class="card-header-light">
        <text class="card-header-emoji">💰</text>
        <view class="card-header-text">
          <text class="card-header-title-light">【记账】应计收入确认</text>
          <text class="card-header-desc-light">从发生额到入账收入的全流程</text>
        </view>
      </view>

      <view class="section-body">
        <!-- 收入结构 -->
        <view class="sub-title-row">
          <text class="sub-title-text">收入结构</text>
          <text class="sub-title-desc">按业务查看各项应计收入的构成</text>
        </view>
        <view class="table-bordered">
          <!-- 表头 -->
          <view class="rev-table-header">
            <text class="rev-col rev-col--name">项目</text>
            <text class="rev-col">发生额</text>
            <text class="rev-col">优惠</text>
            <text class="rev-col">入账</text>
          </view>
          <!-- 数据行 -->
          <block wx:for="{{revenue.structureRows}}" wx:key="id">
            <view class="rev-table-row {{item.isSub ? 'rev-table-row--sub' : ''}}">
              <view class="rev-col rev-col--name">
                <text class="{{item.isSub ? 'rev-name-sub' : 'rev-name'}}">{{item.name}}</text>
                <text class="rev-name-desc" wx:if="{{item.desc}}">{{item.desc}}</text>
              </view>
              <text class="rev-col rev-val">{{item.amount}}</text>
              <text class="rev-col rev-val {{item.discount !== '-' ? 'rev-val--red' : 'rev-val--muted'}}">{{item.discount}}</text>
              <view class="rev-col">
                <text class="rev-val {{item.isSub ? '' : 'rev-val--bold'}}">{{item.booked}}</text>
                <view class="compare-row-inline" wx:if="{{compareEnabled && item.bookedCompare}}">
                  <text class="compare-text-up-xs">↑{{item.bookedCompare}}</text>
                </view>
              </view>
            </view>
          </block>
        </view>

        <!-- 收入确认（损益链） -->
        <!-- CHANGE 2026-03-13 | intent: H5 收入结构外层 mb-5=20px→36rpx(87.5%取偶)，损益链与收入结构之间的间距 -->
        <view class="sub-title-row" style="margin-top: 36rpx;">
          <text class="sub-title-text">收入确认</text>
          <text class="sub-title-desc">从正价到收款方式的损益链</text>
        </view>
        <view class="table-bordered">
          <!-- 项目正价 标题 -->
          <view class="flow-header">
            <text class="flow-header-title">项目正价</text>
            <text class="flow-header-desc">即标价测算</text>
          </view>
          <!-- 正价明细（左侧竖线） -->
          <view class="flow-detail-list">
            <view class="flow-detail-item" wx:for="{{revenue.priceItems}}" wx:key="name">
              <text class="flow-detail-name">{{item.name}}</text>
              <view class="flow-detail-right">
                <text class="flow-detail-val">{{item.value}}</text>
                <view class="compare-row-inline" wx:if="{{compareEnabled}}">
                  <text class="compare-text-up-xs">↑{{item.compare}}</text>
                </view>
              </view>
            </view>
          </view>
          <!-- 发生额合计 -->
          <view class="flow-total-row">
            <view class="flow-total-left">
              <text class="flow-total-label">发生额</text>
              <text class="flow-total-desc">即上列正价合计</text>
            </view>
            <view class="flow-total-right">
              <text class="flow-total-value">{{revenue.totalOccurrence}}</text>
              <view class="compare-row-inline" wx:if="{{compareEnabled}}">
                <text class="compare-text-up-sm">↑{{revenue.totalOccurrenceCompare}}</text>
              </view>
            </view>
          </view>
          <!-- 优惠扣减 -->
          <view class="flow-header flow-header--deduct">
            <text class="flow-header-title">优惠扣减</text>
          </view>
          <view class="flow-detail-list">
            <view class="flow-detail-item" wx:for="{{revenue.discountItems}}" wx:key="name">
              <view class="flow-detail-name-group">
                <text class="flow-detail-name">{{item.name}}</text>
                <text class="flow-detail-name-desc" wx:if="{{item.desc}}">{{item.desc}}</text>
              </view>
              <view class="flow-detail-right">
                <text class="flow-detail-val {{item.value === '-¥0' ? 'flow-detail-val--muted' : 'flow-detail-val--red'}}">{{item.value}}</text>
                <view class="compare-row-inline" wx:if="{{compareEnabled && item.compare}}">
                  <text class="compare-text-down-xs">↓{{item.compare}}</text>
                </view>
              </view>
            </view>
          </view>
          <!-- 成交收入 -->
          <view class="flow-total-row flow-total-row--accent">
            <view class="flow-total-left">
              <text class="flow-total-label">成交/确认收入</text>
              <text class="flow-total-desc">即发生额扣除以上优惠抵扣后的金额</text>
              <text class="flow-total-desc">此金额收款渠道分布如下</text>
            </view>
            <view class="flow-total-right">
              <text class="flow-total-value">{{revenue.confirmedTotal}}</text>
              <view class="compare-row-inline" wx:if="{{compareEnabled}}">
                <text class="compare-text-up-sm">↑{{revenue.confirmedTotalCompare}}</text>
              </view>
            </view>
          </view>
          <!-- 收款渠道 -->
          <view class="flow-header">
            <text class="flow-header-title">收款渠道明细</text>
          </view>
          <view class="flow-detail-list">
            <view class="flow-detail-item" wx:for="{{revenue.channelItems}}" wx:key="name">
              <view class="flow-detail-name-group">
                <text class="flow-detail-name">{{item.name}}</text>
                <text class="flow-detail-name-desc" wx:if="{{item.desc}}">{{item.desc}}</text>
              </view>
              <view class="flow-detail-right">
                <text class="flow-detail-val">{{item.value}}</text>
                <view class="compare-row-inline" wx:if="{{compareEnabled}}">
                  <text class="compare-text-up-xs">↑{{item.compare}}</text>
                </view>
              </view>
            </view>
          </view>
        </view>
      </view>
      <!-- 底部锯齿（模拟 H5 card-section::after） -->
      <view class="card-tear"></view>
    </view>

    <!-- ===== 板块 4: 现金流入 ===== -->
    <view id="section-cashflow" class="card-section">
      <view class="card-header-light">
        <text class="card-header-emoji">🧾</text>
        <view class="card-header-text">
          <text class="card-header-title-light">【现金流水】流入</text>
          <text class="card-header-desc-light">实际到账的资金来源明细</text>
        </view>
      </view>

      <view class="section-body">
        <!-- 消费收入 -->
        <text class="flow-group-label">消费收入</text>
        <view class="flow-item-list">
          <view class="flow-item" wx:for="{{cashflow.consumeItems}}" wx:key="name">
            <view class="flow-item-left">
              <text class="flow-item-name">{{item.name}}</text>
              <text class="flow-item-desc" wx:if="{{item.desc}}">{{item.desc}}</text>
            </view>
            <view class="flow-item-right">
              <text class="flow-item-value">{{item.value}}</text>
              <view class="compare-row-inline" wx:if="{{compareEnabled}}">
                <text class="{{item.isDown ? 'compare-text-down-xs' : 'compare-text-up-xs'}}">{{item.isDown ? '↓' : '↑'}}{{item.compare}}</text>
              </view>
            </view>
          </view>
        </view>

        <!-- 充值收入 -->
        <!-- CHANGE 2026-03-13 | intent: H5 mt-3=12px→22rpx(87.5%取偶) -->
        <text class="flow-group-label" style="margin-top: 22rpx;">充值收入</text>
        <view class="flow-item-list">
          <view class="flow-item" wx:for="{{cashflow.rechargeItems}}" wx:key="name">
            <view class="flow-item-left">
              <text class="flow-item-name">{{item.name}}</text>
              <text class="flow-item-desc" wx:if="{{item.desc}}">{{item.desc}}</text>
            </view>
            <view class="flow-item-right">
              <text class="flow-item-value">{{item.value}}</text>
              <view class="compare-row-inline" wx:if="{{compareEnabled}}">
                <text class="compare-text-up-xs">↑{{item.compare}}</text>
              </view>
            </view>
          </view>
        </view>

        <!-- 合计 -->
        <view class="flow-sum-row">
          <text class="flow-sum-label">现金流入合计</text>
          <view class="flow-sum-right">
            <text class="flow-sum-value">{{cashflow.total}}</text>
            <view class="compare-row-inline" wx:if="{{compareEnabled}}">
              <text class="compare-text-up-sm">↑{{cashflow.totalCompare}}</text>
            </view>
          </view>
        </view>
      </view>
      <!-- 底部锯齿（模拟 H5 card-section::after） -->
      <view class="card-tear"></view>
    </view>

    <!-- ===== 板块 5: 现金流出 ===== -->
    <view id="section-expense" class="card-section">
      <view class="card-header-light">
        <text class="card-header-emoji">📤</text>
        <view class="card-header-text">
          <text class="card-header-title-light">【现金流水】流出</text>
          <text class="card-header-desc-light">清晰呈现各类开销与结构</text>
        </view>
      </view>

      <view class="section-body">
        <!-- 进货与运营 3列 -->
        <text class="expense-group-label">进货与运营</text>
        <view class="expense-grid-3">
          <view class="expense-cell" wx:for="{{expense.operationItems}}" wx:key="name">
            <text class="expense-cell-label">{{item.name}}</text>
            <text class="expense-cell-value">{{item.value}}</text>
            <view class="compare-row" wx:if="{{compareEnabled}}">
              <text class="{{item.isDown ? 'compare-text-down-xs' : 'compare-text-up-xs'}}">{{item.isDown ? '↓' : '↑'}}{{item.compare}}</text>
            </view>
          </view>
        </view>

        <!-- 固定支出 2×2 -->
        <text class="expense-group-label">固定支出</text>
        <view class="expense-grid-2">
          <view class="expense-cell" wx:for="{{expense.fixedItems}}" wx:key="name">
            <text class="expense-cell-label">{{item.name}}</text>
            <text class="expense-cell-value">{{item.value}}</text>
            <view class="compare-row" wx:if="{{compareEnabled}}">
              <text class="{{item.isFlat ? 'compare-text-flat-xs' : 'compare-text-up-xs'}}">{{item.isFlat ? '' : '↑'}}{{item.compare}}</text>
            </view>
          </view>
        </view>

        <!-- 助教薪资 2×2 -->
        <text class="expense-group-label">助教薪资</text>
        <view class="expense-grid-2">
          <view class="expense-cell" wx:for="{{expense.coachItems}}" wx:key="name">
            <text class="expense-cell-label">{{item.name}}</text>
            <text class="expense-cell-value">{{item.value}}</text>
            <view class="compare-row" wx:if="{{compareEnabled}}">
              <text class="{{item.isDown ? 'compare-text-down-xs' : 'compare-text-up-xs'}}">{{item.isDown ? '↓' : '↑'}}{{item.compare}}</text>
            </view>
          </view>
        </view>

        <!-- 平台服务费 3列 -->
        <text class="expense-group-label">平台服务费</text>
        <text class="expense-group-note">服务费在流水流入时，平台已经扣除。不产生支出流水。</text>
        <view class="expense-grid-3">
          <view class="expense-cell" wx:for="{{expense.platformItems}}" wx:key="name">
            <text class="expense-cell-label">{{item.name}}</text>
            <text class="expense-cell-value">{{item.value}}</text>
            <view class="compare-row" wx:if="{{compareEnabled}}">
              <text class="compare-text-up-xs">↑{{item.compare}}</text>
            </view>
          </view>
        </view>

        <!-- 支出合计 -->
        <view class="flow-sum-row">
          <text class="flow-sum-label">支出合计</text>
          <view class="flow-sum-right">
            <text class="flow-sum-value">{{expense.total}}</text>
            <view class="compare-row-inline" wx:if="{{compareEnabled}}">
              <text class="compare-text-up-sm">↑{{expense.totalCompare}}</text>
            </view>
          </view>
        </view>
      </view>
      <!-- 底部锯齿（模拟 H5 card-section::after） -->
      <view class="card-tear"></view>
    </view>

    <!-- ===== 板块 6: 助教分析 ===== -->
    <view id="section-coach" class="card-section">
      <view class="card-header-light">
        <text class="card-header-emoji">🎱</text>
        <view class="card-header-text">
          <text class="card-header-title-light">助教分析</text>
          <text class="card-header-desc-light">全部助教服务收入与分成的平均值，用以评估球房分成效益</text>
        </view>
      </view>

      <view class="section-body">
        <!-- 基础课 -->
        <text class="card-section-title">助教 <text class="card-section-title-sub">（基础课）</text></text>
        <view class="table-bordered">
          <view class="coach-fin-header">
            <text class="coach-fin-col coach-fin-col--name">级别</text>
            <text class="coach-fin-col">客户支付</text>
            <text class="coach-fin-col">球房抽成</text>
            <text class="coach-fin-col">小时平均</text>
          </view>
          <!-- 合计行 -->
          <view class="coach-fin-row coach-fin-row--total">
            <text class="coach-fin-col coach-fin-col--name coach-fin-bold">合计</text>
            <view class="coach-fin-col">
              <text class="coach-fin-bold">{{coachAnalysis.basic.totalPay}}</text>
              <view class="compare-row-inline" wx:if="{{compareEnabled}}">
                <text class="compare-text-up-xs">↑{{coachAnalysis.basic.totalPayCompare}}</text>
              </view>
            </view>
            <view class="coach-fin-col">
              <text class="coach-fin-bold">{{coachAnalysis.basic.totalShare}}</text>
              <view class="compare-row-inline" wx:if="{{compareEnabled}}">
                <text class="compare-text-up-xs">↑{{coachAnalysis.basic.totalShareCompare}}</text>
              </view>
            </view>
            <view class="coach-fin-col">
              <text class="coach-fin-val-sm">{{coachAnalysis.basic.avgHourly}}</text>
              <view class="compare-row-inline" wx:if="{{compareEnabled}}">
                <text class="compare-text-up-xs">↑{{coachAnalysis.basic.avgHourlyCompare}}</text>
              </view>
            </view>
          </view>
          <!-- 明细行 -->
          <view class="coach-fin-row coach-fin-row--detail" wx:for="{{coachAnalysis.basic.rows}}" wx:key="level">
            <text class="coach-fin-col coach-fin-col--name">{{item.level}}</text>
            <view class="coach-fin-col">
              <text class="coach-fin-val">{{item.pay}}</text>
              <view class="compare-row-inline" wx:if="{{compareEnabled}}">
                <text class="{{item.payDown ? 'compare-text-down-xs' : 'compare-text-up-xs'}}">{{item.payDown ? '↓' : '↑'}}{{item.payCompare}}</text>
              </view>
            </view>
            <view class="coach-fin-col">
              <text class="coach-fin-val">{{item.share}}</text>
              <view class="compare-row-inline" wx:if="{{compareEnabled}}">
                <text class="{{item.shareDown ? 'compare-text-down-xs' : 'compare-text-up-xs'}}">{{item.shareDown ? '↓' : '↑'}}{{item.shareCompare}}</text>
              </view>
            </view>
            <view class="coach-fin-col">
              <text class="coach-fin-val-sm">{{item.hourly}}</text>
              <view class="compare-row-inline" wx:if="{{compareEnabled}}">
                <text class="{{item.hourlyFlat ? 'compare-text-flat-xs' : 'compare-text-up-xs'}}">{{item.hourlyFlat ? '' : '↑'}}{{item.hourlyCompare}}</text>
              </view>
            </view>
          </view>
        </view>

        <!-- 激励课 -->
        <text class="card-section-title" style="margin-top: 28rpx;">助教 <text class="card-section-title-sub">（激励课）</text></text>
        <view class="table-bordered">
          <view class="coach-fin-header">
            <text class="coach-fin-col coach-fin-col--name">级别</text>
            <text class="coach-fin-col">客户支付</text>
            <text class="coach-fin-col">球房抽成</text>
            <text class="coach-fin-col">小时平均</text>
          </view>
          <view class="coach-fin-row coach-fin-row--incentive-total">
            <text class="coach-fin-col coach-fin-col--name coach-fin-bold">合计</text>
            <view class="coach-fin-col">
              <text class="coach-fin-bold">{{coachAnalysis.incentive.totalPay}}</text>
              <view class="compare-row-inline" wx:if="{{compareEnabled}}">
                <text class="compare-text-up-xs">↑{{coachAnalysis.incentive.totalPayCompare}}</text>
              </view>
            </view>
            <view class="coach-fin-col">
              <text class="coach-fin-bold">{{coachAnalysis.incentive.totalShare}}</text>
              <view class="compare-row-inline" wx:if="{{compareEnabled}}">
                <text class="compare-text-up-xs">↑{{coachAnalysis.incentive.totalShareCompare}}</text>
              </view>
            </view>
            <view class="coach-fin-col">
              <text class="coach-fin-val-sm">{{coachAnalysis.incentive.avgHourly}}</text>
              <view class="compare-row-inline" wx:if="{{compareEnabled}}">
                <text class="compare-text-up-xs">↑{{coachAnalysis.incentive.avgHourlyCompare}}</text>
              </view>
            </view>
          </view>
        </view>
      </view>
      <!-- 底部锯齿（模拟 H5 card-section::after） -->
      <view class="card-tear"></view>
    </view>

    <!-- 底部安全区 -->
    <view class="safe-bottom"></view>
  </view>

  <!-- ===== 目录导航遮罩 ===== -->
  <view class="toc-overlay" wx:if="{{tocVisible}}" catchtap="closeToc"></view>

  <!-- ===== 目录导航面板 ===== -->
  <view class="toc-panel {{tocVisible ? 'toc-panel--show' : ''}}">
    <view class="toc-header">
      <text class="toc-header-text">📊 财务看板导航</text>
    </view>
    <view class="toc-list">
      <view
        class="toc-item {{currentSectionIndex === index ? 'toc-item--active' : ''}}"
        wx:for="{{tocItems}}"
        wx:key="sectionId"
        data-index="{{index}}"
        bindtap="onTocItemTap"
      >
        <text class="toc-item-emoji">{{item.emoji}}</text>
        <text class="toc-item-text">{{item.title}}</text>
      </view>
    </view>
  </view>

  <!-- ===== 指标说明弹窗 ===== -->
  <view class="tip-overlay" wx:if="{{tipVisible}}" catchtap="closeTip"></view>
  <view class="tip-toast {{tipVisible ? 'tip-toast--show' : ''}}">
    <view class="tip-toast-header">
      <text class="tip-toast-title">{{tipTitle}}</text>
      <view class="tip-toast-close" bindtap="closeTip">
        <t-icon name="close" size="36rpx" color="#8b8b8b" />
      </view>
    </view>
    <text class="tip-toast-content">{{tipContent}}</text>
  </view>
</block>

<!-- AI 悬浮按钮 -->
<ai-float-button bottom="{{200}}" />

<dev-fab wx:if="{{false}}" />
