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

:root {
    --primary: #0ea5e9;
    --primary-dark: #0284c7;
    --primary-light: #7dd3fc;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --info: #6366f1;
    --info-light: #e0e7ff;
    --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;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #0ea5e9 0%, #6366f1 100%);
    min-height: 100vh;
}

.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: white;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

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

.logo-icon {
    font-size: 2rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--info) 100%);
    padding: 10px;
    border-radius: 12px;
}

.logo-text h1 {
    font-size: 1.5rem;
    color: var(--gray-800);
    font-weight: 700;
}

.tagline {
    color: var(--gray-500);
    font-size: 0.8rem;
}

.header-stats {
    display: flex;
    gap: 16px;
}

.stat-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--gray-50);
    border-radius: 20px;
    border: 1px solid var(--gray-200);
}

.stat-icon {
    font-size: 1rem;
}

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

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

/* Main Content */
.main-content {
    flex: 1;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Upload Section */
.upload-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.upload-area {
    background: white;
    border-radius: 16px;
    padding: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    border: 3px dashed var(--gray-300);
    cursor: pointer;
    transition: all 0.3s;
}

.upload-area:hover {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.05) 0%, rgba(99, 102, 241, 0.05) 100%);
}

.upload-area.dragover {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.1) 0%, rgba(99, 102, 241, 0.1) 100%);
    transform: scale(1.02);
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.upload-area h2 {
    color: var(--gray-700);
    font-size: 1.25rem;
    margin-bottom: 8px;
}

.upload-area p {
    color: var(--gray-500);
    font-size: 0.9rem;
}

.upload-formats {
    margin-top: 16px;
    font-size: 0.8rem !important;
    color: var(--gray-400) !important;
}

.sample-docs {
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.sample-docs h3 {
    color: var(--gray-700);
    font-size: 1rem;
    margin-bottom: 16px;
}

.sample-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.sample-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px;
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.sample-btn:hover {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.1) 0%, rgba(99, 102, 241, 0.1) 100%);
    transform: translateY(-2px);
}

.sample-icon {
    font-size: 2rem;
}

.sample-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-700);
}

/* Processing Section */
.processing-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.process-card {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.doc-preview, .pipeline, .results-card, .routing-card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.preview-header, .results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.preview-header h3, .pipeline h3, .results-header h3, .routing-card h3 {
    font-size: 1rem;
    color: var(--gray-700);
}

.doc-type-badge {
    padding: 4px 12px;
    background: var(--info-light);
    color: var(--info);
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.preview-content {
    min-height: 300px;
    background: var(--gray-100);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.preview-placeholder {
    text-align: center;
    color: var(--gray-400);
}

.preview-placeholder .placeholder-icon {
    font-size: 4rem;
    margin-bottom: 12px;
}

.doc-image {
    width: 100%;
    height: 100%;
    min-height: 300px;
    background: white;
    border-radius: 8px;
    padding: 20px;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: var(--gray-700);
    overflow: auto;
    white-space: pre-wrap;
    line-height: 1.6;
}

/* Pipeline Steps */
.pipeline h3 {
    margin-bottom: 20px;
}

.pipeline-steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pipeline-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--gray-50);
    border-radius: 10px;
    border: 1px solid var(--gray-200);
    transition: all 0.3s;
}

.pipeline-step.active {
    background: var(--info-light);
    border-color: var(--info);
}

.pipeline-step.completed {
    background: var(--success-light);
    border-color: var(--success);
}

.pipeline-step .step-icon {
    font-size: 1.25rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 8px;
}

.pipeline-step .step-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pipeline-step .step-name {
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.9rem;
}

.pipeline-step .step-status {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.pipeline-step.active .step-status {
    color: var(--info);
}

.pipeline-step.completed .step-status {
    color: var(--success);
}

.step-indicator {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--gray-300);
    position: relative;
}

.pipeline-step.active .step-indicator {
    border-color: var(--info);
    animation: pulse 1.5s infinite;
}

.pipeline-step.completed .step-indicator {
    border-color: var(--success);
    background: var(--success);
}

.pipeline-step.completed .step-indicator::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(99, 102, 241, 0); }
}

/* Results Card */
.confidence-meter {
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.confidence-bar {
    width: 100px;
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success) 0%, var(--primary) 100%);
    border-radius: 4px;
    width: 0%;
    transition: width 0.5s ease;
}

.confidence-value {
    font-weight: 700;
    color: var(--success);
    font-size: 0.85rem;
    min-width: 40px;
}

.results-content {
    min-height: 200px;
}

.results-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--gray-400);
    text-align: center;
}

.results-placeholder .placeholder-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.extracted-fields {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.field-group {
    padding: 12px;
    background: var(--gray-50);
    border-radius: 8px;
    border-left: 3px solid var(--primary);
}

.field-label {
    font-size: 0.75rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 4px;
}

.field-value {
    font-size: 1rem;
    color: var(--gray-800);
    font-weight: 600;
}

.field-value.highlight {
    color: var(--primary);
}

.line-items {
    margin-top: 16px;
}

.line-items h4 {
    font-size: 0.85rem;
    color: var(--gray-600);
    margin-bottom: 12px;
}

.line-item {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 8px;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-bottom: 6px;
    border: 1px solid var(--gray-200);
}

.line-item.header {
    background: var(--gray-100);
    font-weight: 600;
    color: var(--gray-600);
}

.results-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-200);
}

.export-group {
    display: flex;
    flex: 1;
}

.export-group .action-btn {
    border-radius: 8px 0 0 8px;
    flex: 1;
}

.export-format-select {
    padding: 12px 12px;
    border: none;
    border-radius: 0 8px 8px 0;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    background: var(--gray-200);
    color: var(--gray-700);
    border-left: 1px solid var(--gray-300);
    transition: all 0.2s;
}

.export-format-select:hover {
    background: var(--gray-300);
}

.export-format-select:focus {
    outline: none;
    background: var(--gray-300);
}

.action-btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.action-btn.export {
    background: var(--gray-100);
    color: var(--gray-700);
}

.action-btn.send {
    background: var(--info-light);
    color: var(--info);
}

.action-btn.approve {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: white;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Routing Card */
.routing-card h3 {
    margin-bottom: 16px;
}

.routing-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.routing-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--gray-50);
    border-radius: 10px;
}

.routing-icon {
    font-size: 1.5rem;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 10px;
}

.routing-info {
    flex: 1;
}

.routing-label {
    font-size: 0.75rem;
    color: var(--gray-500);
    text-transform: uppercase;
}

.routing-value {
    font-weight: 600;
    color: var(--gray-800);
}

.routing-status {
    padding: 4px 10px;
    background: var(--success-light);
    color: var(--success);
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Footer */
.footer {
    background: white;
    padding: 16px 24px;
    text-align: center;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.footer p {
    color: var(--gray-600);
    font-size: 0.875rem;
    max-width: 900px;
    margin: 0 auto;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    min-width: 320px;
    max-width: 450px;
    animation: toastSlideIn 0.3s ease;
    border-left: 4px solid var(--success);
}

.toast.success {
    border-left-color: var(--success);
}

.toast.info {
    border-left-color: var(--info);
}

.toast.warning {
    border-left-color: var(--warning);
}

.toast.error {
    border-left-color: var(--danger);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.removing {
    animation: toastSlideOut 0.3s ease forwards;
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100px);
    }
}

.toast-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.toast-title {
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 4px;
    word-wrap: break-word;
}

.toast-message {
    font-size: 0.875rem;
    color: var(--gray-600);
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.toast-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.toast-close:hover {
    color: var(--gray-600);
}

/* Routing Edit Button */
.routing-edit-btn {
    background: none;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.75rem;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.routing-edit-btn:hover {
    background: var(--gray-100);
    border-color: var(--primary);
    color: var(--primary);
}

/* Routing Select Dropdown */
.routing-select {
    padding: 6px 10px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--gray-800);
    background: white;
    cursor: pointer;
    min-width: 140px;
}

.routing-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.routing-value-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.routing-status.filed {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: white;
}

/* Responsive */
@media (max-width: 1024px) {
    .upload-section {
        grid-template-columns: 1fr;
    }

    .process-card {
        grid-template-columns: 1fr;
    }

    .header-stats {
        display: none;
    }
}

@media (max-width: 640px) {
    .header {
        flex-direction: column;
        gap: 12px;
    }

    .sample-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .line-item {
        grid-template-columns: 1fr 1fr;
    }

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

    .export-group {
        width: 100%;
    }
}
