:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --dark: #1f2937;
    --light: #f8fafc;
    --gray: #6b7280;
    --border: #e5e7eb;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #334155;
    line-height: 1.5;
}

/* 暗色主题背景与基础颜色 */
body.theme-dark {
    background: linear-gradient(135deg, #0f172a 0%, #1f2937 100%);
    color: #e5e7eb;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 15px;
}

/* 头部样式 */
.header {
    text-align: center;
    margin-bottom: 25px;
    color: white;
}

.header-content {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 20px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(45deg, #fff, #e0f2fe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header p {
    font-size: 1rem;
    opacity: 0.9;
    margin-bottom: 15px;
}

/* 控制按钮 */
.controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 18px;
    border: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
}

.btn-outline {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 暗色主题下的卡片与边框微调 */
body.theme-dark .stat-card,
body.theme-dark .fund-card,
body.theme-dark .channel-stat-card,
body.theme-dark .content {
    background: #111827;
    border-color: rgba(255, 255, 255, 0.08);
    color: #e5e7eb;
}
body.theme-dark .stat-label { opacity: 0.85; }
body.theme-dark .last-update { color: #e5e7eb; }

/* 统计面板样式 */
.stats-panel {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 25px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
}

.stats-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
}

.stats-title {
    font-size: 1.3rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.stat-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 5px;
    background: linear-gradient(45deg, #fff, #e0f2fe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-label {
    font-size: 0.85rem;
    opacity: 0.9;
}

.stats-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.stats-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
}

.recent-visits {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.visit-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.85rem;
}

.visit-item:last-child {
    border-bottom: none;
}

.visit-ip {
    font-family: 'Monaco', 'Consolas', monospace;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

.visit-time {
    opacity: 0.8;
}

/* 仪表盘样式 */
.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 25px;
}

.stat-card {
    background: white;
    padding: 20px 15px;
    border-radius: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    text-align: center;
    transition: all 0.3s ease;
    border: 1px solid var(--border);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.stat-icon {
    font-size: 1.8rem;
    margin-bottom: 10px;
    opacity: 0.8;
}

.stat-number {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 5px;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--gray);
    font-weight: 600;
}

.stat-subtext {
    font-size: 0.75rem;
    color: var(--gray);
    margin-top: 4px;
    opacity: 0.7;
}

/* 特殊卡片样式 */
.total-funds .stat-number { color: var(--info); }
.up-funds .stat-number { color: var(--danger); }
.down-funds .stat-number { color: var(--success); }
.avg-change .stat-number { color: var(--warning); }
.total-investment .stat-number { color: var(--primary); }

.total-profit .stat-number {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.profit-badge, .loss-badge {
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.profit-badge {
    background: linear-gradient(135deg, var(--success), #059669);
}

.loss-badge {
    background: linear-gradient(135deg, var(--danger), #dc2626);
}

/* 渠道统计 */
.channel-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 25px;
}

.channel-stat-card {
    background: white;
    padding: 18px;
    border-radius: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    border-left: 4px solid;
}

.channel-stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.channel-stat-card.cmb { border-left-color: #e74c3c; }
.channel-stat-card.tt { border-left-color: #3498db; }
.channel-stat-card.zfb { border-left-color: #27ae60; }

.channel-header {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.channel-icon {
    font-size: 1.5rem;
    margin-right: 10px;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.channel-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--dark);
}

.channel-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 15px;
}

.channel-detail-item {
    text-align: center;
    padding: 8px;
    background: #f8fafc;
    border-radius: 8px;
}

.channel-detail-label {
    font-size: 0.75rem;
    color: var(--gray);
    margin-bottom: 4px;
    font-weight: 600;
}

.channel-detail-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--dark);
}

.channel-profit-section {
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    margin-top: 8px;
}

.profit-positive {
    background: linear-gradient(135deg, #dcfce7, #bbf7d0);
    color: #166534;
}

.profit-negative {
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    color: #dc2626;
}

/* 基金卡片网格 */
.funds-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    margin-bottom: 25px;
}

.fund-card {
    background: white;
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    border-left: 4px solid var(--info);
}

.fund-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.fund-card.positive {
    border-left-color: var(--danger);
    background: linear-gradient(135deg, #fff, #fef2f2);
}

.fund-card.negative {
    border-left-color: var(--success);
    background: linear-gradient(135deg, #fff, #f0fdf4);
}

.fund-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.fund-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--dark);
    flex: 1;
    line-height: 1.3;
}

.fund-code {
    background: #eef2ff;
    padding: 4px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
    color: var(--primary);
    font-weight: 600;
    font-family: 'Monaco', 'Consolas', monospace;
}

.fund-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.detail-item {
    text-align: center;
    padding: 10px;
    background: #f8fafc;
    border-radius: 8px;
}

.detail-label {
    font-size: 0.75rem;
    color: var(--gray);
    margin-bottom: 4px;
    font-weight: 600;
}

.detail-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--dark);
}

/* 昨天涨幅显示样式 */
.yesterday-change {
    font-weight: 800;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.change-display {
    text-align: center;
    padding: 10px;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 12px;
}

.change-positive {
    background: linear-gradient(135deg, #fef2f2, #fee2e2);
    color: var(--danger);
}

.change-negative {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    color: var(--success);
}

.change-icon {
    font-size: 1rem;
    margin-right: 5px;
}

.profit-section {
    background: #f8fafc;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 12px;
}

.profit-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.profit-row:last-child {
    margin-bottom: 0;
    padding-top: 6px;
    border-top: 1px solid var(--border);
    font-weight: 800;
}

.profit-label {
    color: var(--gray);
    font-weight: 600;
}

.profit-value {
    font-weight: 700;
}

.profit-positive {
    color: var(--danger);
}

.profit-negative {
    color: var(--success);
}

.channel-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.channel-badge {
    padding: 5px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    color: red;
    display: flex;
    align-items: center;
    gap: 4px;
}

.channel-cmb {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.channel-tt {
    background: linear-gradient(135deg, #3498db, #2980b9);
}

.channel-zfb {
    background: linear-gradient(135deg, #27ae60, #229954);
}

.update-time {
    font-size: 0.75rem;
    color: var(--gray);
    font-weight: 600;
}

.rank-badge {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
    margin-left: 6px;
}

.buy-hint {
    font-size: 0.75rem;
    color: #000000;
    margin-top: 8px;
    padding: 8px;
    background: #f8fafc;
    border-radius: 6px;
    border-left: 3px solid var(--warning);
}

/* 错误信息 */
.error-section {
    background: linear-gradient(135deg, #fef3c7, #fef3c7);
    border: 1px solid #f59e0b;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
}

.error-section h3 {
    color: #92400e;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 1rem;
}

.error-list {
    list-style: none;
}

.error-list li {
    padding: 4px 0;
    color: #92400e;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
}

/* 页脚 */
.footer {
    text-align: center;
    color: white;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
}

.last-update {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 12px;
    font-size: 0.9rem;
}

/* 动画 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fund-card, .stat-card, .channel-stat-card {
    animation: fadeInUp 0.4s ease-out forwards;
    opacity: 0;
}

/* 加载状态 */
.loading {
    text-align: center;
    padding: 40px;
    color: white;
    font-size: 1.2rem;
}

.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 遵循系统减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .header h1 {
        font-size: 1.8rem;
    }

    .dashboard {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .channel-dashboard {
        grid-template-columns: 1fr;
    }

    .funds-grid {
        grid-template-columns: 1fr;
    }

    .fund-details {
        grid-template-columns: 1fr;
    }

    .channel-details {
        grid-template-columns: 1fr;
    }

    .controls {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .channel-info {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }

    .profit-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stats-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .dashboard {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        padding: 15px 10px;
    }
    
    .fund-card {
        padding: 15px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}
/* 昨日涨幅样式 */
.yesterday-change {
    font-weight: 700;
    font-size: 0.9rem;
}

.yesterday-change.profit-positive {
    color: var(--danger);
    font-weight: 800;
}

.yesterday-change.profit-negative {
    color: var(--success);
    font-weight: 800;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .fund-details {
        grid-template-columns: 1fr;
    }
}

/* 暗黑主题：变量覆盖与文字对比度修复 */
body.theme-dark {
    /* 提升暗黑模式下的全局文字可读性 */
    --dark: #e5e7eb;   /* 原为深灰，暗黑下改为浅灰 */
    --gray: #cbd5e1;   /* 次级文字颜色变浅 */
    --border: #1f2937; /* 边框在暗色背景下的可见性 */
}

/* 基金卡片整体与常见文本 */
body.theme-dark .fund-card {
    background: #111827;
    color: #e5e7eb;
    border-color: var(--border);
}

/* 正/负卡片在暗黑主题下不再使用浅色渐变，保持一致暗底 */
body.theme-dark .fund-card.positive,
body.theme-dark .fund-card.negative {
    background: #0b1320;
}

/* 卡片内标题与数值文字提升对比度 */
body.theme-dark .fund-name,
body.theme-dark .detail-value,
body.theme-dark .channel-name,
body.theme-dark .channel-detail-value {
    color: #74a2ff;
}

/* 次要说明文字颜色适配暗黑主题 */
body.theme-dark .detail-label,
body.theme-dark .update-time,
body.theme-dark .profit-label,
body.theme-dark .stat-label,
body.theme-dark .stat-subtext {
    color: #cbd5e1;
}

/* 代码徽章在暗色背景下的可读性提升 */
body.theme-dark .fund-code {
    background: #1f2937;
    color: #93c5fd; /* 浅蓝提高对比 */
}

/* 细节块与收益块背景统一暗色，并提升边框对比 */
body.theme-dark .channel-detail-item,
body.theme-dark .detail-item,
body.theme-dark .profit-section {
    background: #0b1320;
    border-color: var(--border);
}

/* 渠道统计卡片暗黑配色 */
body.theme-dark .channel-dashboard .channel-stat-card {
    background: #111827;
    color: #e5e7eb;
}

/* 涨跌显示在暗底下采用更清晰的配色 */
body.theme-dark .change-positive {
    background: linear-gradient(135deg, #1f2937, #0b1320);
    color: #fca5a5; /* 浅红 */
}
body.theme-dark .change-negative {
    background: linear-gradient(135deg, #1f2937, #0b1320);
    color: #86efac; /* 浅绿 */
}

/* 卡片翻转动画样式 */
.flip-card {
    perspective: 1000px;
}

.flip-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.6s ease;
}

.flip-card.flipped .flip-inner {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    backface-visibility: hidden;
}

.card-front {
    position: relative;
}

.card-back {
    transform: rotateY(180deg);
    padding: 10px;
}

/* 卡片背面图表容器 */
.card-back .chart-container {
    width: 100%;
    height: 220px;
}

.card-back canvas {
    width: 100% !important;
    height: 220px !important;
}

/* 暗色主题下卡片背面 */
body.theme-dark .card-back {
    background: #111827;
}

/* 移动端适配：翻转卡片与图表尺寸 */
@media (max-width: 480px) {
    .flip-card {
        touch-action: manipulation;
    }
    .card-back .chart-container {
        height: 160px;
    }
    .card-back canvas {
        height: 160px !important;
    }
}

/* 卡片背面关闭按钮 */
.flip-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,0.05);
    border: none;
    color: #374151;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    line-height: 1;
}

.flip-close:hover {
    background: rgba(0,0,0,0.1);
}

body.theme-dark .flip-close {
    background: rgba(255,255,255,0.06);
    color: #e5e7eb;
}
body.theme-dark .flip-close:hover {
    background: rgba(255,255,255,0.12);
}
