<template>
  <div class="pdf-report">
    <!-- 报告概览 -->
    <section class="pdf-section">
      <h2 class="pdf-section-title">报告概览</h2>
      
      <!-- 审核建议 -->
      <div class="pdf-card pdf-suggestion-card">
        <div class="pdf-card-header">
          <span class="pdf-label">审核建议</span>
          <span class="pdf-value" :class="getCheckSuggestClass">{{ checkSuggest || '建议拒绝' }}</span>
        </div>
      </div>

      <!-- 基本信息 -->
      <div class="pdf-card">
        <h3 class="pdf-subtitle">基本信息</h3>
        <table class="pdf-info-table">
          <tr>
            <td class="pdf-info-label">姓名：</td>
            <td class="pdf-info-value">{{ maskName(baseInfo.name) }}</td>
            <td class="pdf-info-label">年龄：</td>
            <td class="pdf-info-value">{{ baseInfo.age }}岁</td>
          </tr>
          <tr>
            <td class="pdf-info-label">性别：</td>
            <td class="pdf-info-value">{{ baseInfo.sex }}</td>
            <td class="pdf-info-label">手机号：</td>
            <td class="pdf-info-value">{{ maskPhone(baseInfo.phone) }}</td>
          </tr>
          <tr>
            <td class="pdf-info-label">身份证号：</td>
            <td class="pdf-info-value">{{ maskIdCard(baseInfo.idCard) }}</td>
            <td class="pdf-info-label">户籍所在地：</td>
            <td class="pdf-info-value">{{ baseInfo.location }}</td>
          </tr>
          <tr>
            <td class="pdf-info-label">号码归属地：</td>
            <td class="pdf-info-value" colspan="3">{{ baseInfo.phoneArea }}</td>
          </tr>
        </table>
      </div>

      <!-- 风险评分与等级 -->
      <div class="pdf-card">
        <h3 class="pdf-subtitle">风险评分与等级</h3>
        <div class="pdf-score-grid">
          <div class="pdf-score-item" :class="getFraudScoreBgClass(fraudScore)">
            <div class="pdf-score-label">反欺诈评分</div>
            <div class="pdf-score-value">{{ fraudScore === -1 ? '未命中' : fraudScore }}</div>
            <div class="pdf-score-tag" :class="getRiskTagClass(getFraudRiskLevel(fraudScore))">
              {{ getFraudRiskLevel(fraudScore) }}
            </div>
          </div>
          <div class="pdf-score-item" :class="getCreditScoreBgClass(creditScore)">
            <div class="pdf-score-label">信用评分</div>
            <div class="pdf-score-value">{{ creditScore === -1 ? '未命中' : creditScore }}</div>
            <div class="pdf-score-tag" :class="getRiskTagClass(getCreditLevel(creditScore))">
              {{ getCreditLevel(creditScore) }}
            </div>
          </div>
          <div class="pdf-score-item" :class="getRiskLevelClass(verifyRule)">
            <div class="pdf-score-label">验证规则</div>
            <div class="pdf-score-value">{{ verifyRule || '未评估' }}</div>
            <div class="pdf-score-tag" :class="getRiskTagClass(verifyRule)">
              {{ verifyRule || '未评估' }}
            </div>
          </div>
          <div class="pdf-score-item" :class="getRiskLevelClass(fraudRule)">
            <div class="pdf-score-label">反欺诈规则</div>
            <div class="pdf-score-value">{{ fraudRule || '未评估' }}</div>
            <div class="pdf-score-tag" :class="getRiskTagClass(fraudRule)">
              {{ fraudRule || '未评估' }}
            </div>
          </div>
        </div>
      </div>
    </section>

    <!-- 要素核查详情 -->
    <section class="pdf-section">
      <h2 class="pdf-section-title">要素核查</h2>
      
      <!-- 身份证二要素验证 -->
      <div class="pdf-card">
        <div class="pdf-card-header">
          <span class="pdf-label">身份证二要素验证</span>
          <span class="pdf-tag" :class="getRiskFlagTagClass(sfzeysFlag)">
            {{ getRiskFlagText(sfzeysFlag) }}
          </span>
        </div>
        <div v-if="personCheckDetails" class="pdf-verification-result" :class="getVerificationResultClass(personCheckDetails.result)">
          <div class="pdf-result-label">{{ personCheckDetails.ele || '身份证号、姓名' }}</div>
          <div class="pdf-result-value">{{ getResultText(personCheckDetails.result) }}</div>
        </div>
      </div>

      <!-- 手机三要素验证 -->
      <div class="pdf-card">
        <div class="pdf-card-header">
          <span class="pdf-label">手机三要素验证</span>
          <span class="pdf-tag" :class="getRiskFlagTagClass(sjsysFlag)">
            {{ getRiskFlagText(sjsysFlag) }}
          </span>
        </div>
        <div v-if="phoneCheckDetails" class="pdf-verification-result" :class="getVerificationResultClass(phoneCheckDetails.result)">
          <div class="pdf-result-label">{{ phoneCheckDetails.ele || '身份证号、手机号、姓名' }}</div>
          <div class="pdf-result-value">{{ getResultText(phoneCheckDetails.result) }}</div>
          <div class="pdf-result-detail" v-if="phoneCheckDetails.phoneCompany">
            运营商: {{ phoneCheckDetails.phoneCompany }}
          </div>
        </div>
      </div>
    </section>

    <!-- 风险预警 -->
    <section class="pdf-section" v-if="riskWarning && Object.keys(riskWarning).length > 0">
      <h2 class="pdf-section-title">规则风险提示</h2>
      
      <!-- 总风险统计 -->
      <div class="pdf-card">
        <h3 class="pdf-subtitle">总风险统计</h3>
        <div class="pdf-risk-stats">
          <div class="pdf-stat-item">
            <div class="pdf-stat-value">{{ riskWarning.totalRiskCounts || 0 }}</div>
            <div class="pdf-stat-label">总风险点数量</div>
          </div>
          <div class="pdf-stat-item">
            <div class="pdf-stat-value">{{ getHighRiskCount() }}</div>
            <div class="pdf-stat-label">高风险</div>
          </div>
          <div class="pdf-stat-item">
            <div class="pdf-stat-value">{{ getMiddleRiskCount() }}</div>
            <div class="pdf-stat-label">中风险</div>
          </div>
          <div class="pdf-stat-item">
            <div class="pdf-stat-value">{{ riskWarning.level || '-' }}</div>
            <div class="pdf-stat-label">风险等级</div>
          </div>
        </div>
      </div>

      <!-- 风险详情列表 -->
      <div class="pdf-card" v-if="getAllRisks().length > 0">
        <h3 class="pdf-subtitle">风险详情</h3>
        <div class="pdf-risk-list">
          <div v-for="risk in getAllRisks()" :key="risk.key" class="pdf-risk-item">
            <div class="pdf-risk-content">
              <div class="pdf-risk-title">{{ risk.description }}</div>
              <div class="pdf-risk-detail">{{ risk.detail }}</div>
            </div>
            <span class="pdf-risk-badge" :class="getRiskLevelBadgeClass(risk.level)">
              {{ risk.level }}
            </span>
          </div>
        </div>
      </div>
    </section>

    <!-- 逾期风险综述 -->
    <section class="pdf-section" v-if="overdueRiskProduct && Object.keys(overdueRiskProduct).length > 0">
      <h2 class="pdf-section-title">逾期风险综述</h2>
      
      <!-- 逾期概览 -->
      <div class="pdf-card">
        <div class="pdf-card-header">
          <span class="pdf-label">逾期风险概览</span>
          <span class="pdf-tag" :class="getOverdueStatusTagClass(overdueRiskProduct.hasUnsettledOverdue)">
            {{ getOverdueStatusText(overdueRiskProduct.hasUnsettledOverdue) }}
          </span>
        </div>
        <div class="pdf-overdue-stats">
          <div class="pdf-stat-item">
            <div class="pdf-stat-value">{{ formatInstitutionInterval(overdueRiskProduct.currentOverdueInstitutionCount) }}</div>
            <div class="pdf-stat-label">当前逾期机构数</div>
          </div>
          <div class="pdf-stat-item">
            <div class="pdf-stat-value">{{ formatAmountInterval(overdueRiskProduct.currentOverdueAmount) }}</div>
            <div class="pdf-stat-label">当前逾期金额</div>
          </div>
          <div class="pdf-stat-item">
            <div class="pdf-stat-value">{{ formatInstitutionInterval(overdueRiskProduct.settledInstitutionCount) }}</div>
            <div class="pdf-stat-label">已结清机构数</div>
          </div>
          <div class="pdf-stat-item">
            <div class="pdf-stat-value">{{ formatInstitutionInterval(overdueRiskProduct.totalLoanInstitutions) }}</div>
            <div class="pdf-stat-label">贷款总机构</div>
          </div>
        </div>
      </div>

      <!-- 逾期时间分布 -->
      <div class="pdf-card">
        <h3 class="pdf-subtitle">逾期时间分布</h3>
        <div class="pdf-time-distribution">
          <div class="pdf-time-item" :class="getOverdueTimeClass(overdueRiskProduct.overdueLast1Day)">
            <div class="pdf-time-value">{{ getOverdueTimeText(overdueRiskProduct.overdueLast1Day) }}</div>
            <div class="pdf-time-label">近1天</div>
          </div>
          <div class="pdf-time-item" :class="getOverdueTimeClass(overdueRiskProduct.overdueLast7Days)">
            <div class="pdf-time-value">{{ getOverdueTimeText(overdueRiskProduct.overdueLast7Days) }}</div>
            <div class="pdf-time-label">近7天</div>
          </div>
          <div class="pdf-time-item" :class="getOverdueTimeClass(overdueRiskProduct.overdueLast14Days)">
            <div class="pdf-time-value">{{ getOverdueTimeText(overdueRiskProduct.overdueLast14Days) }}</div>
            <div class="pdf-time-label">近14天</div>
          </div>
          <div class="pdf-time-item" :class="getOverdueTimeClass(overdueRiskProduct.overdueLast30Days)">
            <div class="pdf-time-value">{{ getOverdueTimeText(overdueRiskProduct.overdueLast30Days) }}</div>
            <div class="pdf-time-label">近30天</div>
          </div>
        </div>
      </div>
    </section>

    <!-- 借贷评估 -->
    <section class="pdf-section" v-if="loanEvaluationVerificationDetail && Object.keys(loanEvaluationVerificationDetail).length > 0">
      <h2 class="pdf-section-title">借贷评估</h2>
      
      <div class="pdf-card">
        <div class="pdf-card-header">
          <span class="pdf-label">借贷评估概览</span>
          <span class="pdf-tag" :class="getRiskFlagTagClass(loanEvaluationVerificationDetail.riskFlag)">
            {{ getRiskFlagText(loanEvaluationVerificationDetail.riskFlag) }}
          </span>
        </div>

        <!-- 机构借贷表现 -->
        <div v-if="loanEvaluationVerificationDetail.organLoanPerformances && loanEvaluationVerificationDetail.organLoanPerformances.length > 0" class="pdf-loan-section">
          <h4 class="pdf-mini-title">机构借贷表现</h4>
          <div v-for="(item, index) in loanEvaluationVerificationDetail.organLoanPerformances" :key="index" class="pdf-loan-item">
            <div class="pdf-loan-type">{{ item.applyCount === '银行' ? '银行机构' : '非银机构' }}</div>
            <div class="pdf-loan-data">
              <div class="pdf-loan-row">
                <span class="pdf-loan-label">近7天：</span>
                <span class="pdf-loan-value">{{ item.last7Day || '0/0' }}</span>
              </div>
              <div class="pdf-loan-row">
                <span class="pdf-loan-label">近15天：</span>
                <span class="pdf-loan-value">{{ item.last15Day || '0/0' }}</span>
              </div>
              <div class="pdf-loan-row">
                <span class="pdf-loan-label">近1个月：</span>
                <span class="pdf-loan-value">{{ item.last1Month || '0/0' }}</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>

    <!-- 租赁风险评估 -->
    <section class="pdf-section" v-if="leasingRiskAssessment && Object.keys(leasingRiskAssessment).length > 0">
      <h2 class="pdf-section-title">租赁风险评估</h2>
      
      <div class="pdf-card">
        <div class="pdf-card-header">
          <span class="pdf-label">租赁风险评估概览</span>
          <span class="pdf-tag" :class="getRiskFlagTagClass(leasingRiskAssessment.riskFlag)">
            {{ getRiskFlagText(leasingRiskAssessment.riskFlag) }}
          </span>
        </div>

        <!-- 3C机构申请统计 -->
        <div class="pdf-leasing-section">
          <h4 class="pdf-mini-title">3C机构申请统计（近3天）</h4>
          <div class="pdf-leasing-data">
            <div class="pdf-leasing-row">
              <span class="pdf-leasing-label">总申请数：</span>
              <span class="pdf-leasing-value">{{ leasingRiskAssessment.threeCInstitutionApplicationCountLast3Days || '0/0' }}</span>
            </div>
            <div class="pdf-leasing-row">
              <span class="pdf-leasing-label">周末申请数：</span>
              <span class="pdf-leasing-value">{{ leasingRiskAssessment.threeCInstitutionApplicationCountLast3DaysWeekend || '0/0' }}</span>
            </div>
            <div class="pdf-leasing-row">
              <span class="pdf-leasing-label">夜间申请数：</span>
              <span class="pdf-leasing-value">{{ leasingRiskAssessment.threeCInstitutionApplicationCountLast3DaysNight || '0/0' }}</span>
            </div>
          </div>
        </div>

        <!-- 3C平台申请统计 -->
        <div class="pdf-leasing-section">
          <h4 class="pdf-mini-title">3C平台申请统计（近3天）</h4>
          <div class="pdf-leasing-data">
            <div class="pdf-leasing-row">
              <span class="pdf-leasing-label">总申请数：</span>
              <span class="pdf-leasing-value">{{ leasingRiskAssessment.threeCPlatformApplicationCountLast3Days || '0/0' }}</span>
            </div>
            <div class="pdf-leasing-row">
              <span class="pdf-leasing-label">周末申请数：</span>
              <span class="pdf-leasing-value">{{ leasingRiskAssessment.threeCPlatformApplicationCountLast3DaysWeekend || '0/0' }}</span>
            </div>
            <div class="pdf-leasing-row">
              <span class="pdf-leasing-label">夜间申请数：</span>
              <span class="pdf-leasing-value">{{ leasingRiskAssessment.threeCPlatformApplicationCountLast3DaysNight || '0/0' }}</span>
            </div>
          </div>
        </div>
      </div>
    </section>

    <!-- 关联风险监督 -->
    <section class="pdf-section" v-if="riskSupervision && Object.keys(riskSupervision).length > 0">
      <h2 class="pdf-section-title">关联风险监督</h2>
      
      <div class="pdf-card">
        <div class="pdf-supervision-header">
          <div class="pdf-supervision-title">关联风险监督</div>
          <div class="pdf-supervision-time">最后申请时间: {{ riskSupervision.leastApplicationTime || '未知' }}</div>
        </div>
        <div class="pdf-supervision-stats">
          <div class="pdf-supervision-item">
            <div class="pdf-supervision-value">{{ riskSupervision.rentalRiskListIdCardRelationsPhones || 0 }}</div>
            <div class="pdf-supervision-label">同一身份证关联手机号数</div>
          </div>
          <div class="pdf-supervision-item">
            <div class="pdf-supervision-value">{{ riskSupervision.rentalRiskListPhoneRelationsIdCards || 0 }}</div>
            <div class="pdf-supervision-label">同一手机号关联身份证数</div>
          </div>
        </div>
      </div>
    </section>
  </div>
</template>

<script setup>
import { computed } from 'vue'
import {
  formatAmountInterval,
  formatCountInterval,
  formatDaysInterval,
  formatInstitutionInterval
} from './utils/intervalFormatter.js'

const props = defineProps({
  data: {
    type: Object,
    required: true,
  },
})

// 从data中解构出需要的字段
const {
  baseInfo = {},
  checkSuggest = '',
  fraudScore = -1,
  creditScore = -1,
  verifyRule = '',
  fraudRule = '',
  riskWarning = {},
  elementVerificationDetail = {},
  riskSupervision = {},
  overdueRiskProduct = {},
  loanEvaluationVerificationDetail = {},
  leasingRiskAssessment = {},
} = props.data

// 要素核查详情
const {
  sfzeysFlag = 0,
  personCheckDetails = {},
  sjsysFlag = 0,
  phoneCheckDetails = {}
} = elementVerificationDetail

// 数据脱敏函数
const maskName = (name) => {
  if (!name) return ''
  if (name.length === 1) return '*'
  if (name.length === 2) return name[0] + '*'
  return name[0] + '*'.repeat(name.length - 2) + name[name.length - 1]
}

const maskPhone = (phone) => {
  if (!phone) return ''
  if (phone.length === 11) {
    return phone.substring(0, 3) + '****' + phone.substring(7)
  }
  return phone
}

const maskIdCard = (idCard) => {
  if (!idCard) return ''
  return idCard.replace(/^(.{6})(?:\d+)(.{4})$/, '$1****$2')
}

// 审核建议样式
const getCheckSuggestClass = computed(() => {
  const suggest = checkSuggest || '建议拒绝'
  if (suggest.includes('拒绝')) {
    return 'pdf-value-danger'
  } else if (suggest.includes('通过')) {
    return 'pdf-value-success'
  } else {
    return 'pdf-value-warning'
  }
})

// 风险等级相关函数
const getRiskLevelClass = (level) => {
  if (level === '高风险') return 'pdf-score-high'
  if (level === '中风险') return 'pdf-score-medium'
  if (level === '低风险') return 'pdf-score-low'
  return 'pdf-score-default'
}

const getFraudRiskLevel = (score) => {
  if (score === -1) return '未评估'
  if (score >= 80) return '高风险'
  if (score >= 60) return '中风险'
  return '低风险'
}

const getCreditLevel = (score) => {
  if (score === -1) return '未评估'
  if (score >= 800) return '信用较好'
  if (score >= 500) return '信用良好'
  return '信用一般'
}

const getFraudScoreBgClass = (score) => {
  if (score === -1) return 'pdf-score-default'
  if (score >= 80) return 'pdf-score-high'
  if (score >= 60) return 'pdf-score-medium'
  return 'pdf-score-low'
}

const getCreditScoreBgClass = (score) => {
  if (score === -1) return 'pdf-score-default'
  if (score >= 800) return 'pdf-score-low'
  if (score >= 500) return 'pdf-score-info'
  return 'pdf-score-medium'
}

const getRiskTagClass = (level) => {
  if (level === '高风险') return 'pdf-tag-danger'
  if (level === '中风险') return 'pdf-tag-warning'
  if (level === '低风险') return 'pdf-tag-success'
  if (level === '信用较好') return 'pdf-tag-success'
  if (level === '信用良好') return 'pdf-tag-info'
  if (level === '信用一般') return 'pdf-tag-warning'
  return 'pdf-tag-default'
}

// 风险标识相关函数
const getRiskFlagText = (flag) => {
  if (flag === 1) return '高风险'
  if (flag === 2) return '低风险'
  return '未查得'
}

const getRiskFlagTagClass = (flag) => {
  if (flag === 1) return 'pdf-tag-danger'
  if (flag === 2) return 'pdf-tag-success'
  return 'pdf-tag-default'
}

// 验证结果相关函数
const getResultText = (result) => {
  if (result === '一致') return '核验一致'
  if (result === '不一致') return '核验不一致'
  return result || '未查得'
}

const getVerificationResultClass = (result) => {
  if (result === '一致') return 'pdf-result-success'
  if (result === '不一致') return 'pdf-result-danger'
  return 'pdf-result-default'
}

// 风险统计
const getHighRiskCount = () => {
  const highRiskFields = [
    'idCardTwoElementMismatch', 'phoneThreeElementMismatch',
    'shortPhoneDuration', 'noPhoneDuration',
    'hasCriminalRecord', 'isEconomyFront', 'isDisrupSocial', 'isKeyPerson', 'isTrafficRelated',
    'hitHighRiskBankLastTwoYears', 'hitHighRiskNonBankLastTwoYears',
    'hitCivilCase', 'hitCriminalRisk', 'hitAdministrativeCase', 'hitPreservationReview',
    'hitExecutionCase', 'hitBankruptcyAndLiquidation', 'hitDirectlyUnderCase', 'hitCompensationCase',
    'frequentApplicationRecent', 'frequentNonBankApplications', 'highDebtPressure', 'frequentBankApplications',
    'frequentRentalApplications', 'veryFrequentRentalApplications'
  ]
  return highRiskFields.reduce((count, field) => {
    return count + (riskWarning[field] || 0)
  }, 0)
}

const getMiddleRiskCount = () => {
  const middleRiskFields = [
    'idCardPhoneProvinceMismatch', 'isAntiFraudInfo',
    'hitCurrentOverdue',
    'moreFrequentNonBankApplications', 'highFraudGangLevel', 'moreFrequentBankApplications'
  ]
  return middleRiskFields.reduce((count, field) => {
    return count + (riskWarning[field] || 0)
  }, 0)
}

// 获取所有风险
const getAllRisks = () => {
  const risks = []
  
  // 要素核查风险
  if (riskWarning.idCardTwoElementMismatch) {
    risks.push({
      key: 'idCardTwoElementMismatch',
      description: '身份证二要素信息对比结果不一致',
      detail: '身份证号与姓名信息不匹配',
      level: '高风险'
    })
  }
  if (riskWarning.phoneThreeElementMismatch) {
    risks.push({
      key: 'phoneThreeElementMismatch',
      description: '手机三要素简版不一致',
      detail: '手机号与身份证号、姓名信息不匹配',
      level: '高风险'
    })
  }
  
  // 运营商核验风险
  if (riskWarning.shortPhoneDuration) {
    risks.push({
      key: 'shortPhoneDuration',
      description: '手机在网时长极短',
      detail: '手机号在网时间过短，存在风险',
      level: '高风险'
    })
  }
  if (riskWarning.idCardPhoneProvinceMismatch) {
    risks.push({
      key: 'idCardPhoneProvinceMismatch',
      description: '身份证号手机号归属省不一致',
      detail: '身份证归属地与手机号归属地不匹配',
      level: '中风险'
    })
  }
  
  // 公安重点人员核验风险
  if (riskWarning.hasCriminalRecord) {
    risks.push({
      key: 'hasCriminalRecord',
      description: '该用户有前科',
      detail: '用户存在犯罪前科记录',
      level: '高风险'
    })
  }
  if (riskWarning.isKeyPerson) {
    risks.push({
      key: 'isKeyPerson',
      description: '该用户为重点人员',
      detail: '用户被列为重点监管人员',
      level: '高风险'
    })
  }
  
  // 逾期风险
  if (riskWarning.hitHighRiskBankLastTwoYears) {
    risks.push({
      key: 'hitHighRiskBankLastTwoYears',
      description: '近两年命中银行高风险',
      detail: '近两年在银行机构存在高风险记录',
      level: '高风险'
    })
  }
  if (riskWarning.hitCurrentOverdue) {
    risks.push({
      key: 'hitCurrentOverdue',
      description: '该用户命中当前逾期',
      detail: '用户当前存在逾期记录',
      level: '中风险'
    })
  }
  
  // 借贷评估风险
  if (riskWarning.frequentApplicationRecent) {
    risks.push({
      key: 'frequentApplicationRecent',
      description: '近期申请机构极为频繁',
      detail: '近期在多个机构频繁申请贷款',
      level: '高风险'
    })
  }
  
  return risks
}

const getRiskLevelBadgeClass = (level) => {
  if (level === '高风险') return 'pdf-tag-danger'
  if (level === '中风险') return 'pdf-tag-warning'
  return 'pdf-tag-default'
}

// 逾期相关函数
const getOverdueStatusText = (status) => {
  if (status === '逾期') return '逾期'
  if (status === '未逾期') return '未逾期'
  return '未知'
}

const getOverdueStatusTagClass = (status) => {
  if (status === '逾期') return 'pdf-tag-danger'
  if (status === '未逾期') return 'pdf-tag-success'
  return 'pdf-tag-default'
}

const getOverdueTimeText = (status) => {
  if (status === '逾期') return '逾期'
  if (status === '未逾期') return '正常'
  return '未知'
}

const getOverdueTimeClass = (status) => {
  if (status === '逾期') return 'pdf-time-danger'
  if (status === '未逾期') return 'pdf-time-success'
  return 'pdf-time-default'
}
</script>

<style scoped>
/* PDF 报告容器 - A4 宽度 */
.pdf-report {
  width: 794px; /* A4 宽度 (210mm) */
  max-width: 100%;
  margin: 0 auto;
  background-color: #ffffff;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  color: #333333;
  line-height: 1.6;
  box-sizing: border-box;
}

/* 章节样式 */
.pdf-section {
  margin-bottom: 32px;
  page-break-inside: avoid;
  padding: 0 24px;
}

.pdf-section-title {
  font-size: 20px;
  font-weight: 600;
  color: #1a1a1a;
  margin: 0 0 20px 0;
  padding: 16px 0 12px 0;
  position: relative;
  border-bottom: none;
}

.pdf-section-title::before {
  content: '';
  position: absolute;
  left: -24px;
  top: 16px;
  bottom: 12px;
  width: 4px;
  background: linear-gradient(180deg, #4a90e2 0%, #357abd 100%);
  border-radius: 2px;
}

/* 卡片样式 */
.pdf-card {
  background-color: #ffffff;
  border: 1px solid #e8eaed;
  border-radius: 8px;
  padding: 20px 24px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.2s ease;
}

.pdf-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f0f0f0;
}

.pdf-suggestion-card {
  background: linear-gradient(135deg, #f8f9ff 0%, #f0f4ff 100%);
  border: 1px solid #e0e7ff;
  border-left: 4px solid #4a90e2;
}

/* 标签和值 */
.pdf-label {
  font-size: 15px;
  font-weight: 500;
  color: #1a1a1a;
  letter-spacing: 0.2px;
}

.pdf-value {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.pdf-value-danger {
  color: #e53e3e;
}

.pdf-value-success {
  color: #38a169;
}

.pdf-value-warning {
  color: #d69e2e;
}

/* 标签样式 */
.pdf-tag {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  color: #ffffff;
  letter-spacing: 0.2px;
  line-height: 1.4;
}

.pdf-tag-danger {
  background: linear-gradient(135deg, #fc8181 0%, #e53e3e 100%);
  box-shadow: 0 2px 4px rgba(229, 62, 62, 0.2);
}

.pdf-tag-warning {
  background: linear-gradient(135deg, #f6ad55 0%, #d69e2e 100%);
  box-shadow: 0 2px 4px rgba(214, 158, 46, 0.2);
}

.pdf-tag-success {
  background: linear-gradient(135deg, #68d391 0%, #38a169 100%);
  box-shadow: 0 2px 4px rgba(56, 161, 105, 0.2);
}

.pdf-tag-info {
  background: linear-gradient(135deg, #63b3ed 0%, #3182ce 100%);
  box-shadow: 0 2px 4px rgba(49, 130, 206, 0.2);
}

.pdf-tag-default {
  background: linear-gradient(135deg, #a0aec0 0%, #718096 100%);
  box-shadow: 0 2px 4px rgba(113, 128, 150, 0.2);
}

/* 子标题 */
.pdf-subtitle {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
  margin: 0 0 16px 0;
  padding: 0 0 12px 0;
  border-bottom: 1px solid #f0f0f0;
  position: relative;
}

.pdf-subtitle::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 40px;
  height: 2px;
  background: linear-gradient(90deg, #4a90e2 0%, #357abd 100%);
  border-radius: 1px;
}

.pdf-mini-title {
  font-size: 15px;
  font-weight: 600;
  color: #1a1a1a;
  margin: 20px 0 12px 0;
  padding: 0 0 8px 0;
  border-bottom: 1px solid #f5f5f5;
}

/* 信息表格 */
.pdf-info-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.pdf-info-table tr {
  border-bottom: 1px solid #f5f5f5;
  transition: background-color 0.2s ease;
}

.pdf-info-table tr:hover {
  background-color: #fafafa;
}

.pdf-info-table tr:last-child {
  border-bottom: none;
}

.pdf-info-table td {
  padding: 12px 16px;
  font-size: 14px;
  vertical-align: top;
}

.pdf-info-label {
  color: #666666;
  width: 100px;
  font-weight: 400;
  letter-spacing: 0.1px;
}

.pdf-info-value {
  color: #1a1a1a;
  font-weight: 500;
  letter-spacing: 0.1px;
}

/* 评分网格 */
.pdf-score-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.pdf-score-item {
  padding: 20px;
  border-radius: 8px;
  border: 1px solid #e8eaed;
  position: relative;
  background: #ffffff;
  transition: all 0.2s ease;
}

.pdf-score-item:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.pdf-score-high {
  background: linear-gradient(135deg, #fff5f5 0%, #ffe5e5 100%);
  border-color: #feb2b2;
}

.pdf-score-medium {
  background: linear-gradient(135deg, #fffaf0 0%, #fff5e1 100%);
  border-color: #fbd38d;
}

.pdf-score-low {
  background: linear-gradient(135deg, #f0fff4 0%, #e6ffed 100%);
  border-color: #9ae6b4;
}

.pdf-score-info {
  background: linear-gradient(135deg, #ebf8ff 0%, #d6f0ff 100%);
  border-color: #90cdf4;
}

.pdf-score-default {
  background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
  border-color: #e2e8f0;
}

.pdf-score-label {
  font-size: 13px;
  color: #666666;
  margin-bottom: 10px;
  font-weight: 400;
  letter-spacing: 0.2px;
}

.pdf-score-value {
  font-size: 28px;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.pdf-score-tag {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 4px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  color: #ffffff;
  line-height: 1.3;
}

/* 验证结果 */
.pdf-verification-result {
  padding: 16px;
  border-radius: 6px;
  margin-top: 12px;
  border: 1px solid;
}

.pdf-result-success {
  background: linear-gradient(135deg, #f0fff4 0%, #e6ffed 100%);
  border-color: #9ae6b4;
}

.pdf-result-danger {
  background: linear-gradient(135deg, #fff5f5 0%, #ffe5e5 100%);
  border-color: #feb2b2;
}

.pdf-result-default {
  background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
  border-color: #e2e8f0;
}

.pdf-result-label {
  font-size: 14px;
  color: #1a1a1a;
  margin-bottom: 6px;
  font-weight: 500;
  letter-spacing: 0.1px;
}

.pdf-result-value {
  font-size: 14px;
  color: #1a1a1a;
  margin-bottom: 4px;
  font-weight: 500;
}

.pdf-result-detail {
  font-size: 12px;
  color: #666666;
  margin-top: 6px;
  letter-spacing: 0.1px;
}

/* 风险统计 */
.pdf-risk-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.pdf-stat-item {
  text-align: center;
  padding: 18px 12px;
  background: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
  border-radius: 8px;
  border: 1px solid #e8eaed;
  transition: all 0.2s ease;
}

.pdf-stat-item:hover {
  background: linear-gradient(135deg, #f0f0f0 0%, #e8e8e8 100%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.pdf-stat-value {
  font-size: 26px;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}

.pdf-stat-label {
  font-size: 12px;
  color: #666666;
  letter-spacing: 0.2px;
  line-height: 1.4;
}

/* 风险列表 */
.pdf-risk-list {
  margin-top: 16px;
}

.pdf-risk-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
  border-left: 4px solid #e0e0e0;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.pdf-risk-item:hover {
  background: linear-gradient(135deg, #f0f0f0 0%, #e8e8e8 100%);
  border-left-color: #4a90e2;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.pdf-risk-content {
  flex: 1;
  padding-right: 12px;
}

.pdf-risk-title {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 6px;
  line-height: 1.5;
  letter-spacing: 0.1px;
}

.pdf-risk-detail {
  font-size: 12px;
  color: #666666;
  line-height: 1.5;
  letter-spacing: 0.1px;
}

.pdf-risk-badge {
  padding: 5px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  color: #ffffff;
  margin-left: 12px;
  white-space: nowrap;
  line-height: 1.4;
  flex-shrink: 0;
}

/* 逾期统计 */
.pdf-overdue-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
  margin-top: 15px;
}

/* 时间分布 */
.pdf-time-distribution {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.pdf-time-item {
  text-align: center;
  padding: 16px 12px;
  border-radius: 8px;
  border: 1px solid;
  transition: all 0.2s ease;
}

.pdf-time-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.pdf-time-success {
  background: linear-gradient(135deg, #f0fff4 0%, #e6ffed 100%);
  border-color: #9ae6b4;
}

.pdf-time-danger {
  background: linear-gradient(135deg, #fff5f5 0%, #ffe5e5 100%);
  border-color: #feb2b2;
}

.pdf-time-default {
  background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
  border-color: #e2e8f0;
}

.pdf-time-value {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #1a1a1a;
  letter-spacing: 0.2px;
}

.pdf-time-label {
  font-size: 11px;
  color: #666666;
  letter-spacing: 0.2px;
}

/* 借贷评估 */
.pdf-loan-section {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid #f0f0f0;
}

.pdf-loan-item {
  margin-bottom: 20px;
  padding: 20px;
  background: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
  border-radius: 8px;
  border: 1px solid #e8eaed;
  transition: all 0.2s ease;
}

.pdf-loan-item:hover {
  background: linear-gradient(135deg, #f0f0f0 0%, #e8e8e8 100%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.pdf-loan-type {
  font-size: 15px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e8eaed;
  letter-spacing: 0.2px;
}

.pdf-loan-data {
  margin-top: 12px;
}

.pdf-loan-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f5f5f5;
  transition: background-color 0.2s ease;
}

.pdf-loan-row:hover {
  background-color: rgba(255, 255, 255, 0.5);
  padding-left: 8px;
  padding-right: 8px;
  margin-left: -8px;
  margin-right: -8px;
  border-radius: 4px;
}

.pdf-loan-row:last-child {
  border-bottom: none;
}

.pdf-loan-label {
  font-size: 13px;
  color: #666666;
  letter-spacing: 0.1px;
}

.pdf-loan-value {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a1a;
  letter-spacing: 0.1px;
}

/* 租赁评估 */
.pdf-leasing-section {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid #f0f0f0;
}

.pdf-leasing-data {
  margin-top: 12px;
  padding: 20px;
  background: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
  border-radius: 8px;
  border: 1px solid #e8eaed;
  transition: all 0.2s ease;
}

.pdf-leasing-data:hover {
  background: linear-gradient(135deg, #f0f0f0 0%, #e8e8e8 100%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.pdf-leasing-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #f5f5f5;
  transition: background-color 0.2s ease;
}

.pdf-leasing-row:hover {
  background-color: rgba(255, 255, 255, 0.5);
  padding-left: 8px;
  padding-right: 8px;
  margin-left: -8px;
  margin-right: -8px;
  border-radius: 4px;
}

.pdf-leasing-row:last-child {
  border-bottom: none;
}

.pdf-leasing-label {
  font-size: 13px;
  color: #666666;
  letter-spacing: 0.1px;
}

.pdf-leasing-value {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a1a;
  letter-spacing: 0.1px;
}

/* 关联风险监督 */
.pdf-supervision-header {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #f0f0f0;
}

.pdf-supervision-title {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 6px;
  letter-spacing: 0.2px;
}

.pdf-supervision-time {
  font-size: 12px;
  color: #666666;
  letter-spacing: 0.1px;
}

.pdf-supervision-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.pdf-supervision-item {
  padding: 20px;
  background: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
  border-radius: 8px;
  border: 1px solid #e8eaed;
  text-align: center;
  transition: all 0.2s ease;
}

.pdf-supervision-item:hover {
  background: linear-gradient(135deg, #f0f0f0 0%, #e8e8e8 100%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}

.pdf-supervision-value {
  font-size: 28px;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.pdf-supervision-label {
  font-size: 12px;
  color: #666666;
  letter-spacing: 0.2px;
  line-height: 1.4;
}

/* 打印样式 */
@media print {
  .pdf-report {
    width: 100%;
    padding: 0;
    box-shadow: none;
  }
  
  .pdf-section {
    page-break-inside: avoid;
    margin-bottom: 24px;
    padding: 0 20px;
  }
  
  .pdf-card {
    page-break-inside: avoid;
    box-shadow: none;
    border: 1px solid #e0e0e0;
  }
  
  .pdf-score-item:hover,
  .pdf-stat-item:hover,
  .pdf-risk-item:hover,
  .pdf-time-item:hover {
    transform: none;
    box-shadow: none;
  }
}
</style>
