/* === 1. Basic Setup === */
:root {
    --bg-gray: #f4f7fe;
    --card-white: #ffffff;
    --text-primary: #2b3674;
    --text-secondary: #a3aed0;
    --accent-blue: #4318ff;
    --accent-cyan: #05cd99;
    --shadow: 0 5px 20px rgba(0, 0, 0, 0.02);
}

body {
    font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg-gray);
    margin: 0;
    padding: 30px;
    color: var(--text-primary);
}

/* === 2. Header === */
header {
    margin-bottom: 10px;
}

h1 {
    margin: 0;
    font-size: 36px;
    font-weight: 700;
    text-align: left;
    /* align title left */
}

.subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* === 3. User Bar (Top Right) === */
.user-bar-container {
    display: flex;
    justify-content: flex-end;
    /* align right */
    margin-bottom: 30px;
}

.user-profile {
    display: flex;
    align-items: center;
    background: var(--card-white);
    padding: 8px 20px;
    border-radius: 30px;
    box-shadow: var(--shadow);
}

.user-name {
    font-weight: 600;
    margin-right: 15px;
    font-size: 14px;
}

.avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background-color: var(--text-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

/* === 4. Section 1: KPI Cards === */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 25px;
}

.kpi-card {
    background: var(--card-white);
    border-radius: 20px;
    padding: 20px;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}

.kpi-card:hover {
    transform: translateY(-5px);
}

.icon-box {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    font-size: 22px;
    background: #f4f7fe;
    /* gray bg by default */
    color: var(--accent-blue);
}

.kpi-content h4 {
    margin: 0;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.kpi-content p {
    margin: 5px 0 0 0;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Trend Badge Styles */
.trend-info {
    display: flex;
    align-items: center;
    margin-top: 10px;
}

.trend-badge {
    display: flex;
    align-items: center;
    color: #4318ff;
    background: #f0ecff;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    margin-right: 10px;
}

.trend-text {
    color: var(--text-secondary);
    font-size: 12px;
}

/* Colors for specific KPIs */
.kpi-icon-1 {
    color: #4318ff;
    background: #f0ecff;
}

.kpi-icon-2 {
    color: #05cd99;
    background: #e6faf5;
}

.kpi-icon-3 {
    color: #ffb547;
    background: #fff7e6;
}

.kpi-icon-4 {
    color: #e31a1a;
    background: #ffebeb;
}

/* === 5. Section 2: Main Line Chart === */
.main-chart-section {
    background: var(--card-white);
    border-radius: 20px;
    padding: 25px;
    box-shadow: var(--shadow);
    margin-bottom: 25px;
    position: relative;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.chart-toggle-btn {
    background: #f4f7fe;
    border-radius: 10px;
    padding: 5px;
    display: flex;
    gap: 5px;
}

.toggle-option {
    padding: 6px 15px;
    border-radius: 8px;
    font-size: 12px;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 600;
    transition: 0.3s;
}

.toggle-option.active {
    background: white;
    color: var(--text-primary);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.chart-container-large {
    height: 300px;
    width: 100%;
}

/* === 6. Section 3: Middle Charts === */
.middle-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    /* split 50/50 */
    gap: 25px;
    margin-bottom: 25px;
}

.left-charts-col {
    display: flex;
    flex-direction: column;
    gap: 25px;
    min-width: 0;
    /* fix: allow items to shrink */
}

.chart-card {
    background: var(--card-white);
    border-radius: 20px;
    padding: 20px;
    box-shadow: var(--shadow);
    flex: 1;
    /* fill available space */
    min-height: 250px;
    min-width: 0;
    /* fix: allow shrink */
}

/* Pie Chart Layout */
.pie-card-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.pie-chart-wrapper {
    width: 100%;
    height: 220px;
    /* flexible height */
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
}

/* === Payment Methods Legend === */
.pie-legend-bars {
    width: 100%;
    margin-top: 10px;
}

/* Container for each item */
.legend-item-stacked {
    margin-bottom: 15px;
    /* spacing */
}

/* Top part: dot + text */
.legend-top {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
    display: block;
}

.legend-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Bottom part: bar + number */
.legend-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* split left and right */
}

.legend-progress-bg {
    flex: 1;
    /* takes remaining space */
    height: 6px;
    background: #f4f7fe;
    /* bg color */
    border-radius: 3px;
    margin-right: 10px;
    /* margin */
    overflow: hidden;
}

.legend-fill {
    height: 100%;
    border-radius: 3px;
}

.legend-percent {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 35px;
    /* align numbers */
    text-align: right;
}

/* === 7. Section 4: Bottom Chart === */
.bottom-section {
    background: var(--card-white);
    border-radius: 20px;
    padding: 25px;
    box-shadow: var(--shadow);
    height: 300px;
}