#budget-tracker {
    margin: 12px 0;
}

.voter-info label {
    display: inline-block;
    width: 100%;
    font-weight: bold;
}

.voter-info input[type="text"],
.voter-info input[type="email"] {
    padding: 16px;
    border: 1px solid #ccc;
    width: 100%;
}

.voter-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    align-items: end;
}

/* Budget Progress Bar Styles */
.budget-header h3 {
    font-size: 1.3em;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 5px;
}

#spent-budget {
    color: #dc3545;
    font-weight: bold;
}

#total-budget {
    color: #6c757d;
    font-weight: 500;
}

.budget-progress-container {
    margin: 8px 0;
}

.budget-progress-bar {
    width: 100%;
    height: 16px;
    background: #345B7B;
    border-radius: 12px;
    padding: 4px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid #dee2e6;
}

.budget-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ffe98f 0%, #FFCB05 100%);
    width: 0%;
    transition: width 0.3s ease, background 0.3s ease;
    border-radius: 10px;
    position: relative;
}

.budget-progress-fill[data-progress="low"] {
    background: linear-gradient(90deg, #fff7d7 0%, #fff1ba 100%);
}

.budget-progress-fill[data-progress="medium"] {
    background: linear-gradient(90deg, #ffeb99 0%, #ffdf5f 100%);
}

.budget-progress-fill[data-progress="high"] {
    background: linear-gradient(90deg, #ffd52c 0%, #FFCB05 100%);
}

.budget-progress-fill.over-budget {
    background: #dc3545 !important;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }

    100% {
        opacity: 1;
    }
}

.budget-remaining {
    font-size: 0.95em;
    color: #666;
}

#remaining-budget {
    font-weight: bold;
    color: #2a8a2a;
    font-size: 1.1em;
}

#remaining-budget.over-budget {
    color: #d9534f;
}

.submission-area {
    text-align: center;
}

.voter-info>* {
    width: 100%;
}

#submit-votes {
    width: 100%;
    height: 100%;
    padding: 23px 14px;
    font-weight: bold;
    text-transform: uppercase;
    color: white;
    cursor: pointer;
    background: var(--color-primary);
    transition: background-color 0.3s ease, color 0.3s ease, transform 0.3s ease;
}

#submit-votes:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* Budget-related styling */
#product-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 64px;
    margin: 32px 0;
}

@media (max-width: 1024px) {

    .voter-info input[type="text"],
    .voter-info input[type="email"] {
        width: 100%;
    }

    .voter-info {
        flex-direction: column;
    }

    .voter-info label {
        width: auto;
        margin-bottom: 8px;
    }

    .voter-info p {
        margin-bottom: 12px;
    }

    /* Mobile responsive for product grid - single column */
    #product-list {
        grid-template-columns: 1fr !important;
        gap: 20px;
    }

    /* Mobile responsive for product cards - keep horizontal layout */
    .product-item {
        gap: 10px;
        display: flex;
        flex-direction: column !important;
    }

    .product-details {
        gap: 5px;
    }

    .product-title {
        font-size: 1em;
    }

    .product-price {
        font-size: 1em;
    }

    .quantity-controls {
        min-width: 100px;
        padding: 6px 12px;
    }

    .add-btn {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }

    .quantity-btn {
        width: 24px;
        height: 24px;
        font-size: 16px;
    }

    #product-list-offline {
        grid-template-columns: 1fr !important;
        gap: 20px;
    }

}

.product-item {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 0;
    background: transparent;
    border-radius: 12px;
    border: none;
    transition: all 0.3s ease;
    width: 100%;
}

.product-item.selected .product-image {
    border: 4px solid transparent;
    background: var(--color-primary);
}

.product-item.budget-disabled {
    /* Visually de-emphasize items that exceed the budget, but keep links clickable. */
    opacity: 0.4;
    filter: grayscale(50%);
    /* Don't disable pointer events for the whole card so links remain interactive. */
}

/* Don't fade selected items even if budget is exceeded */
.product-item.selected.budget-disabled {
    opacity: 1;
    filter: none;
    pointer-events: auto;
}

.product-item.budget-warning:not(.selected) {
    opacity: 0.7;
}

.product-image {
    flex-shrink: 0;
    width: 100%;
    height: auto;
    aspect-ratio: 3/2;
    overflow: hidden;
    transition: all 0.3s ease;
    border: 0px solid transparent;
    background: transparent;
    border-radius: var(--radius-lg);
}

/* Center and contain images within the 3:2 box */
.product-image > a,
.product-image > div {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-image img,
.product-image picture {
    object-fit: contain;
    max-width: 100%;
    width: 100%;
    height: auto;
    display: block;
}

.product-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.product-title {
    padding: 0;
    margin: 0;
    font-size: 1.2em;
    font-weight: 600;
    color: #333;
}

.product-price {
    margin: 0;
    font-size: 1em;
    font-weight: 500;
    color: #666;
}

.product-quantity {
    display: flex;
    align-items: center;
    gap: 8px;
    /* place below the image in normal document flow */
    position: relative;
    margin-top: 12px;
    width: 100%;
    justify-content: flex-start;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    /* white background */
    padding: 0 8px;
    min-width: 100px;
    justify-content: space-between;
    transition: all 0.12s ease;
    border: 2px solid #000;
    /* border-2 */
    border-radius: 6px;
    /* small rounded corners */
    height: 32px;
    /* requested height */
    box-sizing: border-box;
}

.quantity-btn {
    background: transparent;
    border: none;
    color: #111;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    width: 32px;
    height: 24px;
    /* requested 24px height */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.12s ease;
    flex-shrink: 0;
}

.quantity-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.quantity-display {
    color: #111;
    font-weight: 700;
    font-size: 14px;
    min-width: 24px;
    text-align: center;
    flex-shrink: 0;
}

/* hide legacy square add button if present */
.add-btn {
    display: none;
}

.add-btn:hover {
    background: #345B7B;
}

.add-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Hide original quantity input */
.quantity-input {
    display: none;
}

/* Offline product grid spacing mirrors online */
#product-list-offline {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 64px;
    margin: 32px 0;
}

/* Offline-only quantity control sizing: larger and easier to tap/click */
#product-list-offline .product-quantity {
    gap: 10px;
}

#product-list-offline .quantity-controls {
    min-width: 120px;
    height: 40px;
    padding: 0 10px;
    border-radius: 8px;
}

#product-list-offline .quantity-btn {
    width: 32px;
    height: 32px;
    font-size: 20px;
}

#product-list-offline .quantity-display {
    font-size: 16px;
    min-width: 28px;
}

.product-item.budget-disabled .quantity-controls,
.product-item.budget-disabled .add-btn {
    opacity: 0.3;
    /* Keep the controls visually disabled and block interaction on them specifically. */
    pointer-events: none;
}

/* Ensure links inside a budget-disabled product remain clickable */
.product-item.budget-disabled a {
    pointer-events: auto;
    color: inherit;
}

/* Also specifically disable quantity buttons inside disabled cards for accessibility */
.product-item.budget-disabled .quantity-btn {
    pointer-events: none;
}

.quantity-input:invalid,
.quantity-input.budget-exceeded {
    border-color: #d9534f;
    background-color: #f2dede;
}

.marketplace-notice {
    padding: 12px;
    margin: 10px 0;
    border-radius: 4px;
    border: 1px solid transparent;
}

.marketplace-notice.marketplace-error {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
}

.marketplace-notice.marketplace-success {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
}

.budget-warning-text {
    color: #856404;
    font-size: 0.9em;
    font-style: italic;
    margin-top: 5px;
}

/* Notice styles */
.marketplace-notice {
    padding: 15px;
    border-radius: 5px;
    margin: 15px 0;
}

.marketplace-error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.marketplace-info {
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

/* Toast/Modal styles for message area */
.marketplace-toast {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 12px;
    z-index: 9999;
    margin: 0 auto;
    width: calc(100% - 24px);
    box-sizing: border-box;
    padding: 14px 16px;
    border-radius: 4px;
    /* rounded top on mobile full-width */
    border-width: 2px;
    border-style: solid;
    transform: translateY(110%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.22s ease-out, opacity 0.22s ease-out;
}

.marketplace-toast.is-visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* Fade in up / fade out down animations */
@keyframes marketplace-fade-in-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes marketplace-fade-out-down {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(20px);
    }
}

.marketplace-toast.anim-in {
    animation: marketplace-fade-in-up 0.24s ease-out both;
}

.marketplace-toast.anim-out {
    animation: marketplace-fade-out-down 0.24s ease-in both;
}

/* Large screens: bottom-right floating, width fits content/text */
@media (min-width: 1024px) {
    .marketplace-toast {
        left: auto;
        right: 24px;
        bottom: 24px;
        width: auto;
        max-width: 480px;
        border-radius: 10px;
        /* fully rounded on desktop */
        box-shadow: var(--shadow-sm);
        transform: translateY(10px);
    }

    .marketplace-toast.is-visible {
        transform: translateY(0);
    }
}

/* Color system using colors-sticky-[type] utility classes, with fallbacks */
.marketplace-toast.colors-sticky-info,
.marketplace-toast.marketplace-info {
    background-color: #d1ecf1;
    border-color: #bee5eb;
    color: #0c5460;
}

.marketplace-toast.colors-sticky-success,
.marketplace-toast.marketplace-success {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.marketplace-toast.colors-sticky-error,
.marketplace-toast.marketplace-error {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.marketplace-toast .toast-close {
    appearance: none;
    background: transparent;
    border: 0;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.marketplace-tag-opens {
    background: #3498db;
}

.marketplace-tag-closes {
    background: #e67e22;
}

.marketplace-tag {
    color: #fff;
    background: #e67e22;
    padding: 4px 16px;
    border-radius: 50px;
    font-size: 1em;
    font-weight: medium;
}

#marketplace-form {
    margin-top: 24px;
}

#marketplace .voter-info {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 20px
}

#marketplace .floating-field {
    position: relative
}

#marketplace .floating-field input {
    width: 100%;
    box-sizing: border-box;
    padding: 32px 14px 14px;
    font-size: 18px;
    line-height: 1.2;
    border: 2px solid #000;
    /* border-radius: 4px; */
    background: transparent;
    outline: none;
    transition: border-color .18s ease;
}

#marketplace .floating-field input:focus {
    border-color: #1c333e;
    border-width: 1.7px;
}

#marketplace .floating-field label {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 700;
    letter-spacing: .02em;
    color: #111;
    pointer-events: none;
    transition: top .18s ease, transform .18s ease, font-size .18s ease, color .18s ease;
}

#marketplace .floating-field input:focus+label,
#marketplace .floating-field input:not(:placeholder-shown)+label,
#marketplace .floating-field.has-value label {
    top: 10px;
    transform: none;
    font-size: .85rem;
    color: black;
}

/* Offline form floating-field styles (mirror online marketplace styles) */
#marketplace-offline .floating-field { position: relative; }
#marketplace-offline .floating-field input {
    width: 100%;
    box-sizing: border-box;
    padding: 32px 14px 14px;
    font-size: 18px;
    line-height: 1.2;
    border: 2px solid #000;
    background: transparent;
    outline: none;
    transition: border-color .18s ease;
}
#marketplace-offline .floating-field input:focus {
    border-color: #1c333e;
    border-width: 1.7px;
}
#marketplace-offline .floating-field label {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 700;
    letter-spacing: .02em;
    color: #111;
    pointer-events: none;
    transition: top .18s ease, transform .18s ease, font-size .18s ease, color .18s ease;
}
#marketplace-offline .floating-field input:focus+label,
#marketplace-offline .floating-field input:not(:placeholder-shown)+label,
#marketplace-offline .floating-field.has-value label {
    top: 10px;
    transform: none;
    font-size: .85rem;
    color: black;
}
/* On small screens, ensure label always stays attached to its field using has-value + focus */
@media (max-width: 760px) {
    #marketplace-offline .floating-field label {
        top: 50%;
        transform: translateY(-50%);
    }
    #marketplace-offline .floating-field.has-value label,
    #marketplace-offline .floating-field input:focus+label {
        top: 10px;
        transform: none;
    }
}


.product-tagline {
    font-size: 0.95em;
    font-style: italic;
}

/* IPD Button Full Width - Replica of large IPD theme button */
.button-full-width {
    position: relative;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: bold;
    font-size: 20px;
    line-height: 1.2;
    padding: calc(0.25rem * 6) calc(0.25rem * 8);
    color: #fff;
    background-color: #315472;
    border: 2px solid #000;
    border-radius: 6px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    transition: all 0.2s ease-out;
    -webkit-user-select: none;
    user-select: none;
    appearance: none;
    text-decoration: none;
}

.button-full-width:hover {
    background-color: #2a4660;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.button-full-width:active {
    transform: translateY(1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.button-full-width:focus {
    outline: 3px solid #FFCB05;
    outline-offset: 2px;
}

.button-full-width:disabled {
    cursor: not-allowed;
    opacity: 0.5;
    transform: none;
    box-shadow: none;
}

.button-full-width:disabled:hover {
    background-color: #315472;
    transform: none;
    box-shadow: none;
}