/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f6f8;
    color: #1a1a2e;
    line-height: 1.6;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Nav --- */
nav {
    background: #1a1a2e;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: 56px;
}
.nav-brand { font-weight: 700; font-size: 1.1rem; letter-spacing: -0.02em; }
.nav-links { display: flex; align-items: center; gap: 1.5rem; }
.nav-links a { color: #cbd5e1; font-size: 0.9rem; }
.nav-links a:hover { color: #fff; text-decoration: none; }
.nav-logout button {
    background: none; border: none; color: #94a3b8; cursor: pointer; font-size: 0.9rem;
}
.nav-logout button:hover { color: #fff; }

/* --- Layout --- */
main { max-width: 720px; margin: 2rem auto; padding: 0 1.5rem; }
.page-container { }
.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; }
.page-header p { color: #64748b; margin-top: 0.25rem; }

/* --- Forms --- */
.form-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-weight: 600; font-size: 0.85rem; margin-bottom: 0.4rem; color: #374151; }
.form-group input, .form-group select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.95rem;
    background: #fff;
}
.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* --- Buttons --- */
.btn {
    display: inline-block;
    padding: 0.6rem 1.25rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    text-align: center;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-primary:disabled { background: #93c5fd; cursor: not-allowed; }
.btn-secondary { background: #e2e8f0; color: #374151; }
.btn-secondary:hover { background: #cbd5e1; }
.btn-full { width: 100%; }
.btn-small { padding: 0.3rem 0.75rem; font-size: 0.8rem; }

/* --- Upload Zone --- */
/* --- Category Upload Sections --- */
.category-sections { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1.5rem; }

.category-section {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

.category-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f5f9;
}
.category-header h3 { font-size: 0.9rem; font-weight: 700; margin: 0; }
.category-header p { font-size: 0.78rem; color: #64748b; margin: 0; }

.priority-badge {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
}
.priority-1 .priority-badge { background: #1d4ed8; }
.priority-2 .priority-badge { background: #2563eb; }
.priority-3 .priority-badge { background: #3b82f6; }
.priority-4 .priority-badge { background: #60a5fa; }
.priority-5 .priority-badge { background: #93c5fd; }

.priority-1 { border-left: 3px solid #1d4ed8; }
.priority-2 { border-left: 3px solid #2563eb; }
.priority-3 { border-left: 3px solid #3b82f6; }
.priority-4 { border-left: 3px solid #60a5fa; }
.priority-5 { border-left: 3px solid #93c5fd; }

/* --- Upload Zone --- */
.upload-zone {
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    padding: 2.5rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.upload-zone.compact {
    border: none;
    border-radius: 0;
    padding: 0.75rem 1rem;
    border-top: 1px dashed #e2e8f0;
    font-size: 0.85rem;
    color: #94a3b8;
}
.upload-zone.compact p { margin: 0; }
.upload-zone:hover, .upload-zone.drag-over {
    border-color: #2563eb;
    background: #eff6ff;
}
.upload-zone.compact:hover, .upload-zone.compact.drag-over {
    border-color: transparent;
    border-top-color: #2563eb;
}
.upload-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.upload-browse { color: #2563eb; font-weight: 600; cursor: pointer; }
.upload-hint { color: #94a3b8; font-size: 0.8rem; margin-top: 0.4rem; }
.upload-hint-global { text-align: center; color: #94a3b8; font-size: 0.8rem; margin-bottom: 1rem; }

.file-list { }
.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 1rem;
    background: #f8fafc;
    border-top: 1px solid #f1f5f9;
    font-size: 0.83rem;
}
.file-meta { display: flex; align-items: center; gap: 0.5rem; }
.file-size { color: #94a3b8; }
.file-remove {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0 0.25rem;
    line-height: 1;
}
.file-remove:hover { color: #dc2626; }

/* --- Login --- */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: #f5f6f8;
}
.login-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 2.5rem;
    width: 100%;
    max-width: 380px;
    text-align: center;
}
.login-card h1 { font-size: 1.3rem; margin-bottom: 0.25rem; }
.login-subtitle { color: #64748b; font-size: 0.9rem; margin-bottom: 1.5rem; }
.error-msg { color: #dc2626; font-size: 0.85rem; margin-top: 0.75rem; }

/* --- Status Page --- */
.status-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 2rem;
}
.status-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.status-header h1 { font-size: 1.4rem; }
.status-meta { display: flex; gap: 1.5rem; color: #64748b; font-size: 0.85rem; margin-bottom: 1.5rem; }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.65rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.badge-pending { background: #f1f5f9; color: #64748b; }
.badge-processing { background: #dbeafe; color: #1d4ed8; }
.badge-completed { background: #dcfce7; color: #166534; }
.badge-failed { background: #fee2e2; color: #991b1b; }

/* Progress */
.progress-bar-container {
    background: #e2e8f0;
    border-radius: 8px;
    height: 12px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}
.progress-bar {
    background: linear-gradient(90deg, #2563eb, #3b82f6);
    height: 100%;
    border-radius: 8px;
    transition: width 0.5s ease;
}
.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #374151;
}
.progress-elapsed { color: #94a3b8; font-size: 0.8rem; margin-top: 0.5rem; }

/* Downloads */
.download-buttons { display: flex; gap: 0.75rem; margin: 1rem 0; flex-wrap: wrap; }
.result-summary { margin-top: 1.5rem; }
.summary-item { margin-bottom: 0.5rem; font-size: 0.9rem; }
.rec-advance { color: #166534; font-weight: 700; }
.rec-hold { color: #991b1b; font-weight: 700; }

/* Error */
.error-box {
    background: #fef2f2;
    border: 1px solid #fee2e2;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
}
.error-box h3 { color: #991b1b; font-size: 0.95rem; }
.error-box p { color: #7f1d1d; font-size: 0.85rem; margin-top: 0.25rem; }

/* --- History Table --- */
.jobs-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}
.jobs-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    border-bottom: 1px solid #e2e8f0;
}
.jobs-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.9rem;
}
.jobs-table tr:last-child td { border-bottom: none; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #64748b;
}
.empty-state .btn { margin-top: 1rem; }

/* --- Email Button --- */
.btn-email { background: #7c3aed; color: #fff; }
.btn-email:hover { background: #6d28d9; }

/* --- Email Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal-card {
    background: #fff;
    border-radius: 10px;
    padding: 2rem;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}
.modal-card h3 { font-size: 1.1rem; margin-bottom: 0.25rem; }
.modal-desc { color: #64748b; font-size: 0.85rem; margin-bottom: 1rem; }
.modal-input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.95rem;
    margin-bottom: 1rem;
}
.modal-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 0.75rem; }
.email-feedback {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    min-height: 1.2em;
}
.email-feedback.success { color: #166534; }
.email-feedback.error { color: #991b1b; }
.email-feedback.sending { color: #1d4ed8; }

/* --- Responsive --- */
@media (max-width: 600px) {
    .form-row { flex-direction: column; gap: 0; }
    .download-buttons { flex-direction: column; }
    .status-meta { flex-wrap: wrap; gap: 0.75rem; }
}
