/* --- 核心变量与基础定义 --- */
:root {
    --brand-orange: #ff9800;
    --brand-green: #4caf50;
    --brand-blue: #2196f3;
    --text-dark: #2c3e50;
    --text-muted: #7f8c8d;
    --bg-body: #f4f7fa;
    --card-bg: #ffffff;
    --border-soft: #edf2f7;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* 状态颜色定义 */
    --status-success: #4caf50; /* 绿 */
    --status-info: #2196f3;    /* 蓝 */
    --status-warning: #ff9800; /* 橙 */
    --status-danger: #ef4444;  /* 红 */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg-body);
    color: var(--text-dark);
    line-height: 1.6;
    -webkit-tap-highlight-color: transparent;
}

a { text-decoration: none; transition: var(--transition); color: var(--brand-green); }
a:hover { opacity: 0.8; }

/* 固定页头 */
.head-mobile {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: #fff;
    padding: 15px;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    border-bottom: 1px solid #eee;
}

/* 主容器 */
.container {
    max-width: 1200px; /* PC端宽屏显示 */
    margin: 0 auto;
    padding: 20px 50px 20px 20px;
    padding-top: 80px; /* 为固定头部留出空间 */
}

/* --- 顶部 Header --- */
.page-header { margin-bottom: 30px; display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 15px; }
.page-header h1 { font-size: 30px; font-weight: 800; color: var(--text-dark); }
.page-header p { color: var(--text-muted); font-size: 14px; }

/* --- 1. Hero-Section 布局 --- */
.hero-section { display: flex; gap: 20px; margin-bottom: 25px; flex-wrap: wrap; }

.hero-card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    border: 1px solid var(--border-soft);
}
small { color: #888;}

/* 左侧车型信息 */
.hero-info { flex: 1; padding: 20px 24px; min-width: 320px; }
.hero-info-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; border-bottom: 1px solid var(--border-soft); padding-bottom: 12px; }
.hero-info-header h1 { font-size: 20px; font-weight: 800; color: var(--text-dark); }
.hero-tag { font-size: 11px; background: #e8f5e9; color: var(--brand-green); padding: 2px 8px; border-radius: 4px; font-weight: bold; }
.hero-specs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 20px; }
.spec-item { display: flex; align-items: baseline; font-size: 13px; }
.spec-item label { color: var(--text-muted); width: 65px; flex-shrink: 0; }
.spec-item span { color: var(--text-dark); font-weight: 600; }

/* 右侧核心数据卡片 */
.hero-data { flex: 1.6; min-width: 450px; padding: 25px 30px; display: flex; flex-direction: column; }
.data-top { display: flex; justify-content: space-between; align-items: flex-end; padding-bottom: 20px; }
.data-item { flex: 1; }
.data-item label { display: block; font-size: 13px; color: var(--text-muted); font-weight: 600; margin-bottom: 8px; }
.main-num { font-size: 36px; font-weight: 800; color: var(--text-dark); line-height: 1; letter-spacing: -1px; }
.main-num small { font-size: 14px; font-weight: bold; color: #94a3b8; margin-left: 4px; }
.main-num.fuel-color { color: var(--brand-green); }

.data-divider { height: 1px; background: var(--border-soft); width: 100%; margin-bottom: 20px; }

.data-bottom { display: flex; justify-content: space-between; }
.sub-column { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.sub-row { font-size: 13px; color: var(--text-muted); }
.sub-row b { color: var(--text-dark); font-weight: 700; }

/* --- 2. 可视化图表 --- */
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 25px; }
.chart-card { background: var(--card-bg); border-radius: 12px; padding: 20px; border: 1px solid var(--border-soft); }
.chart-card h4 { font-size: 14px; margin-bottom: 15px; color: var(--text-dark); font-weight: 700; border-left: 3px solid var(--brand-blue); padding-left: 10px; }

.main-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.main-table th { text-align: left; padding: 10px; color: var(--text-muted); border-bottom: 1px solid var(--border-soft); }
.main-table td { padding: 12px 10px; border-bottom: 1px solid #f8f9fa; }
.main-table tr.highlight td { background: #f0fdf4; color: var(--brand-green); font-weight: 800; }

/* --- 3. 横向排名 --- */
.range-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 25px; }
.range-card { background: var(--card-bg); padding: 10px 20px; border-radius: 12px; border: 1px solid var(--border-soft); }
.panel { border: none; -webkit-box-shadow: none; box-shadow: none;}
.panel-default>.panel-heading { background: var(--card-bg); padding: 10px 0; border: none;}

/* --- 4. 相关车型推荐 --- */
.related-card { background: var(--card-bg); border-radius: 12px; padding: 24px; margin-bottom: 25px; border: 1px solid var(--border-soft); }
.related-card h4 { font-size: 15px; font-weight: 800; color: var(--text-dark); margin-bottom: 15px; }
.related-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.related-item {
    background: #fff; border: 1px solid #edf2f7; padding: 12px; border-radius: 8px;
    text-align: center; color: var(--text-dark); font-weight: 600; font-size: 14px;
}
.related-item:hover { border-color: var(--brand-green); background: #f0fdf4; color: var(--brand-green); }

/* --- 5. 页脚说明 --- */
.info-box { background: #fffdf0; border: 1px solid #f9e6a0; border-radius: 12px; padding: 20px; font-size: 13px; color: #856404; margin-bottom: 30px; }
footer { text-align: center; color: #94a3b8; font-size: 12px; padding: 20px 0; border-top: 1px solid #eee; }

.metric-list {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 12px; /* 卡片间距 */
}

/* --- 单个卡片样式 --- */
.car-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 16px 20px;
    border: 1px solid var(--border-soft);
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.car-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.06);
    border-color: var(--brand-green);
}

/* 标题与标签 */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.car-name {
    color: var(--text-dark);
    font-size: 16px;
    font-weight: 700;
    text-decoration: none;
    line-height: 1.4;
    flex: 1;
}

.car-name:hover { color: var(--brand-green); }

.user-tag {
    background: #f0fdf4;
    color: var(--brand-green);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 600;
    white-space: nowrap;
    margin-left: 10px;
    border: 1px solid #dcfce7;
}

/* 核心指标可视化 */
.card-body {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
}

.metric-group {
    flex: 1;
    min-width: 200px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.metric-label {
    font-size: 12px;
    text-align: right;
    color: var(--text-muted);
    width: 50px;
    font-weight: 500;
}

/* --- 进度条组件 --- */
.progress-container {
    flex: 1;
    height: 18px;
    background: #f0f2f5;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    display: flex;
    align-items: center;
    padding-left: 10px;
    font-size: 11px;
    color: #fff;
    font-weight: 700;
    transition: width 0.8s ease-out;
}

.fill-fuel { background: linear-gradient(90deg, var(--brand-green), #86efac); }
.fill-weight { background: linear-gradient(90deg, var(--brand-blue), #60a5fa); }
/* 状态类映射 */
.fill-success { background: linear-gradient(90deg, var(--status-success), #86efac); }
.fill-info { background: linear-gradient(90deg, var(--status-info), #60a5fa); }
.fill-warning { background: linear-gradient(90deg, var(--status-warning), #fcd34d); }
.fill-danger { background: linear-gradient(90deg, var(--status-danger), #fca5a5); }

/* --- 响应式手机端 --- */
@media (max-width: 768px) {
    /* 主容器 */
    .container {
        padding: 160px 10px 10px 10px; /* 为固定头部留出空间 */
    }
    .hero-section { flex-direction: column; gap: 15px; }

    .hero-info { min-width: 100%; text-align: center; padding: 20px; }
    .hero-info-header { justify-content: center; gap: 10px; }
    .hero-specs { grid-template-columns: 1fr; gap: 8px; justify-items: center; }
    .spec-item { justify-content: center; }

    .hero-data { min-width: 100%; padding: 20px; text-align: center; }
    .data-top { flex-direction: column; align-items: center; gap: 15px; text-align: center; }
    .data-item { width: 100%; text-align: center !important; }
    .data-divider { margin: 15px 0; }
    .data-bottom { flex-direction: column; align-items: center; gap: 12px; text-align: center; }
    .sub-column { width: 100%; text-align: center !important; }
    .main-num { font-size: 32px; }

    .charts-row { grid-template-columns: 1fr; gap: 15px; }

    .related-grid { grid-template-columns: repeat(2, 1fr); }

    .card-body { gap: 10px; }
    .metric-group { min-width: 100%; }
    .car-name { font-size: 15px; }
}

@keyframes slideDown { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }

/* 所有的非移动设备 */
@media screen and (min-device-width: 640px) {
    #container_cspt_distribution_chart {
        height: 300px;
    }

    #container_avg_cspt_trend_chart {
        min-height: 300px;
    }
}

/* iPhone4/4s */
@media screen and (max-height: 480px) {
    #container_avg_cspt_trend_chart {
        margin-top: 10px;
    }
}

@media screen and (min-height: 481px) and (max-height: 568px) {
    #container_avg_cspt_trend_chart {
        margin-top: 15px;
    }
}

/* iPhone 6 */
@media screen and (min-height: 569px) and (max-height: 667px) {
    #container_avg_cspt_trend_chart {
        margin-top: 20px;
    }
}

/* iPhone 6 plus */
@media screen and (min-height: 668px) {
    #container_avg_cspt_trend_chart {
        margin-top: 25px;
    }
}