/* CSS Variables & Theme (Linear Style + Glassmorphism) */
:root {
    --bg-color: #050505;
    --primary-color: #6d5dfc;
    --primary-glow: rgba(109, 93, 252, 0.15);
    --panel-bg: rgba(255, 255, 255, 0.03);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --green-success: #10b981;
    --green-success-bg: rgba(16, 185, 129, 0.1);
    --red-error: #ef4444;
    --red-error-bg: rgba(239, 68, 68, 0.1);
    --orange-warning: #f59e0b;
    --orange-warning-bg: rgba(245, 158, 11, 0.15);
    
    --radius-outer: 28px;
    --radius-inner: 14px;
}

/* Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden; /* Lock viewport scroll */
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Neon Background Orbs */
.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    z-index: 0;
    pointer-events: none;
    opacity: 0.5;
}
.orb-1 {
    width: 250px;
    height: 250px;
    background-color: var(--primary-color);
    top: 15%;
    right: -50px;
}
.orb-2 {
    width: 300px;
    height: 300px;
    background-color: #3b82f6;
    bottom: 10%;
    left: -100px;
}
.orb-3 {
    width: 150px;
    height: 150px;
    background-color: #a855f7;
    top: 50%;
    left: 40%;
}

/* App Container (Emulating iPhone vertical size perfectly) */
.app-container {
    width: 100%;
    max-width: 430px; /* iPhone 15 Pro Max width */
    height: 100vh;
    max-height: 932px; /* iPhone 15 Pro Max height */
    background-color: rgba(5, 5, 5, 0.85);
    backdrop-filter: blur(40px);
    border: 1px solid var(--panel-border);
    border-radius: 40px;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    z-index: 10;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

@media (max-width: 440px) {
    /* Full screen on actual mobile devices */
    .app-container {
        border-radius: 0;
        border: none;
        max-height: 100vh;
    }
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.05em;
    background: linear-gradient(135deg, #fff 0%, #a855f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.status-badge {
    font-size: 0.7rem;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.status-badge::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--green-success);
}
.status-badge.online {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--green-success);
    border: 1px solid rgba(16, 185, 129, 0.15);
}

/* Main Layout */
.app-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow: hidden; /* Child containers will handle scrolling */
}

/* Glassmorphism Panel base */
.glass-panel {
    background-color: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-outer);
    padding: 20px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Upload Section */
.upload-section {
    flex-shrink: 0;
    padding: 6px; /* Tighter padding for outer border */
}

.upload-dropzone {
    border: 2px dashed rgba(109, 93, 252, 0.3);
    border-radius: 22px;
    padding: 24px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
}

.upload-dropzone:hover, .upload-dropzone.dragover {
    border-color: var(--primary-color);
    background-color: rgba(109, 93, 252, 0.05);
    box-shadow: 0 0 15px var(--primary-glow);
}

.file-input-hidden {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-icon {
    width: 44px;
    height: 44px;
    color: var(--primary-color);
    margin-bottom: 12px;
    transition: transform 0.2s ease;
}

.upload-dropzone:hover .upload-icon {
    transform: translateY(-4px);
}

.upload-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.upload-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Results / List Section */
.results-section {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow: hidden;
}

/* Welcome Card */
.welcome-card {
    text-align: center;
    padding: 30px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-grow: 1;
}

.welcome-text {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-muted);
}

/* Loading Card */
.loading-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    flex-grow: 1;
    gap: 16px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s linear infinite;
    box-shadow: 0 0 10px var(--primary-glow);
}

.loading-text {
    font-size: 0.95rem;
    font-weight: 500;
}

.loading-subtext {
    font-size: 0.75rem;
    color: var(--text-muted);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Summary Card */
.summary-card {
    padding: 16px 20px;
    flex-shrink: 0;
}

.summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.summary-title {
    font-size: 1rem;
    font-weight: 600;
}

.mismatch-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 10px;
}

.mismatch-badge.discrepancy {
    background-color: var(--orange-warning-bg);
    color: var(--orange-warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.mismatch-badge.success {
    background-color: var(--green-success-bg);
    color: var(--green-success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Transactions Container (Enables scroll inside iPhone screen limit) */
.transactions-container {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 4px;
}

/* Customize internal scrollbar for aesthetic glass feel */
.transactions-container::-webkit-scrollbar {
    width: 4px;
}
.transactions-container::-webkit-scrollbar-track {
    background: transparent;
}
.transactions-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.transactions-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 20px;
}

/* Transaction Card */
.tx-card {
    background-color: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-inner);
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    transition: all 0.2s ease;
    cursor: pointer;
}

.tx-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 70%;
}

.tx-title {
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tx-details {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.tx-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tx-amount {
    font-size: 0.95rem;
    font-weight: 600;
}

.tx-status-icon {
    width: 24px;
    height: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
}

/* Specific Transaction Statuses */
.tx-card.status-match {
    border-color: rgba(16, 185, 129, 0.2);
}
.tx-card.status-match .tx-status-icon {
    background-color: var(--green-success-bg);
    color: var(--green-success);
}

.tx-card.status-mismatch {
    border-color: rgba(239, 68, 68, 0.4);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.05);
}
.tx-card.status-mismatch .tx-status-icon {
    background-color: var(--red-error-bg);
    color: var(--red-error);
}

.tx-card.status-missing_in_statement {
    border-color: rgba(245, 158, 11, 0.3);
}
.tx-card.status-missing_in_statement .tx-status-icon {
    background-color: var(--orange-warning-bg);
    color: var(--orange-warning);
}

.tx-card.status-missing_in_sheets {
    border-color: rgba(245, 158, 11, 0.3);
}
.tx-card.status-missing_in_sheets .tx-status-icon {
    background-color: var(--orange-warning-bg);
    color: var(--orange-warning);
}

/* Discrepancy details display */
.mismatch-details {
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px dashed rgba(255, 255, 255, 0.05);
    font-size: 0.72rem;
    color: var(--text-muted);
}
.mismatch-details span {
    font-weight: 600;
    color: var(--text-primary);
}

/* Helpers */
.hidden {
    display: none !important;
}

/* Statement Credits Feed Section */
.statement-credits-section {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

.section-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.credits-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.credit-card {
    background-color: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-inner);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

/* Highlight credits NOT found in table */
.credit-card.unmatched {
    border-color: rgba(109, 93, 252, 0.25);
    background: rgba(109, 93, 252, 0.04);
}

.credit-card.matched {
    opacity: 0.5;
}

.credit-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-width: 75%;
}

.credit-desc {
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.credit-tag {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 6px;
    display: inline-block;
    align-self: flex-start;
}

.credit-tag.matched-tag {
    background-color: var(--green-success-bg);
    color: var(--green-success);
}

.credit-tag.unmatched-tag {
    background-color: var(--primary-glow);
    color: var(--primary-color);
    border: 1px solid rgba(109, 93, 252, 0.2);
}

.credit-amount {
    font-size: 0.88rem;
    font-weight: 600;
}

