:root {
    --primary: #132190;
    --primary-hover: #0d1660;
    --primary-light: rgba(19, 33, 144, 0.1);
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.1);
    --error: #ef4444;
    --error-light: rgba(239, 68, 68, 0.1);
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.back-link,
.back-link:visited,
.back-link:link {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    gap: 0.5rem;
    color: var(--gray-500);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
    transition: var(--transition);
}

.back-link:hover {
    color: var(--primary);
}

.header-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #010451 0%, var(--primary) 100%);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    box-shadow: var(--shadow-lg);
}

.header-icon svg {
    width: 32px;
    height: 32px;
    color: white;
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
    letter-spacing: -0.025em;
}

.header p {
    color: var(--gray-500);
    font-size: 1.05rem;
}

/* Steps */
.steps-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.step {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-100);
    transition: var(--transition);
}

.step:hover {
    box-shadow: var(--shadow-lg);
}

.step-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.step-number {
    width: 32px;
    height: 32px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.step-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-800);
}

.step-description {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-top: 0.125rem;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-md);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--gray-50);
}

.upload-area:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-area.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
    border-style: solid;
}

.upload-area.has-file {
    border-color: var(--success);
    background: var(--success-light);
    border-style: solid;
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.upload-icon {
    width: 56px;
    height: 56px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-icon svg {
    width: 28px;
    height: 28px;
    color: var(--primary);
}

.upload-text {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.upload-main {
    font-weight: 600;
    color: var(--gray-700);
}

.upload-sub {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.upload-formats {
    font-size: 0.75rem;
    color: var(--gray-400);
    background: var(--gray-100);
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-sm);
}

/* File Info */
.file-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--success-light);
    border: 1px solid var(--success);
    border-radius: var(--radius-md);
    margin-top: 1rem;
}

.file-icon {
    width: 40px;
    height: 40px;
    background: var(--success);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-icon svg {
    width: 20px;
    height: 20px;
    color: white;
}

.file-details {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.file-name {
    font-weight: 600;
    color: var(--gray-800);
}

.file-size {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.btn-remove {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-remove:hover {
    background: var(--error-light);
}

.btn-remove svg {
    width: 18px;
    height: 18px;
    color: var(--gray-500);
}

.btn-remove:hover svg {
    color: var(--error);
}

/* Mapping Section */
.mapping-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: 0.875rem;
    color: var(--primary);
}

.mapping-info svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.mapping-table-container {
    overflow-x: auto;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
}

.mapping-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.mapping-table th {
    background: var(--gray-50);
    padding: 0.875rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--gray-700);
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}

.mapping-table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

.mapping-table tr:last-child td {
    border-bottom: none;
}

.mapping-table tr:hover {
    background: var(--gray-50);
}

/* Help Icon Button */
.help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    width: 18px;
    height: 18px;
    margin-left: 0.25rem;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--gray-400);
    cursor: pointer;
    border-radius: 50%;
    transition: var(--transition);
}

.help-icon svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.help-icon:hover {
    color: var(--primary);
    background: var(--primary-light);
}

.help-icon:focus {
    outline: none;
    color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

/* Popover */
.popover {
    position: fixed;
    z-index: 1000;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--gray-200);
    width: 400px;
    max-width: calc(100vw - 2rem);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.popover.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-100);
}

.popover-title {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--gray-800);
}

.popover-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--gray-400);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.popover-close:hover {
    background: var(--gray-100);
    color: var(--gray-600);
}

.popover-close svg {
    width: 16px;
    height: 16px;
}

.popover-content {
    padding: 0.75rem;
}

.popover-description {
    font-size: 0.8125rem;
    color: var(--gray-600);
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.popover-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.popover-table td {
    padding: 0.5rem 0.625rem;
    vertical-align: top;
    border-bottom: 1px solid var(--gray-100);
}

.popover-table tr:last-child td {
    border-bottom: none;
}

.popover-type {
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
    width: 80px;
}

.popover-table td:last-child {
    color: var(--gray-600);
    line-height: 1.4;
}

.column-name {
    font-weight: 500;
    color: var(--gray-800);
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
}

.sample-value {
    color: var(--gray-500);
    font-size: 0.8125rem;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.type-select, .format-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: var(--gray-700);
    background: white;
    cursor: pointer;
    transition: var(--transition);
    min-width: 120px;
}

.type-select:hover, .format-select:hover {
    border-color: var(--primary);
}

.type-select:focus, .format-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.format-placeholder {
    color: var(--gray-400);
    font-size: 0.875rem;
}

/* Buttons */
.step-actions {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--gray-100);
}

.btn-primary, .btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-primary svg {
    width: 18px;
    height: 18px;
}

.btn-secondary {
    background: white;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.btn-secondary:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.btn-secondary svg {
    width: 18px;
    height: 18px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 0.625rem 0.75rem;
    text-align: center;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-800);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.stat-card.warning {
    background: var(--warning-light);
    border-color: var(--warning);
}

.stat-card.warning .stat-value {
    color: var(--warning);
}

.stat-card.error {
    background: var(--error-light);
    border-color: var(--error);
}

.stat-card.error .stat-value {
    color: var(--error);
}

.stat-card.success {
    background: var(--success-light);
    border-color: var(--success);
}

.stat-card.success .stat-value {
    color: var(--success);
}

/* Preview Section */
.preview-section {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.625rem 1rem;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.preview-title {
    font-weight: 600;
    color: var(--gray-700);
}

.preview-badge {
    font-size: 0.75rem;
    color: var(--gray-500);
    background: var(--gray-200);
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
}

.table-wrapper {
    overflow-x: auto;
    max-height: 500px;
    overflow-y: auto;
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.preview-table th {
    background: var(--gray-100);
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-weight: 600;
    color: var(--gray-700);
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 1;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.75rem;
    cursor: help;
}

.preview-table td {
    padding: 0.375rem 0.75rem;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-600);
    white-space: nowrap;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
}

.preview-table td a,
.preview-table td a:visited,
.preview-table td a:hover,
.preview-table td a:active {
    color: inherit;
    text-decoration: none;
    pointer-events: none;
}

.preview-table tr:hover {
    background: var(--gray-50);
}

.cell-invalid {
    color: var(--error);
    font-weight: 500;
}

.cell-valid {
    color: var(--success);
    font-weight: 500;
}

.cell-null {
    color: var(--gray-400);
    font-style: italic;
}

.validation-badge {
    display: inline-block;
    font-size: 0.6875rem;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    margin-left: 0.5rem;
    font-weight: 600;
}

.validation-badge.invalid {
    background: var(--error-light);
    color: var(--error);
}

/* Success Step */
.success-content {
    text-align: center;
    padding: 2rem;
}

.success-icon {
    width: 72px;
    height: 72px;
    background: var(--success-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
}

.success-icon svg {
    width: 36px;
    height: 36px;
    color: var(--success);
}

.success-content h2 {
    font-size: 1.5rem;
    color: var(--gray-800);
    margin-bottom: 0.5rem;
}

.success-content p {
    color: var(--gray-500);
    margin-bottom: 1.5rem;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 1000;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    font-weight: 500;
    color: var(--gray-600);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--gray-800);
    color: white;
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: var(--shadow-xl);
    transform: translateY(150%);
    opacity: 0;
    transition: var(--transition);
    z-index: 1001;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast svg {
    width: 20px;
    height: 20px;
    color: var(--success);
}

.toast.error svg {
    color: var(--error);
}

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

/* Responsive */
@media (max-width: 640px) {
    .app-container {
        padding: 1rem;
    }

    .header {
        margin-bottom: 2rem;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .step {
        padding: 1.25rem;
    }

    .upload-area {
        padding: 2rem 1rem;
    }

    .step-actions {
        flex-direction: column;
    }

    .btn-primary, .btn-secondary {
        width: 100%;
        justify-content: center;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .mapping-table th:nth-child(2),
    .mapping-table td:nth-child(2) {
        display: none;
    }

    .toast {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
    }
}
