/* 통계 페이지 공통 레이아웃 */
.statistics-container {
    max-width: 1000px;
    margin: 0 auto;
    padding-bottom: 2rem;
}

.stat-grid-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background-color: var(--color-card);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.stat-card h3 {
    font-size: 1.1rem;
    color: var(--color-heading);
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border);
}

/* 월간 핵심 요약 (상단 카드들) */
.summary-top-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-item-box {
    background-color: var(--color-bg);
    border-left: 4px solid var(--color-primary);
    padding: 1.2rem;
    border-radius: 4px;
}
.stat-item-box.income { border-color: var(--color-safe); }
.stat-item-box.expense { border-color: var(--color-over); }
.stat-item-box.balance { border-color: var(--color-primary); }
.stat-item-box.average { border-color: var(--color-warning); }

.stat-item-box .label {
    display: block;
    font-size: 0.85rem;
    color: var(--color-muted);
    margin-bottom: 0.3rem;
}

.stat-item-box .amount {
    display: block;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--color-text);
}

.stat-item-box .desc {
    display: block;
    font-size: 0.75rem;
    margin-top: 0.5rem;
    color: var(--color-muted);
}
.desc.increase { color: var(--color-over); }
.desc.decrease { color: var(--color-safe); }

/* 빈 상태 */
.empty-stat-state {
    text-align: center;
    padding: 2rem;
    color: var(--color-muted);
    font-size: 0.95rem;
    background-color: var(--color-bg);
    border-radius: 8px;
    border: 1px dashed var(--color-border);
}

/* 가로 막대 차트 (카테고리, 결제수단) */
.h-bar-chart {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.h-chart-item {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.h-chart-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
}

.h-chart-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.h-chart-value {
    color: var(--color-text);
    font-weight: 600;
}

.h-chart-value span {
    color: var(--color-muted);
    font-size: 0.8rem;
    font-weight: normal;
    margin-left: 0.5rem;
}

.h-chart-bar-wrap {
    height: 8px;
    background-color: var(--color-border);
    border-radius: 4px;
    overflow: hidden;
}

.h-chart-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s ease-out;
}

/* 세로 막대 차트 공통 */
.v-chart-container {
    width: 100%;
    overflow-x: auto; /* 모바일에서 가로 스크롤 허용 */
    padding-bottom: 1rem;
}

.v-chart-wrapper {
    display: flex;
    align-items: flex-end;
    height: 200px;
    min-width: 600px; /* 차트의 최소 너비 설정 (스크롤 유도) */
    gap: 4px;
    padding-top: 2rem; /* 툴팁 영역 */
    border-bottom: 1px solid var(--color-border);
}

.v-chart-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
    position: relative;
}

.v-chart-bar {
    width: 100%;
    max-width: 30px;
    background-color: var(--color-over);
    border-radius: 4px 4px 0 0;
    transition: height 0.8s ease-out, opacity 0.2s;
    min-height: 2px;
}

.v-chart-bar:hover {
    opacity: 0.8;
}

.v-chart-label {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--color-muted);
    text-align: center;
}

.v-chart-tooltip {
    position: absolute;
    top: -25px;
    font-size: 0.7rem;
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.v-chart-item:hover .v-chart-tooltip {
    opacity: 1;
}

.v-chart-bar.highlight {
    background-color: #e74a3b;
}

/* 6개월 비교 (그룹 세로 막대) */
.grouped-v-chart-wrapper {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 220px;
    min-width: 600px;
    padding-top: 2rem;
    border-bottom: 1px solid var(--color-border);
    gap: 10px;
}

.gv-chart-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
}

.gv-bars {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 4px;
    width: 100%;
    height: 100%;
    position: relative;
}

.gv-bar {
    width: 20px;
    border-radius: 3px 3px 0 0;
    transition: height 0.8s ease-out;
}
.gv-bar.income { background-color: var(--color-safe); }
.gv-bar.expense { background-color: var(--color-over); }

/* 비율 차트 (진행바) */
.ratio-chart {
    margin-top: 1rem;
}

.ratio-bar-wrap {
    height: 20px;
    background-color: var(--color-border);
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    margin-bottom: 0.5rem;
}

.ratio-bar {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: #fff;
    font-weight: 600;
}
.ratio-bar.fixed { background-color: var(--color-warning); }
.ratio-bar.variable { background-color: var(--color-primary); }

.ratio-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
}

.ratio-legend {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    font-size: 0.85rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

@media (max-width: 768px) {
    .stat-grid-row {
        grid-template-columns: 1fr;
    }
}
