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

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --background: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --border-radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

.upload-section {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 3rem 2rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

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

.upload-icon {
    color: var(--secondary-color);
    margin-bottom: 1rem;
}

.upload-area p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.or-text {
    font-size: 0.875rem;
    margin: 0.75rem 0 !important;
}

.file-select-btn {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.3s ease;
}

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

.file-info {
    font-size: 0.75rem;
    margin-top: 1rem !important;
}

.file-preview {
    margin-top: 1.5rem;
    text-align: center;
}

.file-preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.remove-btn {
    margin-top: 1rem;
    background: var(--error-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
}

.extract-btn {
    width: 100%;
    margin-top: 1.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.extract-btn:disabled {
    background: var(--secondary-color);
    cursor: not-allowed;
    opacity: 0.6;
}

.results-section {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.results-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.results-grid {
    display: grid;
    gap: 1rem;
}

.result-card {
    background: var(--background);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.result-card label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.result-card input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    background: white;
}

.raw-text-section {
    margin-top: 1.5rem;
}

.raw-text-section details {
    background: var(--background);
    border-radius: 8px;
    padding: 1rem;
}

.raw-text-section summary {
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
}

.raw-text-section pre {
    margin-top: 1rem;
    padding: 1rem;
    background: #1e293b;
    color: #e2e8f0;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 0.875rem;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.action-btn {
    flex: 1;
    padding: 0.75rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.action-btn:not(.secondary) {
    background: var(--primary-color);
    color: white;
    border: none;
}

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

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

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

.form-section {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.form-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
}

.field-mapping h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.help-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.mapping-row {
    display: grid;
    grid-template-columns: 120px 1fr 100px;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 0.75rem;
}

.mapping-row label {
    font-size: 0.875rem;
    font-weight: 500;
}

.mapping-row input,
.mapping-row select {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
}

.fill-btn {
    width: 100%;
    margin-top: 1.5rem;
    background: var(--success-color);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

.fill-btn:disabled {
    background: var(--secondary-color);
    cursor: not-allowed;
}

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

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading p {
    color: white;
    margin-top: 1rem;
    font-weight: 500;
}

.message {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 1rem 2rem;
    border-radius: 8px;
    font-weight: 500;
    z-index: 1001;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

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

.message.error {
    background: var(--error-color);
    color: white;
}

.hidden {
    display: none !important;
}

.tse-section {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    border-left: 4px solid var(--primary-color);
}

.tse-section h2 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.tse-fields {
    display: grid;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.tse-status {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--background);
    border-radius: 8px;
}

.tse-status h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
}

.status-grid {
    display: grid;
    gap: 0.5rem;
}

.status-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem;
    background: white;
    border-radius: 4px;
}

.status-label {
    font-weight: 500;
}

.status-value {
    font-weight: 600;
}

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

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

.captcha-section {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
}

.captcha-section h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: #856404;
}

.captcha-container {
    margin: 1rem 0;
    text-align: center;
}

.captcha-container img {
    max-width: 200px;
    border: 2px solid #ddd;
    border-radius: 4px;
}

.screenshot-section {
    margin-top: 1.5rem;
}

.screenshot-section h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
}

.screenshot-section img {
    max-width: 100%;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.voter-info {
    margin-top: 1.5rem;
    padding: 1rem;
    background: #d1fae5;
    border: 1px solid #10b981;
    border-radius: 8px;
}

.voter-info h4 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: #065f46;
}

.voter-info p {
    margin-bottom: 0.25rem;
    color: #047857;
}

.error-message {
    margin-top: 1rem;
    padding: 1rem;
    background: #fee2e2;
    border: 1px solid #ef4444;
    border-radius: 8px;
    color: #dc2626;
    font-weight: 500;
}

footer {
    text-align: center;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

footer p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.disclaimer {
    font-size: 0.75rem !important;
    margin-top: 0.5rem;
}

.install-prompt {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.install-prompt p {
    flex: 1;
    margin: 0;
    font-weight: 500;
}

.install-btn {
    background: white;
    color: #667eea;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}

.dismiss-btn {
    background: transparent;
    color: white;
    border: 1px solid rgba(255,255,255,0.5);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
}

.camera-section {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: black;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.camera-section video {
    flex: 1;
    width: 100%;
    object-fit: cover;
}

.camera-controls {
    padding: 1rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
    background: rgba(0,0,0,0.8);
}

.capture-btn {
    background: var(--success-color);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
}

.close-camera-btn {
    background: var(--error-color);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-size: 1rem;
    cursor: pointer;
}

.camera-option {
    margin-bottom: 1rem;
}

.camera-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    background: var(--success-color);
    color: white;
    border: none;
    padding: 1.5rem 2rem;
    border-radius: 12px;
    cursor: pointer;
    width: 100%;
    font-size: 1.1rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.camera-btn:hover {
    background: #1a9d4e;
    transform: translateY(-2px);
}

.camera-btn svg {
    stroke: white;
}

.registration-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.registration-card {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    text-align: center;
    max-width: 320px;
    width: 90%;
}

.registration-card h2 {
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.registration-card p {
    color: #64748b;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.registration-card input {
    width: 100%;
    padding: 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1.1rem;
    margin-bottom: 1rem;
    text-align: center;
}

.registration-card input:focus {
    outline: none;
    border-color: #27ae60;
}

.register-btn {
    width: 100%;
    background: #27ae60;
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
}

.register-btn:hover {
    background: #219a52;
}

.contact-section {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--background);
    border-radius: 8px;
}

.contact-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    text-align: center;
}

.contact-fields {
    display: grid;
    gap: 0.75rem;
}

.contact-fields input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
}

.contact-fields input::placeholder {
    color: #a0aec0;
}

@media (max-width: 640px) {
    .container {
        padding: 1rem;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .upload-section,
    .results-section,
    .form-section {
        padding: 1.5rem;
    }
    
    .mapping-row {
        grid-template-columns: 1fr;
    }
    
    .actions {
        flex-direction: column;
    }
    
    .install-prompt {
        flex-direction: column;
        text-align: center;
    }
}
