/*
    Created on : 13 janv. 2026, 09:00:34
    Author     : Morgan Vivier - https://github.com/rsquatre
*/

/* Prevent horizontal scroll on all screen sizes */
* {
    box-sizing: border-box;
}

.budget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.budget-header-info {
    flex: 0 0 auto;
}

.budget-header-info h2 {
    margin: 0;
}

.budget-header-info p {
    margin: 0.25rem 0 0 0;
}

.budget-header-form {
    flex: 1 1 auto;
}

.period-selector {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.period-selector-type {
    flex: 0 0 auto;
    min-width: 200px;
}

.period-selector-custom {
    display: flex;
    gap: 0.75rem;
    flex: 0 0 auto;
}

.period-selector-custom > div {
    min-width: 150px;
}

.period-selector button {
    flex: 0 0 auto;
}


.budget-accounts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    padding: 1.5rem;
    border-radius: 1rem;
    background-color: var(--color-bg-surface);
    margin: 1rem 0;
}

.budget-accounts-account {
    display: flex;
    flex-direction: column;
    background: var(--color-bg-elevated);
    border-radius: 1rem;
    border: solid var(--color-border) 1px;
}

.budget-accounts-account h3{
    display: inline-block;
    text-align: center;
    font-size: 1.2rem;
    margin-top: 0;
    padding-bottom: 0.5rem;
    padding: 1rem 0;
    border-bottom: solid var(--color-border) 1px;
}

.budget-accounts-account .account-details div {
    display: flex;
    justify-content: space-between;
    padding: 1rem;
}

.budget-accounts-account .account-details h4{
    display: inline-block;
    font-size: 1rem;
    margin: 0;
}

.budget-last-transactions, .budget-next-transactions {
    border-radius: 1rem;
    background-color: var(--color-bg-surface);
    padding: 1.5rem;
    margin: 1rem 0;
}
.budget-last-transactions tbody, .budget-next-transactions tbody {
    max-height: 50vh;
    overflow-y: auto;
}

.budget-last-transactions h3, .budget-next-transactions h3 {
    margin: 0;
    margin-bottom: 0.5rem;
}

.budget-last-transactions table, .budget-next-transactions table {
    border-collapse: collapse;
}

.budget-last-transactions tr, .budget-next-transactions tr {
    width: 100%;
    border-bottom: solid var(--color-border) 1px;
}

.transaction-table{
    overflow-y: auto;
    max-height: 50vh;
}

.budget-last-transactions .transaction-table tr:nth-of-type(even), .budget-next-transactions .transaction-table tr:nth-of-type(even) {
    background-color: var(--color-bg-elevated);
}

.budget-last-transactions td, .budget-next-transactions td {
    padding: 0.7rem;
}












/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    background: var(--color-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-gray-200);
}

.empty-state__icon {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.empty-state__icon svg {
    color: white;
}

.empty-state__title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-gray-900);
    margin: 0 0 0.75rem 0;
}

.empty-state__text {
    font-size: 1rem;
    color: var(--color-gray-600);
    margin: 0 0 2rem 0;
    max-width: 500px;
}

/* Section Title */
.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-gray-900);
    margin: 0 0 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.budget-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, max-content));
    gap: 1rem;
}

/* Period Filter */
.period-filter {
    margin-bottom: 2rem;
    padding: 1.25rem;
    background: var(--color-white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

.filter-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.filter-label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--color-gray-700);
    white-space: nowrap;
}

.filter-select, .filter-input {
    padding: 0.5rem 0.875rem;
    border: 1px solid var(--color-gray-300);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    background: var(--color-white);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.filter-select:focus, .filter-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.filter-select {
    min-width: 200px;
    cursor: pointer;
    color: var(--color-gray-700);
}

/* Accounts Overview */
.accounts-overview {
    margin-bottom: 2rem;
}

.accounts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.account-card {
    background: var(--color-white);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid var(--color-gray-100);
}

.account-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.account-card__header {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--color-gray-200);
}

.account-card__name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-gray-900);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.account-card__type {
    font-size: 0.6875rem;
    color: var(--color-gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.account-card__body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1;
}

.account-card__balance-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: var(--color-gray-50);
    border-radius: var(--radius-sm);
}

.account-card__balance-row--current {
    background: var(--color-blue-50);
}

.account-card__balance-row--projected {
    background: var(--color-green-50);
}

.balance-label {
    font-size: 0.75rem;
    color: var(--color-gray-600);
    font-weight: 500;
}

.balance-value {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--color-gray-900);
}

.account-card__footer {
    display: flex;
    justify-content: center;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-gray-200);
}

.evolution {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.evolution--positive {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.evolution--negative {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
    border: 1px solid #fca5a5;
}

/* Forecast Section */
.forecast-section {
    margin-bottom: 2rem;
}

.forecast-period {
    font-size: 0.875rem;
    font-weight: normal;
    color: var(--color-gray-500);
    margin-left: 0.5rem;
}

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

.forecast-card {
    background: var(--color-white);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-gray-100);
    transition: box-shadow 0.2s ease;
}

.forecast-card:hover {
    box-shadow: var(--shadow-md);
}

.forecast-card--transactions {
    border-left: 4px solid #3b82f6;
}

.forecast-card--recurring {
    border-left: 4px solid #8b5cf6;
}

.forecast-card--total {
    border-left: 4px solid #10b981;
}

.forecast-card__title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-gray-900);
    margin: 0 0 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.forecast-card__values {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.forecast-value {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    background: var(--color-gray-50);
    transition: background 0.2s ease;
}

.forecast-value:hover {
    background: var(--color-gray-100);
}

.forecast-value--balance {
    font-weight: 600;
}

.forecast-value__label {
    font-size: 0.875rem;
    color: var(--color-gray-600);
    font-weight: 500;
}

.forecast-value__amount {
    font-size: 1.0625rem;
    font-weight: 700;
}

.forecast-value--revenue .forecast-value__amount, .forecast-positive {
    color: #10b981;
}

.forecast-value--expense .forecast-value__amount, .forecast-negative {
    color: #ef4444;
}

/* Period Info */
.period-info {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    align-items: center;
    padding: 1.25rem 1.75rem;
    background: var(--color-white);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--color-gray-100);
    margin-bottom: 1.5rem;
}

.period-info__item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.period-info__item--highlight {
    margin-left: auto;
    padding: 0.625rem 1.125rem;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border-radius: var(--radius-md);
    color: white;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
    font-weight: 600;
}

.period-info__item--highlight svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

.period-info__label {
    font-size: 0.8125rem;
    color: var(--color-gray-500);
    font-weight: 500;
}

.period-info__item--highlight .period-info__label,
.period-info__item--highlight .period-info__value {
    color: white;
}

.period-info__value {
    font-size: 0.875rem;
    color: var(--color-gray-900);
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--color-gray-100);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
    opacity: 0;
    transition: opacity 0.2s ease;
}

.stat-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: var(--color-gray-200);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card--primary::before {
    background: linear-gradient(90deg, #3b82f6, #2563eb);
}

.stat-card--success::before {
    background: linear-gradient(90deg, #10b981, #059669);
}

.stat-card--danger::before {
    background: linear-gradient(90deg, #ef4444, #dc2626);
}

.stat-card--warning::before {
    background: linear-gradient(90deg, #f59e0b, #d97706);
}

.stat-card__header{
    display: flex !important;
    justify-content: space-between;
}

.stat-card__icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--color-bg-surface);
}

.stat-card__icon svg {
    color: var(--color-gray-600);
}


.stat-card--primary .stat-card__icon svg {
    color: #3b82f6;
}

.stat-card--success .stat-card__icon svg {
    color: #10b981;
}

.stat-card--danger .stat-card__icon svg {
    color: #ef4444;
}


.stat-card--warning .stat-card__icon svg {
    color: #f59e0b;
}

.stat-card__content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stat-card__label {
    font-size: 0.8125rem;
    color: var(--color-gray-500);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card__values {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stat-value-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-value-row--forecast {
    padding: 0.75rem 1rem;
    background: var(--color-bg-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-gray-200);
}

.stat-value-current {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--color-gray-900);
    line-height: 1;
    letter-spacing: -0.02em;
}

.stat-value-label {
    font-size: 0.6875rem;
    color: var(--color-gray-500);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value-forecast {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-gray-800);
    letter-spacing: -0.01em;
}

.stat-card__evolution {
    font-size: 0.8125rem;
    font-weight: 700;
    padding: 0.5rem 0.875rem;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    align-self: flex-start;
    letter-spacing: -0.01em;
}

.stat-card__meta {
    font-size: 0.75rem;
    color: var(--color-gray-500);
    font-weight: 500;
}

/* Budget Actions */
.budget-actions {
    margin-bottom: 2rem;
}

.action-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, max-content));
    gap: 1rem;
    margin-top: 1rem;
}

.action-card {
    background: var(--color-white);
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    text-decoration: none;
    transition: all 0.2s ease;
}

.action-card:hover {
    background: var(--color-gray-50);
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.action-card__icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.action-card__icon svg {
    color: white;
}

.action-card__content {
    flex: 1;
}

.action-card__title {
    margin: 0 0 0.25rem 0;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-gray-900);
}

.action-card__text {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--color-gray-600);
    line-height: 1.4;
}

/* Profile Info */
.budget-profile-info {
    display: inline-block;
    margin-bottom: 2rem;
}

.profile-card {
    background: var(--color-white);
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    display: flex;
    gap: 1.25rem;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.profile-card__icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.profile-card__icon svg {
    color: white;
}

.profile-card__content {
    flex: 1;
}

.profile-card__name {
    margin: 0 0 0.5rem 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-gray-900);
}

.profile-card__type {
    font-size: 0.875rem;
    color: var(--color-gray-600);
    margin-bottom: 0.25rem;
}

.profile-card__users {
    font-size: 0.8125rem;
    color: var(--color-gray-500);
}

/* Budget Charts Section */
.budget-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin: 1rem 0;
    padding: 1.5rem;
    background-color: var(--color-bg-surface);
    border-radius: 1rem;
}

.budget-chart-current,
.budget-chart-preview {
    background: var(--color-bg-elevated);
    border-radius: 1rem;
    border: solid var(--color-border) 1px;
    padding: 1.5rem;
}

.budget-chart-current h3,
.budget-chart-preview h3 {
    margin: 0 0 1rem 0;
    font-size: 1.2rem;
    text-align: center;
    color: var(--color-text-primary);
}

.chart-container {
    position: relative;
    height: 400px;
    margin: 0 auto;
}

.chart-container canvas {
    max-height: 100%;
}

/* Chart Details Panel */
.chart-details {
    background: var(--color-bg-surface);
    border-radius: 1rem;
    border: solid var(--color-border) 1px;
    padding: 1.5rem;
    margin: 1rem 0;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chart-details__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 1.5rem;
}

.chart-details__title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text-primary);
}

.chart-details__close {
    background: none;
    border: none;
    font-size: 2rem;
    line-height: 1;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    transition: background-color 0.2s, color 0.2s;
}

.chart-details__close:hover {
    background-color: var(--color-bg-surface);
    color: var(--color-text-primary);
}

.chart-details__content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.chart-details__section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chart-details__section h5 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.875rem;
}

.subcategories-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.subcategory-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--color-bg-elevated);
    border-radius: 0.5rem;
    border: 1px solid var(--color-border);
    transition: background-color 0.2s;
}

.subcategory-item:hover {
    background: var(--color-bg-surface);
}

.subcategory-item__info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.category-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.category-dot--sm {
    width: 10px;
    height: 10px;
}

.subcategory-item__amount {
    font-weight: 600;
    color: var(--color-text-primary);
    font-size: 0.9375rem;
}

.transactions-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.transaction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--color-bg-elevated);
    border-radius: 0.5rem;
    border: 1px solid var(--color-border);
    transition: background-color 0.2s;
}

.transaction-item:hover {
    background: var(--color-bg-surface);
}

.transaction-item__info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.transaction-item__label {
    font-weight: 500;
    color: var(--color-text-primary);
    font-size: 0.9375rem;
}

.transaction-item__date {
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
}

.transaction-item__amount {
    font-weight: 600;
    color: var(--color-text-primary);
    font-size: 0.9375rem;
    margin-left: 1rem;
}

/* Responsive adjustments */

/* Large Desktop (> 1280px) */
@media (min-width: 1281px) {
    .budget-accounts {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }

    .budget-charts {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Desktop (1024px - 1280px) */
@media (max-width: 1280px) {
    .budget-accounts {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .budget-charts {
        grid-template-columns: repeat(2, 1fr);
    }

    .chart-container {
        height: 350px;
    }
}

/* Tablet landscape (768px - 1023px) */
@media (max-width: 1023px) {
    .budget-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .budget-header-form {
        width: 100%;
    }

    .period-selector {
        width: 100%;
    }

    .period-selector-type {
        flex: 1 1 auto;
        min-width: 180px;
    }

    .budget-accounts {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        padding: 1rem;
    }

    .budget-charts {
        grid-template-columns: 1fr;
        padding: 1rem;
    }

    .chart-container {
        height: 350px;
    }

    .accounts-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }

    .forecast-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }

    .action-cards {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }

    .budget-last-transactions,
    .budget-next-transactions {
        padding: 1rem;
    }
}

/* Tablet portrait (640px - 767px) */
@media (max-width: 767px) {
    .budget-header {
        gap: 0.75rem;
    }

    .period-selector {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .period-selector-type {
        width: 100%;
        min-width: auto;
    }

    .period-selector-custom {
        flex-direction: column;
        width: 100%;
    }

    .period-selector-custom > div {
        width: 100%;
        min-width: auto;
    }

    .period-selector button {
        width: 100%;
    }

    .budget-accounts {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        padding: 0.75rem;
    }

    .budget-accounts-account h3 {
        font-size: 1rem;
        padding: 0.75rem 0;
    }

    .budget-accounts-account .account-details div {
        padding: 0.75rem;
    }

    .budget-accounts-account .account-details h4 {
        font-size: 0.9rem;
    }

    .budget-charts {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 0.75rem;
    }

    .budget-chart-current,
    .budget-chart-preview {
        padding: 1rem;
    }

    .budget-chart-current h3,
    .budget-chart-preview h3 {
        font-size: 1rem;
        margin-bottom: 0.75rem;
    }

    .chart-container {
        height: 280px;
    }

    .chart-details {
        padding: 1rem;
    }

    .chart-details__title {
        font-size: 1.1rem;
    }

    .budget-last-transactions,
    .budget-next-transactions {
        padding: 0.75rem;
        overflow-x: visible;
    }

    .budget-last-transactions h3,
    .budget-next-transactions h3 {
        font-size: 1rem;
    }

    /* Transform tables to card layout on mobile */
    .budget-last-transactions table,
    .budget-next-transactions table {
        display: block;
        width: 100%;
    }

    .budget-last-transactions thead,
    .budget-next-transactions thead {
        display: none;
    }

    .budget-last-transactions tbody,
    .budget-next-transactions tbody {
        display: block;
        width: 100%;
        max-height: none;
    }

    .budget-last-transactions tr,
    .budget-next-transactions tr {
        display: block;
        margin-bottom: 0.75rem;
        background: var(--color-bg-elevated);
        border-radius: 0.5rem;
        border: 1px solid var(--color-border);
        padding: 0.75rem;
    }

    .budget-last-transactions td,
    .budget-next-transactions td {
        display: block;
        width: 100% !important;
        text-align: left !important;
        padding: 0.4rem 0;
        border: none;
    }

    .budget-last-transactions td::before,
    .budget-next-transactions td::before {
        content: attr(data-label);
        font-weight: bold;
        display: block;
        margin-bottom: 0.25rem;
        color: var(--color-text-secondary);
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    /* First column (label) - make it stand out */
    .budget-last-transactions td:first-child,
    .budget-next-transactions td:first-child {
        font-size: 1rem;
        font-weight: bold;
        padding-bottom: 0.5rem;
        margin-bottom: 0.5rem;
        border-bottom: 1px solid var(--color-border);
        word-break: break-word;
    }

    .budget-last-transactions td:first-child::before,
    .budget-next-transactions td:first-child::before {
        display: none;
    }

    /* Badges in card layout */
    .budget-last-transactions .badge,
    .budget-next-transactions .badge {
        display: inline-block;
        max-width: 100%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Transaction table container */
    .transaction-table {
        max-height: none;
        overflow-y: visible;
    }

    /* Table footer adjustments */
    .budget-last-transactions tfoot,
    .budget-next-transactions tfoot {
        display: block;
        margin-top: 1rem;
    }

    .budget-last-transactions tfoot tr,
    .budget-next-transactions tfoot tr {
        display: flex;
        flex-direction: column;
        background: var(--color-bg-surface);
        padding: 0.75rem;
        margin-bottom: 0.5rem;
    }

    .budget-last-transactions tfoot td,
    .budget-next-transactions tfoot td {
        padding: 0.25rem 0;
        width: 100% !important;
    }

    .filter-form {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-select {
        min-width: auto;
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .action-cards {
        grid-template-columns: 1fr;
    }

    .profile-card {
        flex-direction: row;
        padding: 1rem;
    }

    .period-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        padding: 1rem;
    }

    .period-info__item--highlight {
        margin-left: 0;
        width: 100%;
        justify-content: center;
    }
}

/* Mobile large (480px - 639px) */
@media (max-width: 639px) {
    .budget-header {
        margin-bottom: 0.75rem;
    }

    .budget-header-info h2 {
        font-size: 1.25rem;
    }

    .budget-header-info p {
        font-size: 0.875rem;
    }

    .budget-accounts {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        padding: 0.5rem;
    }

    .budget-accounts-account {
        padding: 0.75rem !important;
    }

    .budget-charts {
        padding: 0.5rem;
        gap: 0.75rem;
    }

    .budget-chart-current,
    .budget-chart-preview {
        padding: 0.75rem;
    }

    .chart-container {
        height: 250px;
    }

    .budget-last-transactions,
    .budget-next-transactions {
        padding: 0.5rem;
        margin: 0.75rem 0;
    }

    .badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }

    .profile-card {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .period-info {
        padding: 0.75rem;
    }
}

/* Mobile small (< 480px) */
@media (max-width: 479px) {
    .budget-header-info h2 {
        font-size: 1.1rem;
    }

    .budget-header-info p {
        font-size: 0.8rem;
    }

    .period-selector {
        gap: 0.4rem;
    }

    .form-label {
        font-size: 0.85rem;
    }

    .form-select,
    .form-control {
        font-size: 0.875rem;
        padding: 0.4rem 0.6rem;
    }

    .btn {
        font-size: 0.875rem;
        padding: 0.5rem 1rem;
    }

    .budget-accounts {
        padding: 0.4rem;
    }

    .budget-accounts-account h3 {
        font-size: 0.95rem;
        padding: 0.6rem 0;
    }

    .budget-accounts-account .account-details div {
        padding: 0.6rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.3rem;
    }

    .budget-accounts-account .account-details h4 {
        font-size: 0.85rem;
    }

    .budget-charts {
        padding: 0.4rem;
    }

    .budget-chart-current h3,
    .budget-chart-preview h3 {
        font-size: 0.95rem;
    }

    .chart-container {
        height: 220px;
    }

    .chart-details {
        padding: 0.75rem;
    }

    .chart-details__header {
        padding-bottom: 0.75rem;
        margin-bottom: 1rem;
    }

    .chart-details__title {
        font-size: 1rem;
    }

    .chart-details__close {
        width: 28px;
        height: 28px;
        font-size: 1.5rem;
    }

    .chart-details__section h5 {
        font-size: 0.85rem;
    }

    .subcategory-item,
    .transaction-item {
        padding: 0.6rem 0.75rem;
    }

    .subcategory-item__amount,
    .transaction-item__amount {
        font-size: 0.85rem;
    }

    .transaction-item__label {
        font-size: 0.85rem;
    }

    .transaction-item__date {
        font-size: 0.75rem;
    }

    .budget-last-transactions,
    .budget-next-transactions {
        padding: 0.4rem;
    }

    .budget-last-transactions h3,
    .budget-next-transactions h3 {
        font-size: 0.95rem;
        margin-bottom: 0.4rem;
    }

    .badge.fs-6 {
        font-size: 0.65rem;
    }

    .badge.fs-7 {
        font-size: 0.55rem;
    }

    /* Card layout adjustments for smaller text */
    .budget-last-transactions td,
    .budget-next-transactions td {
        font-size: 0.85rem;
    }

    .budget-last-transactions td::before,
    .budget-next-transactions td::before {
        font-size: 0.7rem;
    }

    .profile-card {
        flex-direction: column;
        text-align: center;
        padding: 0.75rem;
    }

    .period-info {
        padding: 0.6rem;
        gap: 0.5rem;
    }

    .period-info__item {
        font-size: 0.8rem;
    }
}

/* Prevent horizontal overflow on mobile */
@media (max-width: 767px) {
    /* Global overflow prevention */
    body {
        overflow-x: hidden;
    }

    /* Ensure no horizontal scroll on main containers */
    .budget-header,
    .budget-accounts,
    .budget-charts,
    .budget-last-transactions,
    .budget-next-transactions,
    .chart-details {
        max-width: 100%;
        overflow-x: hidden;
    }

    /* Ensure all direct children respect container width */
    .budget-last-transactions *,
    .budget-next-transactions * {
        max-width: 100%;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Prevent form elements from overflowing */
    .form-select,
    .form-control,
    .btn {
        max-width: 100%;
    }

    /* Ensure chart containers don't overflow */
    .chart-container,
    .chart-container canvas {
        max-width: 100%;
    }
}

/* Landscape orientation optimizations */
@media (max-width: 1023px) and (orientation: landscape) {
    .budget-accounts {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .budget-charts {
        grid-template-columns: repeat(2, 1fr);
    }

    .chart-container {
        height: 280px;
    }

    .transaction-table {
        max-height: 30vh;
    }
}
