:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --bg-dark: #0f172a;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --success: #10b981;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow-x: auto;
    /* Allow horizontal scrolling */
    overflow-y: auto;
    position: relative;
    padding-top: 120px;
    padding-left: 20px;
    padding-right: 20px;
    padding-bottom: 40px;
}

/* Background Blobs */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    filter: blur(80px);
}

.blob {
    position: absolute;
    border-radius: 50%;
    opacity: 0.6;
    animation: move 20s infinite alternate;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: #4f46e5;
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 350px;
    height: 350px;
    background: #7c3aed;
    bottom: -50px;
    right: -50px;
    animation-delay: -5s;
}

.blob-3 {
    width: 300px;
    height: 300px;
    background: #2563eb;
    top: 50%;
    left: 40%;
    animation-delay: -10s;
}

@keyframes move {
    from {
        transform: translate(0, 0) scale(1);
    }

    to {
        transform: translate(100px, 100px) scale(1.1);
    }
}

/* App Container */
.app-container {
    width: 100%;
    max-width: 100%;
    z-index: 1;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    /* Top-align boxes to prevent jumping when content expands */
    justify-content: center;
    gap: 30px;
    padding: 0;
}

.app-container.wide {
    width: auto;
}

.app-header {
    position: fixed;
    top: 30px;
    left: 40px;
    right: 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    z-index: 100;
}

.main-title {
    font-family: 'Courier New', Courier, monospace;
    /* Monospaced font for perfect typewriter effect */
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
    margin: 0;

    /* Typewriter animation */
    display: inline-block;
    overflow: hidden;
    white-space: nowrap;
    border-right: 4px solid transparent;
    /* Set to transparent by default */
    width: 0;
    animation:
        typing 2s steps(18, end) forwards,
        blink-caret 0.5s step-end 4;
    /* Blinks for 2 seconds, then stops (reverting to transparent) */
}

.logout-button {
    background: rgba(239, 68, 68, 0.1);
    border: 2px solid #ef4444;
    color: #ef4444;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Outfit', sans-serif;
}

.logout-button:hover {
    background: #ef4444;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(239, 68, 68, 0.3);
}

@keyframes typing {
    from {
        width: 0
    }

    to {
        width: 18ch
    }
}

@keyframes blink-caret {

    50% {
        border-color: var(--primary)
    }
}

.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 32px;
    /* 20% smaller: 40 * 0.8 = 32 */
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    width: 100%;
    position: relative;
    /* Removed overflow: hidden to prevent button/shadow cutoff */
}

/* States */
.state {
    display: flex;
    /* Always display */
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 16px;
    width: 360px;
    /* 20% smaller: 450 * 0.8 = 360 */
    min-width: 320px;
    max-width: 400px;
    flex-shrink: 1;
    /* Allow shrinking on smaller screens */
    opacity: 0.1;
    /* Very dimmed initially */
    filter: grayscale(100%) blur(5px);
    transform: scale(0.85);
    pointer-events: none;
    transition: all 0.8s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.state.active {
    opacity: 1;
    filter: grayscale(0%) blur(0px);
    transform: scale(1.05);
    /* Slightly bigger when active */
    pointer-events: all;
    z-index: 5;
}

.state.active .glass-card {
    border-color: var(--primary);
    box-shadow: 0 0 60px rgba(79, 70, 229, 0.4);
}

.state.completed {
    opacity: 0.5;
    filter: grayscale(40%) blur(0px);
    transform: scale(0.95);
    pointer-events: none;
}


/* Hero Content */
.icon-badge {
    font-size: 2.4rem;
    /* 20% smaller: 3 * 0.8 = 2.4 */
    margin-bottom: 16px;
}

h1 {
    font-size: 1.76rem;
    /* 20% smaller: 2.2 * 0.8 = 1.76 */
    font-weight: 700;
    margin-bottom: 12px;
    background: linear-gradient(to right, #fff, #94a3b8);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

h2 {
    font-size: 1.28rem;
    /* 20% smaller: 1.6 * 0.8 = 1.28 */
    margin-bottom: 12px;
}

p {
    color: var(--text-muted);
    font-size: 0.8rem;
    /* 20% smaller: 1 * 0.8 = 0.8 */
    line-height: 1.6;
    margin-bottom: 24px;
}

/* Buttons */
.btn-back {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    z-index: 10;
}

.btn-back:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateX(-2px);
}

.btn-back svg {
    width: 14px;
    height: 14px;
    transition: transform 0.3s ease;
}

.btn-back:hover svg {
    transform: translateX(-2px);
}

.btn-template {
    background: rgba(79, 70, 229, 0.1);
    border: 2px solid var(--primary);
    color: var(--primary);
    padding: 10px 20px;
    /* 20% smaller: 12*0.8=9.6, 24*0.8=19.2 */
    border-radius: 8px;
    font-size: 0.76rem;
    /* 20% smaller: 0.95 * 0.8 = 0.76 */
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    width: 100%;
    margin-bottom: 16px;
}

.btn-template:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(79, 70, 229, 0.3);
}

.btn-template svg {
    transition: transform 0.3s ease;
}

.btn-template:hover svg {
    transform: translateY(2px);
}

.btn-download-results {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border: none;
    padding: 13px 26px;
    /* 20% smaller */
    border-radius: 10px;
    font-size: 0.88rem;
    /* 20% smaller: 1.1 * 0.8 = 0.88 */
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 15px -3px rgba(245, 158, 11, 0.4);
    margin-bottom: 12px;
    width: 100%;
}

.btn-download-results:hover:not(:disabled) {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    transform: translateY(-2px);
    box-shadow: 0 15px 20px -5px rgba(245, 158, 11, 0.5);
}

.btn-download-results:active:not(:disabled) {
    transform: translateY(0);
}

.btn-download-results:disabled {
    background: #334155;
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.5;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 13px 26px;
    /* 20% smaller: 16*0.8=12.8, 32*0.8=25.6 */
    border-radius: 10px;
    font-size: 0.88rem;
    /* 20% smaller: 1.1 * 0.8 = 0.88 */
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.4);
    width: 100%;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 15px 20px -5px rgba(79, 70, 229, 0.5);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: #334155;
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.5;
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 12px 24px;
    border-radius: 10px;
    cursor: pointer;
    transition: 0.3s;
}

.btn-secondary:hover {
    background: var(--glass-border);
}

.btn-restart-premium {
    background: linear-gradient(135deg, #10b981 0%, #3b82f6 100%);
    color: white;
    border: none;
    padding: 16px 40px;
    border-radius: 14px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 20px -5px rgba(16, 185, 129, 0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 20px;
}

.btn-restart-premium:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 20px 30px -10px rgba(16, 185, 129, 0.6);
    filter: brightness(1.1);
}

.btn-restart-premium:active {
    transform: translateY(-1px) scale(0.98);
}

/* Upload Area */
.upload-area {
    width: 100%;
    border: 2px dashed var(--glass-border);
    border-radius: 14px;
    padding: 32px;
    /* 20% smaller: 40 * 0.8 = 32 */
    margin-bottom: 20px;
    transition: 0.3s;
    cursor: pointer;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.05);
}

.upload-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
    color: var(--primary);
    transition: 0.3s;
}

.upload-icon svg {
    width: 38px;
    /* 20% smaller: 48 * 0.8 = 38.4 */
    height: 38px;
}

.upload-area:hover .upload-icon {
    transform: scale(1.1);
    color: white;
}

.upload-text {
    color: var(--text-muted);
    font-size: 0.8rem;
    /* 20% smaller */
}

.upload-text span {
    color: white;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 4px;
}

.file-info {
    margin-top: 15px;
    font-weight: 600;
    color: var(--success);
}

/* Step Indicator */
.step-indicator {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--primary);
    margin-bottom: 10px;
    font-weight: 700;
}

/* Success Content */
.success-icon-container {
    width: 100px;
    height: 100px;
    margin: 0 auto 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.checkmark__circle {
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    stroke-width: 2;
    stroke-miterlimit: 10;
    stroke: var(--success);
    fill: none;
    animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.checkmark {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: block;
    stroke-width: 2;
    stroke: #fff;
    stroke-miterlimit: 10;
    box-shadow: inset 0px 0px 0px var(--success);
    animation: fill .4s ease-in-out .4s forwards, scale .3s ease-in-out .9s both;
}

.checkmark__check {
    transform-origin: 50% 50%;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}

@keyframes stroke {
    100% {
        stroke-dashoffset: 0;
    }
}

@keyframes scale {

    0%,
    100% {
        transform: none;
    }

    50% {
        transform: scale3d(1.1, 1.1, 1);
    }
}

@keyframes fill {
    100% {
        box-shadow: inset 0px 0px 0px 50px var(--success);
    }
}

.success-details {
    background: rgba(0, 0, 0, 0.2);
    padding: 20px;
    border-radius: 12px;
    width: 100%;
    margin-bottom: 30px;
    text-align: left;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.detail-item:last-child {
    border-bottom: none;
}

.detail-item span {
    color: var(--text-muted);
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .glass-card {
        padding: 25px;
        min-height: 400px;
    }

    h1 {
        font-size: 1.8rem;
    }
}

/* Excel Preview & Metadata Styling */
.wide-card {
    max-width: 1000px;
    align-self: center;
}

.preview-area {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    animation: fadeIn 0.5s ease forwards;
}

.metadata-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.meta-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.meta-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.meta-value {
    font-size: 1rem;
    font-weight: 700;
    color: white;
}

.table-container {
    width: 100%;
    overflow-x: auto;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
}

#excel-preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

#excel-preview-table th {
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--glass-border);
}

#excel-preview-table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    white-space: nowrap;
}

#excel-preview-table tr:last-child td {
    border-bottom: none;
}

/* Action Bar Adjustment */
.action-bar {
    display: flex;
    gap: 8px;
    width: 100%;
    justify-content: center;
    flex-wrap: nowrap;
    margin-top: 20px;
}

#btn-excel-upload,
#btn-zip-upload,
.action-bar .btn-primary,
.action-bar .btn-secondary {
    font-size: 0.8rem !important;
    padding: 12px 5px !important;
    /* Extra compact to fit 3 buttons */
    margin-right: 0 !important;
    flex: 1 !important;
    white-space: nowrap !important;
    min-width: 0 !important;
    height: 44px;
    /* Fixed height for uniformity */
    display: flex;
    align-items: center;
    justify-content: center;
}

#btn-excel-upload.success,
#btn-zip-upload.success {
    background: var(--success);
    border-color: var(--success);
    color: white;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
    font-size: 0.75rem !important;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeInModal 0.3s ease;
}

.modal-content {
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid var(--primary);
    border-radius: 24px;
    box-shadow: 0 0 40px rgba(79, 70, 229, 0.2);
    animation: slideUpModal 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 15px;
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 2rem;
    cursor: pointer;
    transition: 0.3s;
}

.btn-close:hover {
    color: white;
    transform: rotate(90deg);
}

#btn-excel-info,
#btn-zip-status {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary);
    border: 1px solid var(--primary);
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

#btn-excel-info:hover,
#btn-zip-status:hover {
    background: var(--primary);
    color: white;
    box-shadow: 0 0 20px rgba(79, 70, 229, 0.3);
}

@keyframes fadeInModal {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUpModal {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

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

/* ZIP Upload Status Modal Styles */
.upload-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

.summary-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: center;
}

.summary-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
}

.success-text {
    color: var(--success);
}

.error-text {
    color: #ef4444;
}

.progress-bar-container {
    position: relative;
    width: 100%;
    height: 40px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 25px;
    border: 1px solid var(--glass-border);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--success) 100%);
    border-radius: 20px;
    transition: width 0.3s ease;
    box-shadow: 0 0 20px rgba(79, 70, 229, 0.5);
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.upload-list-container {
    max-height: 400px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 15px;
    border: 1px solid var(--glass-border);
}

.upload-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.upload-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border-left: 3px solid transparent;
    transition: all 0.3s ease;
}

.upload-item-name {
    flex: 1;
    color: var(--text-main);
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 15px;
}

.upload-item-status {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

.upload-item.pending {
    border-left-color: var(--text-muted);
}

.upload-item.pending .upload-item-status {
    color: var(--text-muted);
}

.upload-item.uploading {
    border-left-color: var(--primary);
    animation: pulse 1.5s ease-in-out infinite;
}

.upload-item.uploading .upload-item-status {
    color: var(--primary);
}

.upload-item.success {
    border-left-color: var(--success);
    background: rgba(16, 185, 129, 0.05);
}

.upload-item.success .upload-item-status {
    color: var(--success);
}

.upload-item.error {
    border-left-color: #ef4444;
    background: rgba(239, 68, 68, 0.05);
}

.upload-item.error .upload-item-status {
    color: #ef4444;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* Custom scrollbar for upload list */
.upload-list-container::-webkit-scrollbar {
    width: 8px;
}

.upload-list-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.upload-list-container::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

.upload-list-container::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover);
}

/* Column Error Modal Styles */
.required-columns {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-top: 20px;
}

.column-item {
    background: rgba(79, 70, 229, 0.1);
    border: 2px solid var(--primary);
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.column-name {
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 1px;
}

.column-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    font-family: 'Outfit', sans-serif;
}