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

        :root {
            --primary: #2563eb;
            --primary-dark: #1d4ed8;
            --success: #10b981;
            --warning: #f59e0b;
            --danger: #ef4444;
            --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: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            padding: 1rem;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
        }

        .header {
            text-align: center;
            color: white;
            margin-bottom: 2rem;
            animation: fadeIn 0.5s ease-out;
        }

        .header h1 {
            font-size: 2rem;
            font-weight: 700;
            margin-bottom: 0.5rem;
            text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(-20px); }
            to { opacity: 1; transform: translateY(0); }
        }

        .nav-buttons {
            display: flex;
            gap: 1rem;
            margin-bottom: 2rem;
            justify-content: center;
        }

        .btn {
            display: inline-block;
            padding: 0.75rem 1.5rem;
            border-radius: 8px;
            font-weight: 600;
            font-size: 1rem;
            cursor: pointer;
            transition: all 0.3s ease;
            border: none;
            text-decoration: none;
            text-align: center;
            color: white;
        }

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

        .btn-primary:hover {
            background: var(--primary-dark);
            transform: translateY(-2px);
        }

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

        .btn-secondary:hover {
            background: var(--gray-700);
            transform: translateY(-2px);
        }

        .btn-success {
            background: var(--success);
        }

        .btn-warning {
            background: var(--warning);
        }

        .current-card-id {
            background: white;
            border-radius: 12px;
            padding: 1rem;
            margin-bottom: 1.5rem;
            text-align: center;
            display: none;
        }

        .current-card-id strong {
            font-family: 'Courier New', monospace;
            background: #f5f5f5;
            padding: 0.25rem 0.5rem;
            border-radius: 4px;
            user-select: all;
            cursor: text;
        }

        .current-card-id.active {
            display: block;
        }

        .scan-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 1.5rem;
            margin-bottom: 2rem;
        }

        @media (max-width: 768px) {
            .scan-grid {
                grid-template-columns: 1fr;
            }
        }

        .scan-box {
            background: white;
            border-radius: 16px;
            overflow: hidden;
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
        }

        .scan-header {
            background: var(--gray-100);
            padding: 1rem;
            border-bottom: 2px solid var(--gray-200);
        }

        .scan-header h2 {
            font-size: 1.25rem;
            color: var(--gray-800);
            margin: 0;
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .scan-status {
            display: inline-block;
            padding: 0.25rem 0.75rem;
            border-radius: 20px;
            font-size: 0.75rem;
            font-weight: 600;
            margin-left: auto;
        }

        .status-empty {
            background: var(--gray-200);
            color: var(--gray-600);
        }

        .status-scanned {
            background: rgba(16, 185, 129, 0.1);
            color: var(--success);
        }

        .scan-content {
            padding: 1.5rem;
        }

        .upload-area {
            border: 2px dashed var(--gray-300);
            border-radius: 12px;
            padding: 2rem 1rem;
            text-align: center;
            background: var(--gray-50);
            transition: all 0.3s ease;
            cursor: pointer;
            min-height: 250px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }

        .upload-area.dragover {
            border-color: var(--primary);
            background: rgba(37, 99, 235, 0.05);
        }

        .upload-area.has-image {
            padding: 0;
            border: none;
            background: transparent;
            cursor: default;
        }

        .preview-image {
            width: 100%;
            height: 250px;
            object-fit: contain;
            background: var(--gray-100);
            border-radius: 8px;
            cursor: zoom-in;
            transition: transform 0.2s ease;
        }

        .preview-image:hover {
            transform: scale(1.02);
        }

        /* Zoom Modal Styles */
        .zoom-modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            background: rgba(0, 0, 0, 0.9);
            z-index: 10000;
            justify-content: center;
            align-items: center;
        }

        .zoom-modal.show {
            display: flex !important;
        }

        .zoom-content {
            position: relative;
            width: 90vw;
            height: 90vh;
            max-width: 1200px;
            max-height: 800px;
            background: white;
            border-radius: 8px;
            overflow: hidden;
            display: flex;
            justify-content: center;
            align-items: center;
            cursor: grab;
        }

        .zoom-content:active {
            cursor: grabbing;
        }

        .zoom-image {
            display: block;
            margin: 0 auto;
            max-width: 90%;
            max-height: 90%;
            object-fit: contain;
            transition: all 0.1s ease;
            user-select: none;
        }

        .zoom-toolbar {
            position: absolute;
            top: 10px;
            right: 10px;
            display: flex;
            gap: 10px;
            background: rgba(0, 0, 0, 0.7);
            padding: 10px;
            border-radius: 8px;
            z-index: 1;
        }

        .zoom-button {
            background: white;
            border: none;
            width: 48px;
            height: 48px;
            border-radius: 8px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
            font-weight: bold;
            box-shadow: 0 2px 8px rgba(0,0,0,0.2);
            touch-action: manipulation;
            user-select: none;
            -webkit-tap-highlight-color: transparent;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            pointer-events: auto;
            z-index: 1000;
            transition: background-color 0.2s;
        }

        .zoom-button:hover {
            background: #f0f0f0;
        }

        .zoom-button:active {
            background: #e0e0e0;
            transform: scale(0.95);
        }

        @media (max-width: 768px) {
            .zoom-button {
                width: 52px;
                height: 52px;
                font-size: 22px;
                margin: 6px;
            }
        }

        .zoom-close-btn {
            position: absolute;
            top: 10px;
            left: 10px;
            background: white;
            border: none;
            width: 40px;
            height: 40px;
            border-radius: 6px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
            font-weight: bold;
            z-index: 1;
        }

        .zoom-close-btn:hover {
            background: #f0f0f0;
        }

        .zoom-container {
            position: relative;
            width: 90vw;
            height: 90vh;
            max-width: 90vw;
            max-height: 90vh;
            overflow: auto;
            border-radius: 8px;
            background: white;
            cursor: grab;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .zoom-container:active {
            cursor: grabbing;
        }

        .zoom-image {
            display: block;
            transition: transform 0.1s ease;
            user-select: none;
            transform-origin: center center;
            max-width: 100%;
            max-height: 100%;
            width: auto;
            height: auto;
            object-fit: contain;
        }

        .zoom-controls {
            position: absolute;
            top: 10px;
            right: 10px;
            display: flex;
            gap: 5px;
            background: rgba(0, 0, 0, 0.8);
            padding: 8px;
            border-radius: 5px;
            z-index: 1000;
        }

        .zoom-btn {
            background: rgba(255, 255, 255, 0.9);
            border: none;
            width: 35px;
            height: 35px;
            border-radius: 4px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 16px;
            transition: background 0.2s ease;
        }

        .zoom-btn:hover {
            background: white;
        }

        .zoom-close {
            position: absolute;
            top: 10px;
            left: 10px;
            background: rgba(255, 255, 255, 0.9);
            border: none;
            width: 35px;
            height: 35px;
            border-radius: 4px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            font-weight: bold;
            transition: background 0.2s ease;
            z-index: 1000;
        }

        .zoom-close:hover {
            background: white;
        }

        .zoom-info {
            position: absolute;
            bottom: 10px;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(0, 0, 0, 0.7);
            color: white;
            padding: 5px 10px;
            border-radius: 4px;
            font-size: 12px;
        }

        .file-input {
            display: none;
        }

        .scan-actions {
            margin-top: 1rem;
            display: none;
            gap: 0.5rem;
        }

        .scan-actions.active {
            display: flex;
        }

        .results-card {
            background: white;
            border-radius: 16px;
            padding: 1.5rem;
            margin-bottom: 1.5rem;
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
            display: none;
        }

        .results-card.active {
            display: block;
        }

        .confidence-meter {
            margin-bottom: 1.5rem;
        }

        .confidence-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 0.5rem;
        }

        .confidence-value {
            font-size: 1.5rem;
            font-weight: bold;
        }

        .confidence-bar {
            height: 20px;
            background: var(--gray-200);
            border-radius: 10px;
            overflow: hidden;
        }

        .confidence-fill {
            height: 100%;
            transition: width 0.5s ease;
        }

        .completeness-dots {
            display: flex;
            gap: 0.5rem;
            margin-bottom: 1.5rem;
            justify-content: center;
        }

        .dot {
            width: 12px;
            height: 12px;
            border-radius: 50%;
            background: var(--gray-300);
            transition: all 0.3s ease;
        }

        .dot.filled {
            background: var(--success);
            transform: scale(1.2);
        }

        .results-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
            gap: 1rem;
            margin-top: 1rem;
        }

        .result-item {
            padding: 0.75rem;
            background: var(--gray-50);
            border-radius: 8px;
        }

        .result-label {
            font-size: 0.75rem;
            color: var(--gray-600);
            margin-bottom: 0.25rem;
        }

        .result-value {
            border: 1px solid transparent;
            background: transparent;
            width: 100%;
            padding: 4px;
            font-weight: 600;
            font-size: 1rem;
            color: var(--gray-900);
            border-radius: 4px;
        }

        .result-value.editable {
            border-color: var(--primary);
            background: white;
        }

        .action-buttons {
            display: flex;
            gap: 1rem;
            margin-top: 2rem;
        }

        .action-buttons .btn {
            flex: 1;
        }

        .loading-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.8);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 1000;
        }

        .loading-overlay.active {
            display: flex;
        }

        .loading-content {
            background: white;
            padding: 2rem;
            border-radius: 16px;
            text-align: center;
        }

        .spinner {
            width: 50px;
            height: 50px;
            border: 4px solid var(--gray-200);
            border-top: 4px solid var(--primary);
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin: 0 auto 1rem;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        .message {
            padding: 1rem;
            border-radius: 8px;
            margin-bottom: 1rem;
            display: none;
        }

        .message.active {
            display: block;
        }

        .message.success {
            background: #f0fdf4;
            border: 1px solid #bbf7d0;
            color: #059669;
        }

        .message.error {
            background: #fef2f2;
            border: 1px solid #fecaca;
            color: #dc2626;
        }

        /* Debug Section Styles */
        .debug-section {
            margin-top: 2rem;
            border-top: 2px solid var(--gray-200);
            padding-top: 1.5rem;
        }

        .debug-header {
            display: flex;
            justify-content: between;
            align-items: center;
            margin-bottom: 1rem;
        }

        .debug-header h4 {
            color: var(--gray-700);
            margin: 0;
            flex-grow: 1;
        }

        .btn-debug-toggle {
            background: var(--gray-100);
            border: 1px solid var(--gray-300);
            color: var(--gray-700);
            padding: 0.5rem 1rem;
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.875rem;
            transition: all 0.2s;
        }

        .btn-debug-toggle:hover {
            background: var(--gray-200);
        }

        .debug-content {
            background: var(--gray-50);
            border: 1px solid var(--gray-200);
            border-radius: 8px;
            padding: 1rem;
        }

        .debug-group {
            margin-bottom: 2rem;
        }

        .debug-group h5 {
            color: var(--gray-800);
            margin-bottom: 1rem;
            padding-bottom: 0.5rem;
            border-bottom: 1px solid var(--gray-300);
        }

        /* Comprehensive Debug Styles */
        .processing-status {
            display: grid;
            gap: 0.5rem;
        }
        
        .status-row {
            display: grid;
            grid-template-columns: 1fr auto;
            align-items: center;
            padding: 0.5rem;
            background: white;
            border-radius: 4px;
            border-left: 3px solid var(--gray-300);
        }
        
        .status-label {
            font-weight: 500;
            color: var(--gray-700);
        }
        
        .status-indicator {
            font-weight: bold;
            padding: 0.25rem 0.5rem;
            border-radius: 4px;
            font-size: 0.875rem;
        }
        
        .status-indicator.waiting {
            background: var(--gray-200);
            color: var(--gray-600);
        }
        
        .status-indicator.processing {
            background: #f59e0b;
            color: white;
            animation: pulse 1.5s ease-in-out infinite alternate;
        }
        
        .status-indicator.success {
            background: #10b981;
            color: white;
        }
        
        .status-indicator.error {
            background: #ef4444;
            color: white;
        }
        
        .status-indicator.skipped {
            background: var(--gray-400);
            color: white;
        }
        
        .field-sources {
            display: grid;
            gap: 0.5rem;
        }
        
        .field-source-row {
            display: grid;
            grid-template-columns: 1fr 2fr;
            align-items: center;
            padding: 0.5rem;
            background: white;
            border-radius: 4px;
        }
        
        .field-label {
            font-weight: 500;
            color: var(--gray-700);
        }
        
        .field-source {
            font-family: monospace;
            font-size: 0.875rem;
            padding: 0.25rem 0.5rem;
            background: var(--gray-50);
            border: 1px solid var(--gray-300);
            border-radius: 4px;
        }
        
        .field-source.ocr {
            border-left: 3px solid #3b82f6;
        }
        
        .field-source.clip {
            border-left: 3px solid #10b981;
        }
        
        .field-source.ai {
            border-left: 3px solid #f59e0b;
        }
        
        .field-source.user {
            border-left: 3px solid #6366f1;
        }

        @keyframes pulse {
            from { opacity: 0.6; }
            to { opacity: 1; }
        }

        .debug-tabs {
            display: flex;
            gap: 0.5rem;
            margin-bottom: 1rem;
        }

        .debug-tab {
            background: var(--gray-200);
            border: none;
            padding: 0.5rem 1rem;
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.875rem;
            transition: all 0.2s;
        }

        .debug-tab.active {
            background: var(--primary);
            color: white;
        }

        .debug-tab:hover:not(.active) {
            background: var(--gray-300);
        }

        .debug-panel {
            display: none;
            background: white;
            border: 1px solid var(--gray-300);
            border-radius: 6px;
            padding: 1rem;
        }

        .debug-panel.active {
            display: block;
        }

        .debug-status {
            font-weight: 600;
            padding: 0.5rem;
            border-radius: 4px;
            margin-bottom: 1rem;
            text-align: center;
        }

        .debug-status.success {
            background: var(--success);
            color: white;
        }

        .debug-status.warning {
            background: var(--warning);
            color: white;
        }

        .debug-status.error {
            background: var(--danger);
            color: white;
        }

        .debug-data {
            display: grid;
            gap: 1rem;
        }

        .debug-item {
            display: grid;
            grid-template-columns: 150px 1fr;
            gap: 0.5rem;
            align-items: start;
        }

        .debug-item label {
            font-weight: 600;
            color: var(--gray-700);
            font-size: 0.875rem;
        }

        .debug-item span {
            color: var(--gray-900);
            font-family: monospace;
            font-size: 0.875rem;
        }

        .debug-item textarea {
            width: 100%;
            height: 80px;
            font-family: monospace;
            font-size: 0.8rem;
            border: 1px solid var(--gray-300);
            border-radius: 4px;
            padding: 0.5rem;
            background: var(--gray-50);
            resize: vertical;
        }

        .debug-item pre {
            background: var(--gray-100);
            border: 1px solid var(--gray-300);
            border-radius: 4px;
            padding: 0.75rem;
            font-size: 0.8rem;
            overflow-x: auto;
            max-height: 200px;
            overflow-y: auto;
            margin: 0;
            white-space: pre-wrap;
        }

        .debug-error-log {
            background: var(--gray-100);
            border: 1px solid var(--gray-300);
            border-radius: 6px;
            padding: 1rem;
            font-family: monospace;
            font-size: 0.875rem;
            min-height: 60px;
            max-height: 200px;
            overflow-y: auto;
        }

        .debug-error-log.has-errors {
            background: #fef2f2;
            border-color: #fecaca;
            color: var(--danger);
        }

        /* Mobile responsive debug styles */
        @media (max-width: 768px) {
            .debug-header {
                flex-direction: column;
                gap: 1rem;
                align-items: stretch;
            }

            .debug-tabs {
                flex-wrap: wrap;
            }

            .debug-item {
                grid-template-columns: 1fr;
                gap: 0.25rem;
            }

            .debug-item label {
                font-size: 0.8rem;
            }
        }

        /* Details/summary styling for raw data */
        details {
            margin: 0.5rem 0;
        }

        summary {
            cursor: pointer;
            font-weight: 600;
            color: var(--primary);
            padding: 0.5rem;
            border: 1px solid var(--gray-300);
            border-radius: 4px;
            background: var(--gray-50);
        }

        summary:hover {
            background: var(--gray-100);
        }

        details[open] summary {
            border-bottom: none;
            border-radius: 4px 4px 0 0;
        }
