:root {
    --primary: #1a56db;
    --primary-hover: #1e40af;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --error: #dc2626;
    --success: #16a34a;
    --focus: #3b82f6;
    --warning: #f59e0b;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* Auth pages */
body:has(.auth-container) {
    display: flex;
    align-items: center;
    justify-content: center;
}
.auth-container {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}
.auth-container h1 {
    font-size: 1.75rem;
    text-align: center;
    margin-bottom: 0.5rem;
}
.subtitle {
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 2rem;
    font-size: 0.95rem;
}
.brand { color: var(--primary); }

/* Forms */
.form-group { margin-bottom: 1.25rem; }
label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
    font-size: 0.95rem;
}
input[type="text"], input[type="email"], input[type="password"] {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}
input:focus {
    outline: none;
    border-color: var(--focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}
.btn-full {
    width: 100%;
    padding: 0.85rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 0.5rem;
}
.btn-full:hover { background: var(--primary-hover); }
.btn-full:focus { outline: none; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.5); }
.error-message {
    color: var(--error);
    font-weight: 600;
    text-align: center;
    margin-top: 1rem;
    min-height: 1.5rem;
}
.error-message:empty { display: none; }
.success-message {
    color: var(--success);
    font-weight: 600;
    text-align: center;
    margin-top: 1rem;
}
.auth-links {
    display: flex;
    justify-content: space-between;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.auth-links a {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
}
.auth-links a:hover { text-decoration: underline; }
.auth-links a:focus { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
.auth-links.center { justify-content: center; }

/* App layout */
header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
header h1 { font-size: 1.3rem; }
.header-actions { display: flex; gap: 0.5rem; align-items: center; }
.header-btn {
    background: none;
    border: 2px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}
.header-btn:hover { border-color: var(--text-muted); }
.header-btn:focus { outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,0.3); }
.header-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* Main content */
.main-content {
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

/* Upload area */
.upload-area {
    background: var(--card-bg);
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 2.5rem;
    text-align: center;
    margin-bottom: 2rem;
    transition: border-color 0.2s;
}
.upload-area:focus-within { border-color: var(--focus); }
.upload-area h2 { margin-bottom: 0.75rem; font-size: 1.2rem; }
.upload-area p { color: var(--text-muted); margin-bottom: 1rem; }
.upload-btn {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
}
.upload-btn:hover { background: var(--primary-hover); }
.upload-btn:focus { outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,0.5); }
input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
}

/* Cards */
.section-title {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    transition: box-shadow 0.2s;
}
.card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.card-name { font-weight: 700; font-size: 1.05rem; }
.card-info { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 0.75rem; }
.card-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Status badges */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}
.badge-ready { background: #dbeafe; color: #1e40af; }
.badge-processing { background: #fef3c7; color: #92400e; }
.badge-done { background: #dcfce7; color: #166534; }
.badge-error { background: #fee2e2; color: #991b1b; }
.badge-inactive { background: #f1f5f9; color: #64748b; }
.badge-admin { background: #ede9fe; color: #5b21b6; }

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background 0.2s;
}
.btn:focus { outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,0.3); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--bg); border: 2px solid var(--border); color: var(--text); }
.btn-secondary:hover:not(:disabled) { border-color: var(--text-muted); }
.btn-danger { background: var(--error); color: white; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-small { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

/* Progress */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin: 0.75rem 0;
}
.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.5s;
}

/* Image review */
.image-review {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}
.image-review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.image-meta { font-size: 0.85rem; color: var(--text-muted); }
.image-preview {
    max-width: 100%;
    max-height: 300px;
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 0.75rem;
}
.alt-text-field {
    width: 100%;
    min-height: 80px;
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
}
.alt-text-field:focus {
    outline: none;
    border-color: var(--focus);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.3);
}
.image-type-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: #f1f5f9;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}
.save-indicator {
    font-size: 0.85rem;
    color: var(--success);
    margin-left: 0.5rem;
    opacity: 0;
    transition: opacity 0.3s;
}
.save-indicator.visible { opacity: 1; }

/* Navigation */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    background: none;
    border: none;
    color: var(--primary);
    font-size: 1rem;
    cursor: pointer;
    font-weight: 600;
}
.back-btn:focus { outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,0.3); border-radius: 4px; }

/* Empty state */
.empty-state { text-align: center; color: var(--text-muted); padding: 2rem; }

/* Admin table */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}
.admin-table th, .admin-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.admin-table th {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
}
.admin-table tr:hover { background: var(--bg); }

/* Accessible utilities */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    width: 100%;
    max-width: 450px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal h2 { margin-bottom: 1rem; font-size: 1.2rem; }
.modal .form-group { margin-bottom: 1rem; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1.5rem; }
