:root {
    --bg: #f3f6ff;
    --card: #ffffff;
    --primary: #3d5afe;
    --primary-dark: #2d46d6;
    --primary-light: #eef2ff;
    --border: #dfe7ff;
    --text: #1d2433;
    --muted: #5d697c;
    --success: #1e9e6d;
    --warning: #d97706;
    --error: #d63b3b;
    --gradient-primary: linear-gradient(135deg, #3d5afe 0%, #7048e8 100%);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, #eef4ff 0%, #f9fbff 100%);
    color: var(--text);
}


/* Top Navigation */
.top-nav {
    width: 100%;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1500px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--primary);
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.brand:hover {
    opacity: 0.9;
}

.brand-icon {
    width: 24px;
    height: 24px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link {
    text-decoration: none;
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.nav-link:hover {
    color: var(--primary);
    background: var(--primary-light);
}

.nav-link.active {
    color: var(--primary);
    background: var(--primary-light);
    font-weight: 700;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Page Shell */
.page-shell {
    width: min(100%, 1500px);
    padding: 28px 24px 60px;
    flex: 1;
}

/* Upload Card */
.upload-card {
    width: min(100%, 640px);
    margin: 0 auto;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 18px 40px rgba(61, 90, 254, 0.08);
    padding: 36px 32px;
}

.card-header {
    text-align: center;
    margin-bottom: 24px;
}

.card-header h1 {
    margin: 0 0 8px;
    font-size: clamp(1.8rem, 3vw, 2.3rem);
    font-weight: 800;
    letter-spacing: -0.01em;
}

.card-intro {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

.upload-form {
    display: grid;
    gap: 20px;
}

.filter-fieldset {
    margin: 0;
    padding: 16px 16px 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #f9faff;
    transition: border-color 0.2s ease;
}

.filter-fieldset.has-error {
    border-color: #fca5a5;
    background: #fffafa;
}

.filter-fieldset legend {
    padding: 0 8px;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text);
}

.required-mark {
    color: var(--error);
}

.optional-label {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: normal;
}

.option-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin-top: 8px;
}

.option-list-radio {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
}

.option-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-size: 0.92rem;
    font-weight: 500;
    cursor: pointer;
}

.option-item input {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.field-error-msg {
    display: block;
    color: var(--error);
    font-size: 0.82rem;
    font-weight: 600;
    margin-top: 8px;
}

/* File Upload Section */
.file-upload-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.file-picker {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    border: 2px dashed var(--primary);
    border-radius: 14px;
    padding: 24px 20px;
    background: #f7f9ff;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
}

.file-picker:hover {
    border-color: var(--primary-dark);
    background: #eef3ff;
    transform: translateY(-1px);
}

.file-picker.dragover {
    border-color: var(--primary-dark);
    background: #e0eaff;
    transform: scale(1.01);
}

.file-picker input {
    display: none;
}

.picker-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #e0e7ff;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

.picker-icon svg {
    width: 22px;
    height: 22px;
}

.file-picker-label {
    display: block;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--primary);
    margin-bottom: 4px;
}

.file-picker-subtext {
    display: block;
    font-size: 0.84rem;
    color: var(--muted);
}

.selected-file-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #eef3ff;
    border: 1px solid var(--border);
    border-radius: 12px;
}

.file-info-left {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

.file-icon {
    width: 20px;
    height: 20px;
    color: var(--primary);
    flex-shrink: 0;
}

.file-name-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.clear-file-btn {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1.4rem;
    line-height: 1;
    padding: 0 4px;
    cursor: pointer;
    border-radius: 4px;
    transition: color 0.2s ease;
}

.clear-file-btn:hover {
    color: var(--error);
}

/* Submit Button */
.submit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: none;
    border-radius: 14px;
    background: var(--gradient-primary);
    color: #fff;
    font-size: 1.05rem;
    font-weight: 700;
    padding: 16px 24px;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(61, 90, 254, 0.25);
    transition: all 0.2s ease;
}

.btn-icon {
    width: 18px;
    height: 18px;
}

.submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px rgba(61, 90, 254, 0.35);
}

.submit-btn:disabled {
    opacity: 0.75;
    cursor: wait;
    transform: none;
}

/* Status Banner */
.status {
    margin-top: 20px;
    min-height: 24px;
    font-size: 0.92rem;
    color: var(--muted);
    padding: 10px 14px;
    border-radius: 10px;
    line-height: 1.4;
    transition: all 0.2s ease;
}

.status.error {
    background: #fdf2f2;
    border: 1px solid #fca5a5;
    color: #b91c1c;
    font-weight: 600;
}

.status.loading {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1d4ed8;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.status.loading::before {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid #bfdbfe;
    border-top-color: #1d4ed8;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.status.success {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #15803d;
    font-weight: 600;
}

/* Results Panel */
.results-panel {
    width: min(100%, 1500px);
    margin: 36px auto 0;
}

.results-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.results-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.results-header-info h2 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 800;
}

.count-badge {
    background: #eef2ff;
    color: var(--primary-dark);
    font-weight: 700;
    font-size: 0.82rem;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid #c7d2fe;
}

.controls-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-btn,
.sort-btn {
    border: none;
    border-radius: 10px;
    background: #e9eeff;
    color: var(--primary-dark);
    font-size: 0.88rem;
    font-weight: 700;
    padding: 9px 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

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

.filter-btn:hover:not(.active),
.sort-btn:hover {
    background: #dfe7ff;
    transform: translateY(-1px);
}

.sort-btn svg {
    width: 15px;
    height: 15px;
}

/* Results Grid */
.results-container {
    display: grid;
    grid-template-columns: repeat(4, minmax(240px, 1fr));
    gap: 16px;
    align-items: stretch;
}

/* Empty State */
.empty-state {
    grid-column: 1 / -1;
    padding: 36px 24px;
    border-radius: 16px;
    background: #f8faff;
    border: 1px dashed var(--border);
    color: var(--muted);
    text-align: center;
    line-height: 1.6;
}

.empty-state.initial-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 48px 24px;
}

.empty-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #eef2ff;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

.empty-icon svg {
    width: 28px;
    height: 28px;
}

.empty-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 6px;
}

.empty-desc {
    font-size: 0.92rem;
    color: var(--muted);
    max-width: 480px;
    margin: 0;
}

/* Comprehensive Error State Card */
.empty-state.error-state {
    background: #fff5f5;
    border: 1.5px solid #fca5a5;
    color: #7f1d1d;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 28px;
    box-shadow: 0 8px 24px rgba(214, 59, 59, 0.08);
}

.error-state-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid #fee2e2;
    padding-bottom: 12px;
}

.error-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #b91c1c;
    font-size: 1.18rem;
    font-weight: 800;
}

.error-title-group svg {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.error-category-badge {
    background: #fee2e2;
    color: #991b1b;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.error-state-message {
    font-size: 1.02rem;
    font-weight: 600;
    color: #991b1b;
    margin: 0;
    line-height: 1.5;
}

.error-state-details {
    background: #ffffff;
    border: 1px solid #fecaca;
    border-radius: 12px;
    padding: 16px 20px;
}

.error-details-title {
    display: block;
    margin-bottom: 8px;
    font-size: 0.92rem;
    font-weight: 700;
    color: #374151;
}

.error-state-tips {
    margin: 0;
    padding-left: 20px;
    font-size: 0.88rem;
    color: #4b5563;
    line-height: 1.6;
}

.error-state-tips li {
    margin-bottom: 6px;
}

.error-actions-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.error-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.error-action-btn.retry-btn {
    background: #b91c1c;
    color: #ffffff;
}

.error-action-btn.retry-btn:hover {
    background: #991b1b;
}

.error-action-btn.guide-btn {
    background: #fee2e2;
    color: #991b1b;
}

.error-action-btn.guide-btn:hover {
    background: #fecaca;
}

/* Offer Card */
.offer-card {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px 18px;
    box-shadow: 0 10px 24px rgba(61, 90, 254, 0.04);
    min-height: 240px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
}

.offer-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 28px rgba(61, 90, 254, 0.08);
}

.offer-card.score-tier-low {
    background: linear-gradient(180deg, rgba(61, 90, 254, 0.08), rgba(61, 90, 254, 0.02));
    border-color: rgba(61, 90, 254, 0.35);
}

.offer-card.score-tier-mid {
    background: linear-gradient(180deg, rgba(46, 204, 113, 0.12), rgba(46, 204, 113, 0.02));
    border-color: rgba(46, 204, 113, 0.5);
}

.offer-card.score-tier-high {
    background: linear-gradient(180deg, rgba(255, 140, 0, 0.12), rgba(255, 140, 0, 0.02));
    border-color: rgba(255, 140, 0, 0.5);
}

.offer-card.score-tier-urgent {
    background: linear-gradient(180deg, rgba(214, 59, 59, 0.12), rgba(214, 59, 59, 0.02));
    border-color: rgba(214, 59, 59, 0.45);
}

.offer-new-badge {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    background: #3d5afe;
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 3px 8px;
    border-radius: 6px;
    margin-bottom: 10px;
    line-height: 1.2;
    box-shadow: 0 2px 6px rgba(61, 90, 254, 0.25);
}

.offer-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.offer-title-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.offer-title {
    margin: 0;
    color: var(--text);
    font-size: 1.08rem;
    line-height: 1.35;
    font-weight: 700;
    word-break: break-word;
}

.offer-company {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--primary);
}

.company-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.offer-score {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
}

.offer-score.score-tier-low {
    background: linear-gradient(135deg, #3d5afe 0%, #6b7cff 100%);
}

.offer-score.score-tier-mid {
    background: linear-gradient(135deg, #19a76b 0%, #49d38a 100%);
    color: #ffffff;
}

.offer-score.score-tier-high {
    background: linear-gradient(135deg, #ff8a00 0%, #ffb000 100%);
    color: #fff;
}

.offer-score.score-tier-urgent {
    background: linear-gradient(135deg, #d63b3b 0%, #ef5a5a 100%);
}

.offer-reason {
    margin: 0;
    color: var(--text);
    line-height: 1.5;
    font-size: 0.9rem;
    white-space: pre-wrap;
    flex: 1;
}

.offer-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    width: 100%;
}

.offer-link-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 1;
    margin-top: 0;
    padding: 11px 14px;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.92rem;
    transition: background 0.2s ease, transform 0.2s ease;
}

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

.offer-link-btn svg {
    width: 14px;
    height: 14px;
}

.offer-apply-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 16px;
    border-radius: 10px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    border: none;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
    white-space: nowrap;
}

.offer-apply-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.offer-apply-btn.is-applied {
    background: rgba(61, 90, 254, 0.12);
    color: var(--primary);
    border: 1px solid rgba(61, 90, 254, 0.35);
    box-shadow: none;
    cursor: default;
    opacity: 0.95;
}

.offer-apply-btn.is-applied.status-applied {
    background: rgba(61, 90, 254, 0.12);
    color: var(--primary);
    border: 1px solid rgba(61, 90, 254, 0.35);
}

.offer-apply-btn.is-applied.status-screening {
    background: rgba(147, 51, 234, 0.12);
    color: #9333ea;
    border: 1px solid rgba(147, 51, 234, 0.35);
}

.offer-apply-btn.is-applied.status-interview {
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.35);
}

.offer-apply-btn.is-applied.status-offer {
    background: rgba(22, 163, 74, 0.14);
    color: #16a34a;
    border: 1px solid rgba(22, 163, 74, 0.35);
}

.offer-apply-btn.is-applied.status-rejected {
    background: rgba(220, 38, 38, 0.12);
    color: #dc2626;
    border: 1px solid rgba(220, 38, 38, 0.35);
}

.offer-apply-btn.is-applied.status-no_response,
.offer-apply-btn.is-applied.status-no-response {
    background: rgba(100, 116, 139, 0.12);
    color: #64748b;
    border: 1px solid rgba(100, 116, 139, 0.35);
}

.offer-apply-btn:disabled:not(.is-applied) {
    opacity: 0.6;
    cursor: wait;
}

.offer-apply-btn svg {
    width: 14px;
    height: 14px;
}

/* Toast Notification */
.analyzer-toast {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 1000;
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 0.92rem;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.analyzer-toast.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.analyzer-toast.success {
    background: #0f172a;
    color: #ffffff;
    border: 1px solid rgba(16, 185, 129, 0.4);
}

.analyzer-toast.error {
    background: #450a0a;
    color: #fecaca;
    border: 1px solid #dc2626;
}

/* Responsive */
@media (max-width: 1200px) {
    .results-container {
        grid-template-columns: repeat(3, minmax(220px, 1fr));
    }
}

@media (max-width: 860px) {
    .results-container {
        grid-template-columns: repeat(2, minmax(220px, 1fr));
    }
}

@media (max-width: 580px) {
    .upload-card {
        padding: 24px 18px;
    }

    .results-container {
        grid-template-columns: 1fr;
    }

    .results-controls {
        flex-direction: column;
        align-items: flex-start;
    }
}
