/* 
 * BIDERSS 用户故事可视化系统 - 主样式表 v2.0
 * 专业咨询级设计风格 + 科学可视化标准
 * 遵循 Tufte 数据可视化原则
 */

/* ==================== 色彩系统 ==================== */
:root {
    /* 基础色 */
    --primary: #1a365d;
    --primary-light: #2c5282;
    --secondary: #2171b5;
    --accent: #e65100;
    
    /* 语义色 - ColorBrewer优化 */
    --success: #31a354;
    --warning: #f59e0b;
    --danger: #dc2626;
    --info: #0284c7;
    
    /* 中性色 */
    --light: #f8fafc;
    --dark: #0f172a;
    --gray-900: #1e293b;
    --gray-700: #334155;
    --gray-500: #64748b;
    --gray-400: #94a3b8;
    --gray-300: #cbd5e1;
    --gray-200: #e2e8f0;
    --gray-100: #f1f5f9;
    
    /* 兼容旧变量 */
    --gray: var(--gray-500);
    --gray-light: var(--gray-200);
    
    /* 数据可视化色板 - ColorBrewer Paired */
    --data-1: #1f78b4;
    --data-2: #33a02c;
    --data-3: #e31a1c;
    --data-4: #ff7f00;
    --data-5: #6a3d9a;
    --data-6: #b15928;
    
    /* 品牌专属色 */
    --brand-skinceuticals: #0066cc;
    --brand-estee: #1e3a5f;
    --brand-lancome: #c8a55f;
    --brand-hr: #8b0000;
    
    /* 人群细分色 - ColorBrewer Set2 */
    --segment-1: #66c2a5;
    --segment-2: #fc8d62;
    --segment-3: #8da0cb;
    --segment-4: #e78ac3;
    --segment-5: #a6d854;
    --segment-6: #ffd92f;
    
    /* 布局 */
    --sidebar-width: 260px;
    --sidebar-collapsed: 60px;
    --header-height: 80px;
    --content-max-width: 1400px;
    
    /* 阴影 */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1);
    
    /* 圆角 */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    /* 过渡 */
    --transition: all 0.2s ease;
    --transition-slow: all 0.3s ease;
}

/* ==================== 基础重置 ==================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--light);
    color: var(--gray-900);
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==================== 侧边导航 ==================== */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--primary) 0%, var(--gray-900) 100%);
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
    transition: var(--transition);
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
}

.logo {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    text-align: center;
    position: sticky;
    top: 0;
    background: inherit;
    z-index: 10;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--accent);
}

.logo p {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 4px;
}

/* 版本切换器 */
.version-switcher {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(0,0,0,0.2);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.version-btn {
    flex: 1;
    padding: 10px 0;
    text-align: center;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.8rem;
    transition: all 0.25s ease;
    border: 1px solid transparent;
}

.version-btn:not(.active) {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.6);
}

.version-btn:not(.active):hover {
    background: rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.9);
    border-color: rgba(255,255,255,0.2);
}

.version-btn.active {
    background: linear-gradient(135deg, #2171b5 0%, #1a365d 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(33, 113, 181, 0.4);
}

.version-btn.v2 {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.15) 0%, rgba(20, 184, 166, 0.15) 100%);
    border-color: rgba(6, 182, 212, 0.3);
    color: #06b6d4;
}

.version-btn.v2:hover {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.25) 0%, rgba(20, 184, 166, 0.25) 100%);
    border-color: rgba(6, 182, 212, 0.5);
    color: #22d3ee;
}

/* 导航滚动容器 */
.nav-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 20px;
}

.nav-scroll::-webkit-scrollbar {
    width: 4px;
}

.nav-scroll::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
}

.nav-scroll::-webkit-scrollbar-track {
    background: transparent;
}

/* 导航分类 */
.nav-category {
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.nav-category:last-child {
    border-bottom: none;
}

.nav-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.nav-category-header:hover {
    background: rgba(255,255,255,0.05);
}

.nav-category-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(255,255,255,0.9);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-category-title .icon {
    font-size: 1em;
    width: 20px;
    text-align: center;
}

.nav-category-arrow {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.5);
    transition: transform 0.2s ease;
}

.nav-category.collapsed .nav-category-arrow {
    transform: rotate(-90deg);
}

.nav-category.collapsed .nav-category-content {
    display: none;
}

.nav-category-content {
    padding: 0 8px 8px;
}

/* 导航分组 */
.nav-section {
    padding: 8px 4px;
}

.nav-section h3 {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.4;
    margin-bottom: 6px;
    padding-left: 12px;
    font-weight: 500;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
    font-size: 0.82rem;
    transition: var(--transition);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-item .nav-icon {
    font-size: 0.9em;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.nav-item.active {
    background: var(--secondary);
    color: white;
    font-weight: 500;
}

/* 导航标签 */
.nav-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 8px;
    background: rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.8);
    margin-left: auto;
}

.nav-badge.new {
    background: #10b981;
    color: white;
}

/* ==================== 主内容区 ==================== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 24px 32px;
    min-height: 100vh;
    max-width: calc(100vw - var(--sidebar-width));
    overflow-x: hidden;
}

.content-wrapper {
    max-width: var(--content-max-width);
    margin: 0 auto;
}

/* ==================== 页面头部 ==================== */
.page-header {
    margin-bottom: 32px;
}

.page-header h1 {
    font-size: 1.75rem;
    color: var(--primary);
    font-weight: 600;
    line-height: 1.3;
}

.page-header .subtitle {
    color: var(--gray-500);
    margin-top: 8px;
    font-size: 0.95rem;
}

/* ==================== 指标卡片 ==================== */
.metrics-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.metric-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    border: 1px solid var(--gray-200);
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.metric-icon {
    font-size: 1.75rem;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--gray-100);
    flex-shrink: 0;
}

.metric-card.primary .metric-icon { background: rgba(33, 113, 181, 0.1); }
.metric-card.success .metric-icon { background: rgba(49, 163, 84, 0.1); }
.metric-card.warning .metric-icon { background: rgba(245, 158, 11, 0.1); }
.metric-card.info .metric-icon { background: rgba(26, 54, 93, 0.1); }

.metric-info {
    min-width: 0;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

.metric-card.primary .metric-value { color: var(--secondary); }
.metric-card.success .metric-value { color: var(--success); }
.metric-card.warning .metric-value { color: var(--warning); }
.metric-card.info .metric-value { color: var(--primary); }

.metric-label {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 2px;
}

.metric-change {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 10px;
    margin-top: 4px;
    display: inline-block;
}

.metric-change.positive {
    background: rgba(49, 163, 84, 0.1);
    color: var(--success);
}

.metric-change.negative {
    background: rgba(220, 38, 38, 0.1);
    color: var(--danger);
}

/* ==================== 卡片网格 ==================== */
.nav-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.nav-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    text-decoration: none;
    color: var(--dark);
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    border: 1px solid var(--gray-200);
    min-width: 0;
}

.nav-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--secondary);
}

.nav-card.featured {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    border: none;
}

.nav-card.featured h3 { color: white; }
.nav-card.featured p { opacity: 0.9; }

.nav-card.role {
    border-left: 4px solid var(--accent);
}

.card-icon {
    font-size: 2rem;
    margin-bottom: 12px;
}

.nav-card h3 {
    font-size: 1.1rem;
    color: var(--primary);
    margin-bottom: 8px;
    font-weight: 600;
}

.nav-card p {
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-bottom: 12px;
    line-height: 1.5;
}

.card-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.tag {
    padding: 4px 10px;
    background: var(--gray-100);
    border-radius: 12px;
    font-size: 0.7rem;
    color: var(--gray-500);
    font-weight: 500;
}

.nav-card.featured .tag {
    background: rgba(255,255,255,0.2);
    color: white;
}

/* ==================== 图表区域 ==================== */
.charts-section {
    margin-bottom: 32px;
}

.charts-section h2 {
    color: var(--primary);
    margin-bottom: 20px;
    font-size: 1.25rem;
    font-weight: 600;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

.chart-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-200);
}

.chart-card h3 {
    font-size: 0.95rem;
    color: var(--primary);
    margin-bottom: 16px;
    font-weight: 600;
}

.chart-container {
    height: 280px;
    position: relative;
    width: 100%;
}

/* 图表注释 */
.chart-annotation {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-200);
}

.chart-annotation .sample-size {
    color: var(--gray-700);
    font-weight: 500;
}

/* ==================== 响应式表格 ==================== */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -24px;
    padding: 0 24px;
}

.matrix-table {
    width: 100%;
    min-width: 600px;
    border-collapse: separate;
    border-spacing: 2px;
    font-size: 0.875rem;
}

.matrix-table th {
    background: var(--primary);
    color: white;
    padding: 12px 10px;
    text-align: center;
    font-weight: 500;
    font-size: 0.8rem;
    white-space: nowrap;
}

.matrix-table td {
    padding: 10px 8px;
    text-align: center;
    background: var(--gray-100);
    transition: var(--transition);
}

.matrix-table tr:hover td {
    background: var(--gray-200);
}

.matrix-table .segment-cell {
    background: var(--secondary);
    color: white;
    font-weight: 500;
    text-align: left;
    padding-left: 12px;
    white-space: nowrap;
}

/* 热力图色阶 */
.cell-high, .score-high {
    background: #c6f6d5 !important;
    color: #166534;
    font-weight: 600;
}

.cell-medium, .score-medium {
    background: #fef3c7 !important;
    color: #92400e;
}

.cell-low, .score-low {
    background: #fecaca !important;
    color: #991b1b;
}

/* ==================== 用户故事时间线 ==================== */
.story-timeline {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    overflow-x: auto;
    padding: 20px;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    -webkit-overflow-scrolling: touch;
}

.timeline-stage {
    flex: 0 0 140px;
    text-align: center;
    padding: 16px 12px;
    border-radius: var(--radius-md);
    background: var(--gray-100);
    transition: var(--transition);
    cursor: pointer;
}

.timeline-stage:hover {
    background: var(--secondary);
    color: white;
    transform: translateY(-4px);
}

.timeline-stage:hover h4,
.timeline-stage:hover p {
    color: white;
}

.stage-icon {
    font-size: 1.75rem;
    margin-bottom: 8px;
    transition: var(--transition);
}

.timeline-stage:hover .stage-icon {
    transform: scale(1.1);
}

.timeline-stage h4 {
    font-size: 0.85rem;
    color: var(--primary);
    margin-bottom: 4px;
    font-weight: 600;
}

.timeline-stage p {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-bottom: 8px;
}

.timeline-arrow {
    display: flex;
    align-items: center;
    font-size: 1.25rem;
    color: var(--gray-400);
    padding-top: 24px;
    flex-shrink: 0;
}

/* ==================== 统计标注 ==================== */
.stat-annotation {
    display: flex;
    gap: 16px;
    padding: 12px 16px;
    background: var(--gray-100);
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    color: var(--gray-700);
    margin-top: 16px;
}

.stat-annotation .stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-annotation .stat-label {
    color: var(--gray-500);
}

.stat-annotation .stat-value {
    font-weight: 600;
    color: var(--primary);
}

/* 置信区间标记 */
.confidence-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: rgba(33, 113, 181, 0.1);
    color: var(--secondary);
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 500;
}

.confidence-badge::before {
    content: '✓';
}

/* ==================== 发散条形图样式 ==================== */
.diverging-bar {
    display: flex;
    align-items: center;
    height: 40px;
    margin: 12px 0;
}

.diverging-bar .bar-negative {
    background: var(--danger);
    height: 28px;
    border-radius: 4px 0 0 4px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
}

.diverging-bar .bar-center {
    width: 2px;
    height: 100%;
    background: var(--gray-400);
}

.diverging-bar .bar-positive {
    background: var(--success);
    height: 28px;
    border-radius: 0 4px 4px 0;
    display: flex;
    align-items: center;
    padding-left: 8px;
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
}

.diverging-bar .bar-neutral {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: var(--gray-500);
    top: -16px;
}

/* ==================== 棒棒糖图样式 ==================== */
.lollipop-chart {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.lollipop-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.lollipop-label {
    width: 80px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-700);
    text-align: right;
    flex-shrink: 0;
}

.lollipop-bar {
    flex: 1;
    height: 2px;
    background: var(--gray-300);
    position: relative;
}

.lollipop-fill {
    height: 2px;
    background: var(--secondary);
    position: absolute;
    left: 0;
    top: 0;
}

.lollipop-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--secondary);
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: -6px;
}

.lollipop-value {
    width: 60px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    flex-shrink: 0;
}

/* ==================== 热力图样式 ==================== */
.heatmap-container {
    overflow-x: auto;
}

.heatmap-table {
    border-collapse: collapse;
    width: 100%;
}

.heatmap-table th,
.heatmap-table td {
    padding: 8px 12px;
    text-align: center;
    font-size: 0.8rem;
}

.heatmap-table th {
    background: var(--gray-100);
    font-weight: 600;
    color: var(--gray-700);
}

.heatmap-table .row-header {
    text-align: left;
    font-weight: 500;
    background: var(--gray-50);
}

/* 热力图色阶 - 9级 */
.heat-1 { background: #f7fbff; color: #08306b; }
.heat-2 { background: #deebf7; color: #08306b; }
.heat-3 { background: #c6dbef; color: #08306b; }
.heat-4 { background: #9ecae1; color: #08306b; }
.heat-5 { background: #6baed6; color: white; }
.heat-6 { background: #4292c6; color: white; }
.heat-7 { background: #2171b5; color: white; }
.heat-8 { background: #08519c; color: white; }
.heat-9 { background: #08306b; color: white; }

/* ==================== 动画 ==================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

.animate-fade-in {
    animation: fadeInUp 0.4s ease forwards;
}

.metric-card {
    animation: fadeInUp 0.4s ease forwards;
}

.metric-card:nth-child(1) { animation-delay: 0.05s; }
.metric-card:nth-child(2) { animation-delay: 0.1s; }
.metric-card:nth-child(3) { animation-delay: 0.15s; }
.metric-card:nth-child(4) { animation-delay: 0.2s; }

/* ==================== 响应式设计 ==================== */
@media (max-width: 1280px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1024px) {
    :root {
        --sidebar-width: 220px;
    }
    
    .main-content {
        padding: 20px 24px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        max-width: 100vw;
        padding: 16px;
    }
    
    .metrics-section {
        grid-template-columns: 1fr 1fr;
    }
    
    .nav-grid {
        grid-template-columns: 1fr;
    }
    
    .nav-card.featured {
        grid-column: 1;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .metrics-section {
        grid-template-columns: 1fr;
    }
    
    .metric-card {
        padding: 16px;
    }
    
    .page-header h1 {
        font-size: 1.5rem;
    }
}

/* ==================== 打印样式 ==================== */
@media print {
    .sidebar {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0;
        max-width: 100%;
        padding: 20px;
    }
    
    .nav-card:hover,
    .metric-card:hover {
        transform: none;
        box-shadow: var(--shadow-md);
    }
    
    .chart-container {
        page-break-inside: avoid;
    }
}

/* ==================== 无障碍优化 ==================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 焦点样式 */
a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--secondary);
    outline-offset: 2px;
}

/* 高对比度模式 */
@media (prefers-contrast: high) {
    :root {
        --primary: #000;
        --secondary: #0000cc;
        --gray-500: #333;
    }
    
    .nav-card,
    .metric-card,
    .chart-card {
        border: 2px solid var(--gray-900);
    }
}

/* ==================== 统计标注组件 ==================== */
.stat-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 16px;
    background: var(--gray-100);
    border-radius: var(--radius-md);
    margin-top: 20px;
    font-size: 0.8rem;
}

.stat-footer .stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat-footer .stat-label {
    color: var(--gray-500);
}

.stat-footer .stat-value {
    font-weight: 600;
    color: var(--primary);
}

.stat-sig {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    background: rgba(49, 163, 84, 0.1);
    color: var(--success);
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
}

.stat-sig.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.stat-sig.danger {
    background: rgba(220, 38, 38, 0.1);
    color: var(--danger);
}

/* ==================== 发散条形图组件 ==================== */
.diverging-container {
    padding: 20px;
    background: var(--gray-100);
    border-radius: var(--radius-md);
}

.diverging-row {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px;
}

.diverging-label {
    width: 60px;
    text-align: right;
    font-size: 0.85rem;
    color: var(--gray-500);
}

.diverging-bar-container {
    flex: 1;
    display: flex;
    align-items: center;
    height: 28px;
}

.diverging-negative {
    background: var(--danger);
    height: 100%;
    border-radius: 4px 0 0 4px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    transition: width 0.5s ease;
}

.diverging-center {
    width: 2px;
    height: 100%;
    background: var(--gray-400);
}

.diverging-positive {
    background: var(--success);
    height: 100%;
    border-radius: 0 4px 4px 0;
    display: flex;
    align-items: center;
    padding-left: 8px;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    transition: width 0.5s ease;
}

.diverging-end-label {
    width: 60px;
    font-size: 0.85rem;
    color: var(--gray-500);
}

/* ==================== 数据表格增强 ==================== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.data-table th {
    background: var(--gray-100);
    font-weight: 600;
    color: var(--primary);
}

.data-table tbody tr:hover {
    background: var(--gray-50, #fafafa);
}

.data-table .numeric {
    text-align: right;
    font-feature-settings: 'tnum';
}

.data-table .highlight {
    background: rgba(33, 113, 181, 0.1);
}

/* ==================== 图表图例优化 ==================== */
.legend-container {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 16px;
    background: var(--gray-50, #fafafa);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--gray-700);
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-line {
    width: 24px;
    height: 3px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* ==================== 响应式辅助类 ==================== */
@media (max-width: 768px) {
    .stat-footer {
        flex-direction: column;
        gap: 12px;
    }
    
    .diverging-label,
    .diverging-end-label {
        width: 40px;
        font-size: 0.75rem;
    }
    
    .legend-container {
        flex-direction: column;
        gap: 8px;
    }
}

/* ==================== 数据钻取交互组件 ==================== */
.drilldown-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.drilldown-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.drilldown-content {
    background: white;
    border-radius: var(--radius-lg);
    max-width: 800px;
    max-height: 80vh;
    width: 90%;
    overflow: hidden;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translateY(20px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

.drilldown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50, #fafafa);
}

.drilldown-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary);
}

.drilldown-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--gray-200);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--gray-700);
    transition: var(--transition);
}

.drilldown-close:hover {
    background: var(--gray-300);
}

.drilldown-body {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(80vh - 80px);
}

.drilldown-section {
    margin-bottom: 24px;
}

.drilldown-section:last-child {
    margin-bottom: 0;
}

.drilldown-section h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.drilldown-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
}

.drilldown-metric {
    background: var(--gray-100);
    padding: 16px;
    border-radius: var(--radius-md);
    text-align: center;
}

.drilldown-metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.drilldown-metric-label {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 4px;
}

.drilldown-quotes {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.drilldown-quote {
    background: var(--gray-100);
    padding: 16px;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--secondary);
    font-size: 0.9rem;
    color: var(--gray-700);
    line-height: 1.6;
}

.drilldown-quote-source {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 8px;
}

/* 可点击数据点样式 */
.data-point-clickable {
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.data-point-clickable:hover {
    transform: scale(1.05);
}

.data-point-clickable::after {
    content: '点击查看详情';
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-900);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.data-point-clickable:hover::after {
    opacity: 1;
}

/* ==================== 筛选器组件 ==================== */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 16px 24px;
    background: var(--gray-100);
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    align-items: center;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-700);
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--gray-700);
    background: white;
    cursor: pointer;
    transition: var(--transition);
}

.filter-select:hover {
    border-color: var(--secondary);
}

.filter-select:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(33, 113, 181, 0.1);
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--secondary);
    color: white;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.filter-chip-remove {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.7rem;
}

.filter-chip-remove:hover {
    background: rgba(255, 255, 255, 0.5);
}

.filter-reset {
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--gray-600);
    cursor: pointer;
    transition: var(--transition);
}

.filter-reset:hover {
    background: var(--gray-200);
}
