<div class="finance-dashboard">
  <!-- 顶部标题区域 -->
  <div class="dashboard-header">
    <h1 class="dashboard-title">财务工作台</h1>
    <div class="current-date">{{ today | date: 'yyyy年MM月dd日' }}</div>
  </div>

  <!-- 快捷操作区域 -->
  <div class="quick-actions">
    <button class="action-btn" (click)="handleQuickAction('newQuote')">
      <div class="action-icon new-quote">📝</div>
      <div class="action-label">新建报价</div>
    </button>
    <button class="action-btn" (click)="handleQuickAction('recordPayment')">
      <div class="action-icon record-payment">💰</div>
      <div class="action-label">录入收款</div>
    </button>
    <button class="action-btn" (click)="handleQuickAction('generateReport')">
      <div class="action-icon generate-report">📊</div>
      <div class="action-label">生成日接单表</div>
    </button>
  </div>

  <!-- 主内容区域 -->
  <div class="dashboard-content">
    <!-- 数据概览卡片 -->
    <div class="stats-cards">
      <div class="stat-card">
        <div class="stat-icon orders"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor"><path d="M3 3h18v18H3V3zm6 6v2H7V9h2zm0 4v2H7v-2h2zm0 4v2H7v-2h2zm4-8v2h-2V9h2zm0 4v2h-2v-2h2zm0 4v2h-2v-2h2zm4-8v2h-2V9h2zm0 4v2h-2v-2h2zm0 4v2h-2v-2h2z"/></svg></div>
        <div class="stat-content">
          <div class="stat-value">{{ dashboardStats().todayOrders }}</div>
          <div class="stat-label">今日接单量</div>
        </div>
        <button class="view-detail-btn" (click)="handleQuickAction('generateReport')">查看详情</button>
      </div>

      <div class="stat-card">
        <div class="stat-icon payment"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor"><path d="M20 6h-2c0-1.654-1.346-3-3-3H9C7.346 3 6 4.346 6 6H4c-1.103 0-2 .897-2 2v10c0 1.103.897 2 2 2h16c1.103 0 2-.897 2-2V8c0-1.103-.897-2-2-2zM9 6c0-.551.448-1 1-1h4c.552 0 1 .449 1 1v2H9V6zm10 12H4v-4h16v4z"/></svg></div>
        <div class="stat-content">
          <div class="stat-value" *ngIf="userRole() === 'teamLead'; else hiddenValue">{{ formatAmount(dashboardStats().pendingPayment) }}</div>
          <ng-template #hiddenValue><div class="stat-value">--</div></ng-template>
          <div class="stat-label">待收款金额</div>
        </div>
        <button class="view-detail-btn" (click)="handleQuickAction('recordPayment')">查看详情</button>
      </div>

      <div class="stat-card">
        <div class="stat-icon quotes"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor"><path d="M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 01-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 012 2v3"/></svg></div>
        <div class="stat-content">
          <div class="stat-value">{{ dashboardStats().quotedProjects }}</div>
          <div class="stat-label">已完成报价单数</div>
        </div>
        <button class="view-detail-btn" (click)="handleQuickAction('newQuote')">查看详情</button>
      </div>

      <div class="stat-card">
        <div class="stat-icon savings"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor"><path d="M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"/></svg></div>
        <div class="stat-content">
          <div class="stat-value" *ngIf="userRole() === 'teamLead'; else hiddenSavings">{{ formatAmount(dashboardStats().materialCostSaved) }}</div>
          <ng-template #hiddenSavings><div class="stat-value">--</div></ng-template>
          <div class="stat-label">素材成本节约金额</div>
        </div>
        <button class="view-detail-btn" (click)="handleQuickAction('recordPayment')">查看详情</button>
      </div>
    </div>

    <!-- 待办任务区域 -->
    <div class="todo-section">
      <div class="section-header">
        <h2>待办任务</h2>
        <div class="task-count">{{ todoTasks().length }} 项任务</div>
      </div>
      <div class="task-list">
        <div class="task-item" *ngFor="let task of todoTasks()" (click)="handleTaskClick(task)" [class.high-priority]="task.priority === 'high'" [class.medium-priority]="task.priority === 'medium'">
          <div class="task-priority-indicator"></div>
          <div class="task-content">
            <div class="task-title">{{ task.title }}</div>
            <div class="task-meta">
              <span class="due-time">截止时间: {{ task.dueTime }}</span>
            </div>
          </div>
          <div class="task-action">
            <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor"><path d="M5 12h14M12 5l7 7-7 7"/></svg>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>