.modern-dashboard {
    padding: 1.5rem;
    background: #f8f9fa;
    min-height: 100vh;
    width: 100%;
    box-sizing: border-box;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 0;
}

.section-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

.metric-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
    width: 100%;
}

.metric-card {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
    transition: transform 0.2s;
}

.metric-card:hover {
    transform: translateY(-4px);
}

.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.metric-card.income .metric-icon {
    background: rgba(40, 167, 69, 0.1);
    color: #28a745;
}

.metric-card.expense .metric-icon {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

.metric-card.balance .metric-icon {
    background: rgba(0, 123, 255, 0.1);
    color: #007bff;
}

.metric-content {
    flex: 1;
}

.metric-content h4 {
    color: #6c757d;
    font-size: 0.875rem;
    margin: 0 0 0.5rem 0;
}

.metric-content .amount {
    font-size: 1.5rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

.trend {
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.5rem;
}

.trend.up { color: #28a745; }
.trend.down { color: #dc3545; }

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1.5rem;
    width: 100%;
    margin: 0 auto;
    max-width: 1600px;
}

.dashboard-card {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
    transition: transform 0.2s, box-shadow 0.2s;
}

.dashboard-card:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.accounts-section { grid-column: span 4; }
.charts-section { 
    grid-column: span 8; 
    min-height: 400px;
    height: auto;
    overflow: hidden; /* Contain overflowing content */
}
.transactions-section { 
    grid-column: span 8;
    display: flex;
    flex-direction: column;
}
.budget-section { grid-column: span 4; }

.accounts-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.account-card {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 1rem;
    border-left: 4px solid;
}

.account-card.savings { border-color: #28a745; }
.account-card.checking { border-color: #007bff; }
.account-card.credit { border-color: #dc3545; }

.account-info h4 {
    margin: 0;
    font-size: 1rem;
    color: #2c3e50;
}

.account-type {
    font-size: 0.75rem;
    color: #6c757d;
    text-transform: uppercase;
}

.account-balance {
    margin-top: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.balance-label {
    font-size: 0.875rem;
    color: #6c757d;
}

.balance-amount {
    font-weight: 600;
    color: #2c3e50;
}

.transactions-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.transaction-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: 8px;
    background: white;
    margin-bottom: 0.5rem;
    transition: background-color 0.2s;
}

.transaction-item:hover {
    background: #f8f9fa;
}

.transaction-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.transaction-icon.income {
    background: rgba(40, 167, 69, 0.1);
    color: #28a745;
}

.transaction-icon.expense {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

.transaction-info {
    flex: 1;
}

.transaction-info h4 {
    margin: 0;
    font-size: 0.875rem;
    color: #2c3e50;
}

.transaction-info .date {
    font-size: 0.75rem;
    color: #6c757d;
}

.transaction-amount {
    font-weight: 600;
    font-size: 0.875rem;
}

.transaction-amount.income { color: #28a745; }
.transaction-amount.expense { color: #dc3545; }

.budget-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.budget-item {
    padding-bottom: 0.75rem;
}

.budget-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.budget-name h4 {
    margin: 0;
    font-size: 0.875rem;
    color: #2c3e50;
}

.budget-name .category {
    font-size: 0.75rem;
    color: #6c757d;
}

.budget-amount {
    text-align: right;
    font-size: 0.75rem;
}

.budget-amount .current {
    font-weight: 600;
    color: #2c3e50;
}

.budget-amount .separator {
    color: #6c757d;
    margin: 0 0.25rem;
}

.budget-amount .allocated {
    color: #6c757d;
}

.progress {
    height: 8px;
    margin-top: 0.5rem;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    transition: width 0.3s ease;
}

.charts-section {
    min-height: 400px;
    height: auto;
    padding: 1.5rem;
    overflow: hidden; /* Contain overflowing content */
}

.charts-section .row {
    display: flex;
    flex-wrap: wrap;
    margin: 0;
    height: auto;
    min-height: 300px;
}

.expense-trend-chart,
.category-distribution-chart {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
}

.charts-section canvas {
    width: 100% !important;
    height: 100% !important;
}

.charts-section .col-md-7,
.charts-section .col-md-5 {
    height: 300px;
    padding: 0.5rem;
    position: relative;
}

.chart-container {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 300px;
    display: flex;
    flex-direction: column;
}

.expense-trend-chart,
.category-distribution-chart {
    width: 100%;
    /* height: 300px; */
    position: relative;
}

.chart-period-selector {
    display: flex;
    gap: 0.5rem;
}

.chart-period-selector .btn {
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
}

.chart-period-selector .btn.active {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: repeat(6, 1fr);
    }

    .accounts-section,
    .charts-section,
    .transactions-section,
    .budget-section { 
        grid-column: span 6; 
    }
}

@media (max-width: 992px) {
    .dashboard-grid {
        display: grid;
        grid-template-columns: repeat(1, 1fr);
        gap: 1rem;
    }
    
    .accounts-section,
    .charts-section, 
    .transactions-section, 
    .budget-section {
        grid-column: span 1;
    }
    
    /* Make charts stack nicely on mobile */
    .charts-section {
        min-height: 600px; /* Accommodate stacked charts */
    }
    
    .charts-section .row {
        flex-direction: column;
        height: 100%;
    }
    
    .charts-section .col-md-7,
    .charts-section .col-md-5 {
        width: 100%;
        flex: 0 0 250px;
        height: 250px;
    }
}

@media (max-width: 768px) {
    .modern-dashboard {
        padding: 1rem;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .accounts-section,
    .charts-section,
    .transactions-section,
    .budget-section { 
        grid-column: span 1; 
    }
    
    .metric-cards {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .chart-container {
        min-height: 250px;
    }

    .charts-section .row {
        flex-direction: column;
        height: auto;
    }
    
    .charts-section .col-md-7,
    .charts-section .col-md-5 {
        height: 250px;
    }
}

@media (max-width: 576px) {
    .modern-dashboard {
        padding: 0.75rem;
    }
    
    .metric-cards {
        gap: 0.75rem;
        margin-bottom: 1rem;
    }
    
    .metric-card {
        padding: 1rem;
    }
    
    .dashboard-card {
        padding: 1rem;
    }
    
    .charts-section {
        min-height: 500px;
    }
    
    .charts-section .col-md-7,
    .charts-section .col-md-5 {
        flex: 0 0 200px;
        height: 200px;
    }
}

/* Fix transaction section */
.transactions-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
