:root {
    --bg-gradient: linear-gradient(135deg, #f3f6fc 0%, #e8f0fe 50%, #f0f4fd 100%);
    --card-bg: rgba(255, 255, 255, 0.88);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --primary-indigo: #6366f1;
    --primary-indigo-dark: #4f46e5;
    --primary-violet: #8b5cf6;
    --primary-light: #eef2ff;
    
    --accent-emerald: #10b981;
    --accent-emerald-dark: #059669;
    --accent-emerald-light: #ecfdf5;

    --border: rgba(226, 232, 240, 0.8);
    --border-hover: rgba(99, 102, 241, 0.4);
    
    --shadow-main: 0 25px 50px -12px rgba(99, 102, 241, 0.12), 0 10px 25px -5px rgba(15, 23, 42, 0.04);
    --shadow-btn: 0 10px 20px -5px rgba(99, 102, 241, 0.35);
    
    --radius-xl: 24px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    position: relative;
    overflow-x: hidden;
}

/* Ambient Animated Glowing Background Blobs */
.ambient-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.55;
    animation: floatBlob 20s infinite alternate ease-in-out;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.35) 0%, rgba(139, 92, 246, 0.15) 100%);
}

.blob-2 {
    bottom: -15%;
    right: -10%;
    width: 55vw;
    height: 55vw;
    background: radial-gradient(circle, rgba(14, 165, 233, 0.3) 0%, rgba(16, 185, 129, 0.15) 100%);
    animation-delay: -7s;
}

.blob-3 {
    top: 40%;
    left: 35%;
    width: 35vw;
    height: 35vw;
    background: radial-gradient(circle, rgba(236, 72, 153, 0.2) 0%, rgba(99, 102, 241, 0.1) 100%);
    animation-delay: -12s;
}

@keyframes floatBlob {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(40px, -30px) scale(1.08); }
    100% { transform: translate(-30px, 40px) scale(0.95); }
}

/* Main Container Structure */
.app-wrapper {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 520px;
}

.container {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    padding: 40px 36px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-main);
    transition: transform 0.3s ease;
}

/* Header & Typography */
.header {
    text-align: center;
    margin-bottom: 28px;
}

.badge-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--primary-light);
    color: var(--primary-indigo-dark);
    font-size: 12px;
    font-weight: 700;
    border-radius: 30px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.badge-dot {
    width: 7px;
    height: 7px;
    background: var(--primary-indigo);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--primary-indigo);
    animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(1.3); }
}

.gradient-title {
    font-family: 'Outfit', sans-serif;
    font-size: 34px;
    font-weight: 800;
    letter-spacing: -0.8px;
    background: linear-gradient(135deg, #1e1b4b 0%, #4338ca 50%, #6366f1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

.subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.55;
    max-width: 400px;
    margin: 0 auto 16px;
}

.features-bar {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 14px;
}

.feature-chip {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(241, 245, 249, 0.8);
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

/* Interactive Drag & Drop Upload Section */
.upload-section {
    margin-bottom: 24px;
}

.upload-card {
    display: block;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius-lg);
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

.upload-card:hover, .upload-card.drag-active {
    background: var(--primary-light);
    border-color: var(--primary-indigo);
    transform: translateY(-2px);
    box-shadow: 0 12px 24px -6px rgba(99, 102, 241, 0.15);
}

.upload-idle {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.icon-ring {
    width: 56px;
    height: 56px;
    background: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-indigo);
    box-shadow: 0 8px 16px -2px rgba(99, 102, 241, 0.15);
    margin-bottom: 14px;
    transition: transform 0.25s ease;
}

.upload-card:hover .icon-ring {
    transform: scale(1.1) rotate(-5deg);
    background: var(--primary-indigo);
    color: #ffffff;
}

.upload-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.browse-link {
    color: var(--primary-indigo);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.upload-hint {
    font-size: 12px;
    color: var(--text-muted);
}

#file {
    display: none;
}

/* Image Preview Container */
.file-preview-container {
    display: flex;
    align-items: center;
    gap: 14px;
    background: #ffffff;
    padding: 12px;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0,0,0,0.04);
    border: 1px solid var(--border);
    text-align: left;
}

.image-preview {
    width: 54px;
    height: 54px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.file-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.file-name-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size-text {
    font-size: 12px;
    color: var(--text-muted);
}

.change-file-btn {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-indigo);
    background: var(--primary-light);
    padding: 6px 12px;
    border-radius: 20px;
}

/* Primary Button */
.btn {
    width: 100%;
    padding: 16px 24px;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 700;
    font-family: inherit;
    border: none;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-indigo) 0%, var(--primary-indigo-dark) 100%);
    color: #ffffff;
    box-shadow: var(--shadow-btn);
}

.btn-primary::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -60%;
    width: 40%;
    height: 200%;
    background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.3) 50%, rgba(255,255,255,0) 100%);
    transform: rotate(25deg);
    transition: all 0.6s ease;
}

.btn-primary:hover::after {
    left: 140%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px -4px rgba(99, 102, 241, 0.45);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-arrow {
    transition: transform 0.2s ease;
}

.btn-primary:hover .btn-arrow {
    transform: translateX(4px);
}

/* Secondary Download Button */
.btn-secondary {
    background: linear-gradient(135deg, var(--accent-emerald) 0%, var(--accent-emerald-dark) 100%);
    color: #ffffff;
    box-shadow: 0 10px 20px -5px rgba(16, 185, 129, 0.35);
    margin-top: 24px;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px -4px rgba(16, 185, 129, 0.45);
}

/* Loading Indicator */
#loading {
    margin-top: 18px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-indigo);
}

#loading:not(:empty) {
    padding: 14px;
    background: var(--primary-light);
    border-radius: var(--radius-md);
    border: 1px dashed var(--primary-indigo);
    animation: pulseGlow 1.5s infinite ease-in-out;
}

@keyframes pulseGlow {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.2); }
    50% { opacity: 0.7; box-shadow: 0 0 0 10px rgba(99, 102, 241, 0); }
}

/* Results Section */
.result-section {
    margin-top: 32px;
    padding-top: 28px;
    border-top: 1px solid var(--border);
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.result-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.success-icon {
    width: 26px;
    height: 26px;
    background: var(--accent-emerald-light);
    color: var(--accent-emerald);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
}

.result-header h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.status-pill {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--accent-emerald-light);
    color: var(--accent-emerald-dark);
    padding: 4px 10px;
    border-radius: 20px;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.result-card {
    background: #ffffff;
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.result-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.06);
}

.card-icon-wrapper {
    font-size: 20px;
    width: 38px;
    height: 38px;
    background: #f8fafc;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.card-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.result-card .label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.result-card .value {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    word-break: break-word;
}

/* Highlight Card for Grand Total */
.result-card.highlight-card {
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    border-color: rgba(99, 102, 241, 0.3);
    grid-column: span 1;
}

.highlight-card .card-icon-wrapper {
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.15);
}

.highlight-card .label {
    color: var(--primary-indigo-dark);
}

.highlight-val {
    color: var(--primary-indigo-dark);
    font-size: 16px;
}

/* Footer */
.app-footer {
    margin-top: 28px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}
