/* Base styles */
body {
    font-family: sans-serif;
    background-color: #f9fafb;
    /* bg-gray-50 */
    min-height: 100vh;
    padding: 0.5rem;
    /* Reduced from 2rem */
}

.container {
    max-width: 90%;
    /* Increased max width for wider horizontal spread */
    margin-left: auto;
    margin-right: auto;
}

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

.font-extrabold {
    font-weight: 800;
}

.text-gray-800 {
    color: #1f2937;
}

.mb-6 {
    margin-bottom: 0.5rem;
    /* Reduced from 1.5rem */
}

.mb-8 {
    margin-bottom: 1rem;
    /* Reduced from 2rem */
}

.mt-8 {
    margin-top: 1rem;
    /* Reduced from 2rem */
}

.mt-6 {
    margin-top: 1rem;
    /* Reduced from 1.5rem */
}

.mt-4 {
    margin-top: 0.5rem;
    /* Reduced from 1rem */
}

.mb-4 {
    margin-bottom: 0.5rem;
    /* Reduced from 1rem */
}

.p-6 {
    padding: 1rem;
    /* Reduced from 1.5rem */
}

.p-4 {
    padding: 0.75rem;
    /* Reduced from 1rem */
}

.p-3 {
    padding: 0.5rem;
    /* Reduced from 0.75rem */
}

.rounded-xl {
    border-radius: 0.5rem;
    /* Reduced radius slightly */
}

.shadow-lg {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.shadow-2xl {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* Master Envelope Styles */
.master-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    /* Further reduced gap */
    padding: 1rem;
    /* Further reduced padding */
    min-height: 100px;
    /* Further reduced height */
    background-color: #eef4ff;
    /* bg-blue-50 */
    border: 2px solid #a855f7;
    /* Violet border */
    border-radius: 0.75rem;
    margin-bottom: 1.5rem;
    /* Optimized margin */
}

@media (min-width: 640px) {

    /* sm: */
    .master-box {
        flex-direction: row;
        justify-content: space-around;
    }
}

.text-indigo-700 {
    color: #4338ca;
}

.text-indigo-800 {
    color: #3730a3;
}

.text-6xl {
    font-size: 3.75rem;
    line-height: 1;
}

.text-5xl {
    font-size: 3rem;
    line-height: 1;
}

.text-4xl {
    font-size: 1.875rem;
    /* Reduced from 2.25rem */
    line-height: 2.25rem;
}

.text-3xl {
    font-size: 1.5rem;
    line-height: 2rem;
}

.text-lg {
    font-size: 1.125rem;
    line-height: 1.25rem;
}

.text-sm {
    font-size: 0.75rem;
    /* Reduced from 0.875rem */
    line-height: 1rem;
}

.text-xs {
    font-size: 0.7rem;
    /* Reduced from 0.75rem */
    line-height: 0.9rem;
}

.font-semibold {
    font-weight: 600;
}

.font-bold {
    font-weight: 700;
}

/* Drag Handle */
.drag-handle {
    cursor: grab;
    user-select: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #a855f7;
    /* bg-violet-500 */
    color: white;
    padding: 0.75rem;
    /* Reduced from 1rem */
    border-radius: 9999px;
    box-shadow: 0 4px 14px rgba(168, 85, 247, 0.4);
    transition: all 0.2s;
    transform: scale(1.0);
    font-size: 1.5rem;
    /* Reduced from 2rem */
    width: 3rem;
    /* Reduced from 4rem */
    height: 3rem;
    /* Reduced from 4rem */
}

.drag-handle:active {
    cursor: grabbing;
    box-shadow: 0 2px 8px rgba(168, 85, 247, 0.6);
    transform: scale(0.95);
}

/* Envelope Grid and Cards - 4 over 3 Layout */
.envelope-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 0.75rem;
    /* Reduced from 1.5rem */
    padding: 0 0.25rem;
}

@media (min-width: 640px) {

    /* sm: */
    .envelope-grid {
        grid-template-columns: repeat(6, 1fr);
        /* 8 columns for precise centering */
        justify-content: center;
    }
}

.envelope-card {
    min-height: 140px;
    /* Reduced from 200px */
    background-color: #ffffff;
    border: 2px solid #a855f7;
    /* Violet border */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    /* Indicate it's clickable */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 0.25rem;
    /* Reduced from 0.5rem */
}

.envelope-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 12px rgba(0, 0, 0, 0.15);
}

/* Explicit placement for 4-over-3 layout on desktop (E5, E6, E7 centered) */
@media (min-width: 640px) {

    /* Row 1: Spans 2 columns each in 8-column grid */
    .envelope-card:nth-child(1),
    .envelope-card:nth-child(2),
    .envelope-card:nth-child(3),
    .envelope-card:nth-child(4) {
        grid-column: span 2;
    }

    /* Row 2: Centered 3 items */
    .envelope-card:nth-child(5) {
        grid-column: span 2;
        /* Start at col 2 */
        margin-top: 0.75rem;
        /* Reduced from 1rem */
    }

    .envelope-card:nth-child(6) {
        grid-column: span 2;
        margin-top: 0.75rem;
        /* Reduced from 1rem */
    }

    .envelope-card:nth-child(7) {
        grid-column: span 2;
        /* Ends at col 7 */
        margin-top: 0.75rem;
        /* Reduced from 1rem */
    }
}

/* Highlight target on drag over */
.drag-over {
    border: 4px dashed #a855f7;
    /* Violet */
    background: #f3e8ff;
    /* Light Violet */
}

/* Envelope State Visuals */
.filled-envelope {
    border-color: #10b981;
    /* Green for allocated */
}

/* General styles */
.currency {
    font-weight: 700;
}

.text-2xl {
    font-size: 1.25rem;
    /* Reduced from 1.5rem */
    line-height: 1.75rem;
}

.text-xl {
    font-size: 1.125rem;
    /* Reduced from 1.25rem */
    line-height: 1.5rem;
}

/* .text-lg is defined above */

.text-gray-700 {
    color: #374151;
}

.text-green-700 {
    color: #047857;
}

.text-indigo-600 {
    color: #4f46e5;
}

.text-gray-500 {
    color: #6b7280;
}

.w-full {
    width: 100%;
}

.p-2 {
    padding: 0.5rem;
}

.p-1 {
    padding: 0.25rem;
}

.border-gray-300 {
    border-color: #d1d5db;
}

.shadow-sm {
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.focus-ring-indigo-500:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.5);
}

.flex {
    display: flex;
}

.justify-end {
    justify-content: flex-end;
}

.space-x-3>*+* {
    margin-left: 0.5rem;
    /* Reduced from 0.75rem */
}

.space-x-2>*+* {
    margin-left: 0.5rem;
}

.block {
    display: block;
}

.relative {
    position: relative;
}

.absolute {
    position: absolute;
}

.top-2 {
    top: 0.25rem;
    /* Reduced from 0.5rem */
}

.right-2 {
    right: 0.25rem;
    /* Reduced from 0.5rem */
}

.text-white {
    color: white;
}

.transition-colors {
    transition-property: background-color, border-color, color;
    transition-duration: 150ms;
}

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

.bg-gray-400 {
    background-color: #9ca3af;
}

.bg-green-600 {
    background-color: #059669;
}

.hover-bg-green-700:hover {
    background-color: #047857;
}

.bg-gray-200 {
    background-color: #e5e7eb;
}

.hover-bg-gray-300:hover {
    background-color: #d1d5db;
}

.bg-indigo-600 {
    background-color: #4f46e5;
}

.hover-bg-indigo-700:hover {
    background-color: #4338ca;
}

.bg-red-100 {
    background-color: #fee2e2;
}

.text-red-800 {
    color: #991b1b;
}

.bg-green-100 {
    background-color: #d1fae5;
}

.text-green-800 {
    color: #065f46;
}

.bg-blue-100 {
    background-color: #dbeafe;
}

.text-blue-800 {
    color: #1e40af;
}

/* Utility classes must be at the end to override others */
.top-0 {
    top: 0;
}

.right-0 {
    right: 0;
}

.text-gray-400 {
    color: #9ca3af;
}

.hover-text-red-500:hover {
    color: #ef4444;
}

.drag-over {
    border: 4px dashed #a855f7;
    /* Violet */
    background: #f3e8ff;
    /* Light Violet */
}

/* Envelope State Visuals */
.filled-envelope {
    border-color: #10b981;
    /* Green for allocated */
}

/* General styles */
.currency {
    font-weight: 700;
}

.text-2xl {
    font-size: 1.25rem;
    /* Reduced from 1.5rem */
    line-height: 1.75rem;
}

.text-xl {
    font-size: 1.125rem;
    /* Reduced from 1.25rem */
    line-height: 1.5rem;
}

/* .text-lg is defined above */

.text-gray-700 {
    color: #374151;
}

.text-green-700 {
    color: #047857;
}

.text-indigo-600 {
    color: #4f46e5;
}

.text-gray-500 {
    color: #6b7280;
}

.w-full {
    width: 100%;
}

.p-2 {
    padding: 0.5rem;
}

.p-1 {
    padding: 0.25rem;
}

.border-gray-300 {
    border-color: #d1d5db;
}

.shadow-sm {
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.focus-ring-indigo-500:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.5);
}

.flex {
    display: flex;
}

.justify-end {
    justify-content: flex-end;
}

.space-x-3>*+* {
    margin-left: 0.5rem;
    /* Reduced from 0.75rem */
}

.space-x-2>*+* {
    margin-left: 0.5rem;
}

.block {
    display: block;
}

.relative {
    position: relative;
}

.absolute {
    position: absolute;
}

.top-2 {
    top: 0.25rem;
    /* Reduced from 0.5rem */
}

.right-2 {
    right: 0.25rem;
    /* Reduced from 0.5rem */
}

.text-white {
    color: white;
}

.transition-colors {
    transition-property: background-color, border-color, color;
    transition-duration: 150ms;
}

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

.bg-gray-400 {
    background-color: #9ca3af;
}

.bg-green-600 {
    background-color: #059669;
}

.hover-bg-green-700:hover {
    background-color: #047857;
}

.bg-gray-200 {
    background-color: #e5e7eb;
}

.hover-bg-gray-300:hover {
    background-color: #d1d5db;
}

.bg-indigo-600 {
    background-color: #4f46e5;
}

.hover-bg-indigo-700:hover {
    background-color: #4338ca;
}

.bg-red-100 {
    background-color: #fee2e2;
}

.text-red-800 {
    color: #991b1b;
}

.bg-green-100 {
    background-color: #d1fae5;
}

.text-green-800 {
    color: #065f46;
}

.bg-blue-100 {
    background-color: #dbeafe;
}

.text-blue-800 {
    color: #1e40af;
}

/* Utility classes must be at the end to override others */
.top-0 {
    top: 0;
}

.right-0 {
    right: 0;
}

.text-gray-400 {
    color: #9ca3af;
}

.hover-text-red-500:hover {
    color: #ef4444;
}

.hidden {
    display: none !important;
}

/* Custom Submit Button Style */
#submitBtn {
    padding-top: 1.25rem;
    padding-bottom: 1.25rem;
    font-size: 1.25rem;
}

/* Modal Styles */
.fixed {
    position: fixed;
}

.inset-0 {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
}

.bg-opacity-75 {
    background-color: rgba(17, 24, 39, 0.75);
}

.z-50 {
    z-index: 50;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.max-w-2xl {
    max-width: 42rem;
}

.mx-4 {
    margin-left: 1rem;
    margin-right: 1rem;
}

.list-disc {
    list-style-type: disc;
}

.pl-6 {
    padding-left: 1.5rem;
}

.space-y-4>*+* {
    margin-top: 1rem;
}

.space-y-2>*+* {
    margin-top: 0.5rem;
}

.leading-relaxed {
    line-height: 1.625;
}

.focus-ring-indigo-500:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.5);
}

.flex {
    display: flex;
}

.justify-end {
    justify-content: flex-end;
}

.space-x-3>*+* {
    margin-left: 0.5rem;
    /* Reduced from 0.75rem */
}

.space-x-2>*+* {
    margin-left: 0.5rem;
}

.block {
    display: block;
}

.relative {
    position: relative;
}

.absolute {
    position: absolute;
}

.top-2 {
    top: 0.25rem;
    /* Reduced from 0.5rem */
}

.right-2 {
    right: 0.25rem;
    /* Reduced from 0.5rem */
}

.text-white {
    color: white;
}

.transition-colors {
    transition-property: background-color, border-color, color;
    transition-duration: 150ms;
}

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

.bg-gray-400 {
    background-color: #9ca3af;
}

.bg-green-600 {
    background-color: #059669;
}

.hover-bg-green-700:hover {
    background-color: #047857;
}

.bg-gray-200 {
    background-color: #e5e7eb;
}

.hover-bg-gray-300:hover {
    background-color: #d1d5db;
}

.bg-indigo-600 {
    background-color: #4f46e5;
}

.hover-bg-indigo-700:hover {
    background-color: #4338ca;
}

.bg-red-100 {
    background-color: #fee2e2;
}

.text-red-800 {
    color: #991b1b;
}

.bg-green-100 {
    background-color: #d1fae5;
}

.text-green-800 {
    color: #065f46;
}

.bg-blue-100 {
    background-color: #dbeafe;
}

.text-blue-800 {
    color: #1e40af;
}

/* Utility classes must be at the end to override others */
.top-0 {
    top: 0;
}

.right-0 {
    right: 0;
}

.text-gray-400 {
    color: #9ca3af;
}

.hover-text-red-500:hover {
    color: #ef4444;
}

.hidden {
    display: none !important;
}

/* Custom Submit Button Style */
#submitBtn {
    padding-top: 1.25rem;
    padding-bottom: 1.25rem;
    font-size: 1.25rem;
}

/* Modal Styles */
.fixed {
    position: fixed;
}

.inset-0 {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
}

.bg-opacity-75 {
    background-color: rgba(17, 24, 39, 0.75);
}

.z-50 {
    z-index: 50;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.max-w-2xl {
    max-width: 42rem;
}

.mx-4 {
    margin-left: 1rem;
    margin-right: 1rem;
}

.list-disc {
    list-style-type: disc;
}

.pl-6 {
    padding-left: 1.5rem;
}

.space-y-4>*+* {
    margin-top: 1rem;
}

.space-y-2>*+* {
    margin-top: 0.5rem;
}

.leading-relaxed {
    line-height: 1.625;
}

.bg-gray-900 {
    background-color: #111827;
}

.bg-white {
    background-color: #ffffff;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
}

.modal-content {
    background-color: white;
    padding: 2rem;
    border-radius: 0.75rem;

    .relative {
        position: relative;
    }

    .absolute {
        position: absolute;
    }

    .top-2 {
        top: 0.25rem;
        /* Reduced from 0.5rem */
    }

    .right-2 {
        right: 0.25rem;
        /* Reduced from 0.5rem */
    }

    .text-white {
        color: white;
    }

    .transition-colors {
        transition-property: background-color, border-color, color;
        transition-duration: 150ms;
    }

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

    .bg-gray-400 {
        background-color: #9ca3af;
    }

    .bg-green-600 {
        background-color: #059669;
    }

    .hover-bg-green-700:hover {
        background-color: #047857;
    }

    .bg-gray-200 {
        background-color: #e5e7eb;
    }

    .hover-bg-gray-300:hover {
        background-color: #d1d5db;
    }

    .bg-indigo-600 {
        background-color: #4f46e5;
    }

    .hover-bg-indigo-700:hover {
        background-color: #4338ca;
    }

    .bg-red-100 {
        background-color: #fee2e2;
    }

    .text-red-800 {
        color: #991b1b;
    }

    .bg-green-100 {
        background-color: #d1fae5;
    }

    .text-green-800 {
        color: #065f46;
    }

    .bg-blue-100 {
        background-color: #dbeafe;
    }

    .text-blue-800 {
        color: #1e40af;
    }

    /* Utility classes must be at the end to override others */
    .top-0 {
        top: 0;
    }

    .right-0 {
        right: 0;
    }

    .text-gray-400 {
        color: #9ca3af;
    }

    .hover-text-red-500:hover {
        color: #ef4444;
    }

    .hidden {
        display: none !important;
    }

    /* Custom Submit Button Style */
    #submitBtn {
        padding-top: 1.25rem;
        padding-bottom: 1.25rem;
        font-size: 1.25rem;
    }

    /* Modal Styles */
    .fixed {
        position: fixed;
    }

    .inset-0 {
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
    }

    .bg-opacity-75 {
        background-color: rgba(17, 24, 39, 0.75);
    }

    .z-50 {
        z-index: 50;
    }

    .items-center {
        align-items: center;
    }

    .justify-center {
        justify-content: center;
    }

    .max-w-2xl {
        max-width: 42rem;
    }

    .mx-4 {
        margin-left: 1rem;
        margin-right: 1rem;
    }

    .list-disc {
        list-style-type: disc;
    }

    .pl-6 {
        padding-left: 1.5rem;
    }

    .space-y-4>*+* {
        margin-top: 1rem;
    }

    .space-y-2>*+* {
        margin-top: 0.5rem;
    }

    .leading-relaxed {
        line-height: 1.625;
    }

    .bg-gray-900 {
        background-color: #111827;
    }

    .bg-white {
        background-color: #ffffff;
    }

    /* Modal Styles */
    .modal-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        display: flex;
        justify-content: center;
        align-items: center;
        z-index: 50;
    }

    .modal-content {
        background-color: white;
        padding: 2rem;
        border-radius: 0.75rem;
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
        position: relative;
    }

    .absolute {
        position: absolute;
    }

    .top-2 {
        top: 0.25rem;
        /* Reduced from 0.5rem */
    }

    .right-2 {
        right: 0.25rem;
        /* Reduced from 0.5rem */
    }

    .text-white {
        color: white;
    }

    .transition-colors {
        transition-property: background-color, border-color, color;
        transition-duration: 150ms;
    }

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

    .bg-gray-400 {
        background-color: #9ca3af;
    }

    .bg-green-600 {
        background-color: #059669;
    }

    .hover-bg-green-700:hover {
        background-color: #047857;
    }

    .bg-gray-200 {
        background-color: #e5e7eb;
    }

    .hover-bg-gray-300:hover {
        background-color: #d1d5db;
    }

    .bg-indigo-600 {
        background-color: #4f46e5;
    }

    .hover-bg-indigo-700:hover {
        background-color: #4338ca;
    }

    .bg-red-100 {
        background-color: #fee2e2;
    }

    .text-red-800 {
        color: #991b1b;
    }

    .bg-green-100 {
        background-color: #d1fae5;
    }

    .text-green-800 {
        color: #065f46;
    }

    .bg-blue-100 {
        background-color: #dbeafe;
    }

    .text-blue-800 {
        color: #1e40af;
    }

    /* Utility classes must be at the end to override others */
    .top-0 {
        top: 0;
    }

    .right-0 {
        right: 0;
    }

    .text-gray-400 {
        color: #9ca3af;
    }

    .hover-text-red-500:hover {
        color: #ef4444;
    }

    .hidden {
        display: none !important;
    }

    /* Custom Submit Button Style */
    #submitBtn {
        padding-top: 1.25rem;
        padding-bottom: 1.25rem;
        font-size: 1.25rem;
    }

    /* Modal Styles */
    .fixed {
        position: fixed;
    }

    .inset-0 {
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
    }

    .bg-opacity-75 {
        background-color: rgba(17, 24, 39, 0.75);
    }

    .z-50 {
        z-index: 50;
    }

    .items-center {
        align-items: center;
    }

    .justify-center {
        justify-content: center;
    }

    .max-w-2xl {
        max-width: 42rem;
    }

    .mx-4 {
        margin-left: 1rem;
        margin-right: 1rem;
    }

    .list-disc {
        list-style-type: disc;
    }

    .pl-6 {
        padding-left: 1.5rem;
    }

    .space-y-4>*+* {
        margin-top: 1rem;
    }

    .space-y-2>*+* {
        margin-top: 0.5rem;
    }

    .leading-relaxed {
        line-height: 1.625;
    }

    .bg-gray-900 {
        background-color: #111827;
    }

    .bg-white {
        background-color: #ffffff;
    }

    /* Modal Styles */
    .modal-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        display: flex;
        justify-content: center;
        align-items: center;
        z-index: 50;
    }

    .modal-content {
        background-color: white;
        padding: 2rem;
        border-radius: 0.75rem;
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
        max-width: 32rem;
        width: 100%;
        margin: 0 1rem;
        position: relative;
        max-height: 90vh;
        overflow-y: auto;
    }

    .bg-orange-600 {
        background-color: #ea580c;
    }

    .hover-bg-orange-700:hover {
        background-color: #c2410c;
    }