.forecast-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}

.forecast-item {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 12px 14px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.forecast-item-title {
    font-weight: 700;
    color: #212529;
    margin-bottom: 8px;
}

.forecast-item-line {
    display: flex;
    justify-content: space-between;
    margin: 4px 0;
    color: #495057;
}

.forecast-amount {
    color: #0071e3;
    font-weight: 700;
}

.forecast-conf {
    color: #6e6e73;
    font-size: 0.85rem;
    margin-top: auto;
}

.stat-primary,
.duration-main {
    font-size: 1.8rem;
    font-weight: 700;
    color: #1d1d1f;
    line-height: 1.2;
    display: block;
}

.stat-secondary,
.duration-sub {
    display: block;
    margin-top: 6px;
    font-size: 0.95rem;
    color: #6e6e73;
}

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

.chart-container-wrapper {
    width: 100%;
    margin-top: 0;
    padding: 0;
    height: 100%;
}


.chart-container.regression,
.chart-container.prob {
    min-height: 320px;
    position: relative;
    overflow: visible;
}

#forecastRegressionChart,
#forecastDurationChart,
#forecastProbChart,
#forecastDailyDurationChart {
    width: 100%;
    height: 250px !important;
    min-height: 250px;
    max-height: 250px;
    flex: 0 0 250px;
    display: block;
}

#forecastRegressionWrapper,
#forecastDurationWrapper,
#forecastProbWrapper,
#forecastDailyDurationWrapper {
    max-height: none;
}

.chart-container.regression .forecast-conf {
    font-size: 0.8rem;
    margin-top: 6px;
}

#forecastRegressionEqn {
    white-space: normal;
    word-break: break-word;
}

.forecast-next-val {
    font-weight: 600;
    color: #0071e3;
    margin-top: 4px;
    font-size: 0.9rem;
}

#forecast-section .stats-container {
    gap: 10px;
}

#forecast-section .stat-card {
    min-height: 110px;
    padding: 14px;
    gap: 4px;
}

.stat-card h3 {
    font-size: clamp(1rem, 0.9rem + 0.6vw, 1.25rem);
}

.stat-card p {
    font-size: clamp(1rem, 0.85rem + 0.7vw, 1.4rem);
}

.stat-card .duration-main,
.stat-card .stat-primary {
    font-size: clamp(1.2rem, 1rem + 1.2vw, 1.8rem);
}

.stat-card .duration-sub,
.stat-card .stat-secondary {
    font-size: clamp(0.8rem, 0.72rem + 0.5vw, 1rem);
}

.stat-card .forecast-conf {
    font-size: clamp(0.75rem, 0.7rem + 0.3vw, 0.85rem);
}

.stats-container {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
    gap: 15px;
    flex-wrap: wrap;
}

.stat-card {
    flex: 1;
    background-color: white;
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
    min-width: 150px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 96px;
}

.stats-container {
    gap: 10px;
}

.stat-card h3 {
    font-size: 1rem;
    color: #6e6e73;
    margin-bottom: 10px;
    font-weight: 500;
}

.stat-card p {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1d1d1f;
    margin: 0;
}

.stat-card .forecast-conf {
    font-size: 0.85rem;
    font-weight: 400;
    color: #6e6e73;
    margin-top: auto;
}

/* 图表切换按钮样式 */
.chart-toggle-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
    position: relative;
}

.chart-toggle-btn {
    padding: 8px 20px;
    background-color: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 30px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    position: relative;
    overflow: hidden;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    width: auto;
    min-width: max-content;
}

.chart-toggle-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0071e3, #005bbd);
    z-index: -1;
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}




.chart-toggle-btn.active {
    color: white;
    border-color: #0071e3;
    background-color: transparent;
}

.chart-toggle-btn.active::before {
    transform: scaleX(1);
    transform-origin: left;
}



.chart-toggle-btn.clicked {
    transform: scale(0.96);
    transition: transform 0.2s ease;
}

/* 活动指示器动画 */
.chart-toggle-buttons::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: var(--indicator-left, 0);
    width: var(--indicator-width, 0);
    height: 3px;
    background: linear-gradient(90deg, #0071e3, #005bbd);
    border-radius: 3px;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

/* 图表容器样式 */
.chart-container-wrapper {
    width: 100%;
    margin-top: 20px;
    padding: 10px 0;
    min-width: 0; /* 防止Grid Item溢出 */
}

.chart-container {
    background-color: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
    width: 100%;
    height: 100%;
    max-height: 450px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 10px;
    overflow-x: auto;
    /* 允许水平滚动 */
}

.chart-scroll-container {
    overflow-x: auto;
    /* 图表内容在容器内滑动 */
    padding-bottom: 15px;
    /* 为滚动条留出空间 */
    /* Firefox滚动条样式 */
    scrollbar-width: thin;
    scrollbar-color: #d1d1d6 transparent;
}

/* 标签页容器样式 */
.forecast-tabs-wrapper {
    background-color: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
    width: 100%;
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    min-width: 0; /* 关键：允许Grid Item收缩，防止撑开页面 */
}

.forecast-tabs-nav.chart-toggle-buttons {
    justify-content: flex-start;
    margin: 0 0 20px 0;
    padding-bottom: 12px; /* Increased padding to accommodate indicator */
    border-bottom: 1px solid #f5f5f7;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none;  /* IE 10+ */
    cursor: grab;
    user-select: none; /* Prevent text selection while dragging */
    max-width: 100%; /* 确保不超出父容器 */
    width: 100%; /* 强制宽度为父容器宽度 */
    min-width: 0; /* 允许在Flex/Grid容器中收缩 */
}

/* Hide scrollbar for Chrome/Safari/Webkit */
.forecast-tabs-nav.chart-toggle-buttons::-webkit-scrollbar {
    display: none;
}

.forecast-tabs-nav.chart-toggle-buttons:active {
    cursor: grabbing;
}

/* Override indicator position for scrollable container */
.forecast-tabs-nav.chart-toggle-buttons::after {
    bottom: 0; /* Align with bottom edge to prevent clipping */
}

.forecast-tabs-nav .chart-toggle-btn {
    flex-shrink: 0;
}

.forecast-tab-content {
    flex: 1;
    position: relative;
    min-height: 300px;
}

/* 当图表在标签页内部时，移除卡片样式 */
.forecast-tab-content .chart-container-wrapper {
    margin-top: 0;
    padding: 0;
    box-shadow: none;
}

.forecast-tab-content .chart-container {
    box-shadow: none;
    padding: 0;
    border-radius: 0;
    background: transparent;
    height: auto;
    min-height: auto;
    max-height: none;
    display: block; /* Override flex */
}

/* 横向滚动条样式优化 */
.chart-scroll-container::-webkit-scrollbar {
    height: 10px;
}

.chart-scroll-container::-webkit-scrollbar-track {
    background: #f1f3f4;
    border-radius: 5px;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.1);
}

.chart-scroll-container::-webkit-scrollbar-thumb {
    background-color: #0071e3;
    border-radius: 5px;
    border: 2px solid #f1f3f4;
    transition: background-color 0.3s ease;
}

.chart-scroll-container::-webkit-scrollbar-thumb:hover {
    background-color: #005bbd;
}

.chart-section,
.data-section {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    min-width: 250px;
    /* 设置最小宽度以确保内容可读 */
    flex: 1;
    /* 允许伸缩以适应可用空间 */
}

.chart-section h3,
.data-section h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #212529;
    font-size: 1.1rem;
    font-weight: 700;
    padding-bottom: 8px;
    border-bottom: 1px solid #e9ecef;
}

.chart-section {
    display: flex;
    flex-direction: column;
}

.data-section {
    max-width: 350px;
}

/* 在小屏幕上调整样式 */
@media (max-width: 767px) {
    .data-section {
        min-width: 200px;
        /* 在小屏幕上设置更小的最小宽度 */
    }
}

@media (max-width: 767px) {
    .chart-section {
        min-width: 400px;
        /* 在小屏幕上设置更小的最小宽度 */
    }
}

.person-chart {
    max-width: 100%;
    height: 250px !important;
    max-height: 250px;
}