.budget-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.budget-list-item {
    display: flex;
    align-items: center;
    border-bottom: 1px solid #ccc;
    border-radius: 0;
    padding: 12px 5px;
}

.budget-list-item:focus,
.budget-list-item:active,
.budget-list-item:hover {
    background-color: #f1f1f1;
}

.budget-list-item:last-child {
    border: none;
}

.budget-list-item-link {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    flex-shrink: 1;
    flex-basis: auto;
    min-width: 0;
    text-decoration: none;
    margin: 0;
}

.budget-list-item-link:link,
.budget-list-item-link:visited,
.budget-list-item-link:focus,
.budget-list-item-link:hover,
.budget-list-item-link:active {
    text-transform: uppercase;
    text-decoration: none;
}

.budget-list-item-link:hover,
.budget-list-item-link:focus {
    text-decoration: none;
}

.budget-list-item-title {
    margin: 0 0 6px 0;
    font-size: 0.9em;
    color: #333;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    max-width: 100%;
}

.budget-list-item-date {
    font-size: 0.75em;
    color: #777;
    text-transform: none;
    font-weight: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    max-width: 100%;
}

.budget-list-item-controls {
    display: flex;
    flex-grow: 0;
    flex-shrink: 0;
    flex-basis: auto;
    gap: 8px;
}

.budget-list-item-controls .budget-list-item-button {
    width: 28px;
    height: 28px;
    padding: 0;
    margin-left: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    background-repeat: no-repeat;
    background-size: 18px;
    background-position: center;
    border: none;
}

/* Hover effect for buttons */
.budget-list-item-controls .budget-list-item-button:hover {
    background-color: #e0e0e0;
}

.budget-list-item-controls .button-duplicate {
    background-image: url("../../../assets/images/icons/icon-copy-gray.svg");
}

.budget-list-item-controls .button-delete {
    background-image: url("../../../assets/images/icons/icon-trash-can-gray.svg");
}

/* BUDGET PAGE */
/* ---------------------------------------------------- */
.budget-summary-box {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    padding: 20px 0 30px 0;
    margin: 0;
}

.budget-summary-item-wrapper {
    flex-grow: 1;
    flex-grow: 1;
}

.budget-summary-item-label {
    margin: 0 0 3px 0;
    font-size: 0.7rem;
    font-weight: normal;
    text-align: center;
    text-transform: uppercase;
    white-space: nowrap;
}

.budget-summary-item-amount {
    margin: 0;
    font-size: 1.5rem;
    font-weight: bold;
    text-align: center;
}

.all-values {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    margin: 0 0 20px 0;
}

.budget-item-block {
    flex-grow: 1;
    flex-basis: 100%;
    margin: 0;
}

@media only screen and (min-width: 800px) {
    .budget-item-block {
        flex-grow: 1;
        flex-basis: calc(50% - 15px);
        margin: 0;
    }
}

.budget-item-title {
    box-sizing: border-box;
    margin: 0;
    padding: 0 10px;
    font-size: 1rem;
    line-height: 32px;
    border-radius: 5px;
}

.budget-item-block:nth-child(5n+1) .budget-item-title {
    background-color: #BDDDF4;
}

.budget-item-block:nth-child(5n+2) .budget-item-title {
    background-color: #B9F5D7;
}

.budget-item-block:nth-child(5n+3) .budget-item-title {
    background-color: #DCF4B5;
}

.budget-item-block:nth-child(5n+4) .budget-item-title {
    background-color: #ffe6af;
}

.budget-item-block:nth-child(5n+5) .budget-item-title {
    background-color: #ffd6cf;
}

.budget-item-block:nth-child(5n+6) .budget-item-title {
    background-color: #D1D8F3;
}

.budget-item-category-list {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.budget-item-category-list li {
    display: flex;
    padding: 8px 4px;
    border-bottom: 1px solid #ccc;
    cursor: pointer;
}

.budget-item-category-list li:focus,
.budget-item-category-list li:active,
.budget-item-category-list li:hover {
    background-color: #f1f1f1;
}

.budget-item-category-list li:last-child {
    border: none;
}

.budget-item-name,
.budget-item-edit,
.budget-item-amount,
.budget-category-total {
    line-height: 1.3em;
}

.budget-item-name {
    flex-grow: 1;
}

.budget-item-edit {
    flex-basis: 38px;
    flex-grow: 0;
    flex-shrink: 0;
    background-image: url("../../../assets/images/icons/icon-pencil-gray.svg");
    background-repeat: no-repeat;
    background-size: 14px;
    background-position: center 2px;
}

.budget-item-amount {
    flex-grow: 0;
    flex-shrink: 0;
    padding: 0;
    font-weight: bold;
}

.budget-category-total {
    flex-grow: 1;
    font-size: 0.8rem;
    font-weight: bold;
    text-align: right;
    text-transform: uppercase;
}

/* VISUALIZATION */
/* ---------------------------------------------------- */

/* Mobile-first: stacked layout */
.budgeting-allocation {
    display: flex;
    flex-direction: column;
    gap: 60px;
    align-items: stretch;
}

.budgeting-allocation-chart-wrapper {
    width: 100%;
}

.budgeting-allocation-chart-wrapper canvas.category-donut-chart {
    width: 100% !important;
    height: auto !important;
    max-width: 300px;
    aspect-ratio: 1 / 1; /* keep it square on responsive */
    display: block;
    margin: 0 auto;
}

.budgeting-allocation-legend-wrapper {
    width: 100%;
    min-width: 200px;
}

/* Larger screens: side-by-side layout */
@media only screen and (min-width: 700px) {
    .budgeting-allocation {
        flex-direction: row;
        align-items: flex-start;
    }
    .budgeting-allocation-chart-wrapper {
        width: 40%;
    }

    .budgeting-allocation-legend-wrapper {
        width: 60%;
    }

    .budgeting-allocation-chart-wrapper canvas.category-donut-chart {
        max-width: 100%;
    }
}

/* Visualization legend styles */
.category-legend-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
    min-width: 0; /* allow children to shrink for ellipsis */
}

.legend-item:last-child {
    border: none;
}

.legend-swatch {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 2px;
}

.legend-label {
    display: block;
    flex: 1 1 auto;
    min-width: 0; /* allow flex child to shrink for ellipsis */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.legend-value {
    margin-left: auto;
    text-align: right;
}

.legend-percent {
    margin: 0 0 0 12px;
    min-width: 50px;
    font-weight: 600;
    text-align: right;
}
/* Per-category swatch colors (fallback to ensure styling even without inline JS colors) */
.legend-swatch-cat-1 { background-color: #66c2a5; }
.legend-swatch-cat-2 { background-color: #ffd92f; }
.legend-swatch-cat-3 { background-color: #a6d854; }
.legend-swatch-cat-4 { background-color: #9c27b0; }
.legend-swatch-cat-5 { background-color: #f44336; }
.legend-swatch-cat-6 { background-color: #fc8d62; }

/* Legend summary rows styling */
.legend-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85em;
    font-weight: normal;
    padding: 8px 0;
    border-top: 1px solid #eee;
}

.legend-total-label {
    flex: 1 1 auto;
    text-align: left;
}

.legend-total-value {
    flex: 0 0 auto;
    text-align: right;
    margin-left: 12px;
    font-weight: bold;
}

.sankey-chart-title {
    margin: 40px 0 0 0;
}