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

:root {
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-danger: #dc2626;
    --color-danger-hover: #b91c1c;
    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-border: #e2e8f0;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-drop-bg: #f1f5f9;
    --color-drop-active: #dbeafe;
    --color-success: #16a34a;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 20px;
}

/* Container */
.scanner-container {
    width: 100%;
    max-width: 560px;
    margin-top: 20px;
}

/* Header */
.scanner-header {
    text-align: center;
    margin-bottom: 24px;
}

.scanner-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.scanner-header p {
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

/* Drop Zone */
.drop-zone {
    background: var(--color-drop-bg);
    border: 2px dashed var(--color-border);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.drop-zone:hover {
    border-color: var(--color-primary);
    background: var(--color-drop-active);
}

.drop-zone--over {
    border-color: var(--color-primary);
    background: var(--color-drop-active);
    transform: scale(1.01);
}

.drop-zone__icon {
    width: 48px;
    height: 48px;
    color: var(--color-text-muted);
    margin-bottom: 12px;
}

.drop-zone__text {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.drop-zone__hint {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

/* Preview */
.preview {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow);
}

.preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    object-fit: contain;
    margin-bottom: 12px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    margin-top: 16px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

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

.btn--secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn--secondary:hover {
    background: var(--color-bg);
}

.btn--remove {
    background: transparent;
    color: var(--color-danger);
    border: 1px solid var(--color-danger);
    padding: 8px 16px;
    font-size: 0.875rem;
    width: auto;
    margin-top: 0;
}

.btn--remove:hover {
    background: var(--color-danger);
    color: #fff;
}

/* Loader */
.loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 32px;
    text-align: center;
}

.loader p {
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

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

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

/* Results */
.results {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-top: 16px;
}

.results h2 {
    font-size: 1.25rem;
    margin-bottom: 16px;
}

.results__fields {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.result-field {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--color-bg);
    border-radius: 8px;
    font-size: 0.925rem;
}

.result-field strong {
    color: var(--color-text-muted);
    font-weight: 500;
}

.result-field span {
    font-weight: 600;
}

.result-field .confidence-high {
    color: var(--color-success);
}

.result-field .confidence-medium {
    color: #d97706;
}

.result-field .confidence-low {
    color: var(--color-danger);
}

/* Search Section */
.search-section {
    margin-bottom: 16px;
}

.search-section label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 8px;
    color: var(--color-text-muted);
}

.search-row {
    display: flex;
    gap: 8px;
}

.search-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.search-input:focus {
    border-color: var(--color-primary);
}

.search-row .btn {
    width: auto;
    margin-top: 0;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Raw Text */
.raw-text {
    margin-top: 16px;
    margin-bottom: 8px;
}

.raw-text summary {
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    padding: 8px 0;
}

.raw-text pre {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 12px;
    font-size: 0.8rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    margin-top: 8px;
    max-height: 200px;
    overflow-y: auto;
}

/* Responsive */
@media (max-width: 480px) {
    body {
        padding: 12px;
    }

    .scanner-header h1 {
        font-size: 1.4rem;
    }

    .drop-zone {
        padding: 32px 16px;
    }

    .search-row {
        flex-direction: column;
    }

    .search-row .btn {
        width: 100%;
    }
}
