/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f8f9fa;
    color: #212529;
    line-height: 1.6;
    min-height: 100vh;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.container { max-width: 1100px; margin: 0 auto; padding: 24px; }
.container-wide { max-width: 1400px; margin: 0 auto; padding: 24px; }

/* Navbar */
.navbar {
    background: #1e293b;
    color: white;
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand { font-size: 18px; font-weight: 600; }
.nav-links { display: flex; gap: 16px; align-items: center; }
.nav-links a { color: #94a3b8; font-size: 14px; }
.nav-links a:hover, .nav-links a.active { color: white; text-decoration: none; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
    text-decoration: none;
}

.btn:hover { text-decoration: none; }

.btn-primary { background: #2563eb; color: white; }
.btn-primary:hover { background: #1d4ed8; }
.btn-primary:disabled { background: #93c5fd; cursor: not-allowed; }

.btn-danger { background: #dc2626; color: white; }
.btn-danger:hover { background: #b91c1c; }

.btn-delete-case {
    background: none; border: none; color: #94a3b8; font-size: 22px; font-weight: bold;
    cursor: pointer; padding: 0 4px; line-height: 1; margin-left: 8px; border-radius: 4px;
}
.btn-delete-case:hover { color: #dc2626; background: #fee2e2; }

.btn-outline { background: white; color: #374151; border-color: #d1d5db; }
.btn-outline:hover { background: #f3f4f6; }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 28px; font-size: 16px; }
.btn-full { width: 100%; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 4px; font-size: 14px; color: #374151; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}
.form-group input:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }

.input-full {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
}
.input-full:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }

/* Error / Success Messages */
.error-message { color: #dc2626; font-size: 14px; margin-top: 8px; }
.success-message { text-align: center; padding: 40px 20px; }
.success-message h2 { color: #059669; margin-bottom: 12px; }

/* Login */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: #f1f5f9;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
    width: 100%;
    max-width: 400px;
}

.login-box h1 { font-size: 20px; color: #1e293b; margin-bottom: 4px; }
.login-box h2 { font-size: 14px; color: #64748b; font-weight: 400; margin-bottom: 28px; }

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}

.page-header h1 { font-size: 24px; color: #1e293b; }
.back-link { font-size: 14px; color: #64748b; }

/* Search */
.search-bar { margin-bottom: 20px; }

/* Case Cards */
.cases-list { display: flex; flex-direction: column; gap: 12px; }

.case-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px 20px;
    cursor: pointer;
    transition: box-shadow 0.15s;
}

.case-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.08); }

.case-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.case-card-header h3 { font-size: 16px; color: #1e293b; }

.case-card-details { display: flex; gap: 16px; font-size: 13px; color: #64748b; flex-wrap: wrap; }
.case-card-date { font-size: 12px; color: #94a3b8; margin-top: 6px; }

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-created { background: #e2e8f0; color: #475569; }
.status-uploading { background: #dbeafe; color: #1d4ed8; }
.status-processing { background: #fef3c7; color: #92400e; }
.status-verifying { background: #fef3c7; color: #92400e; }
.status-review { background: #d1fae5; color: #065f46; }
.status-complete { background: #d1fae5; color: #065f46; }
.status-error { background: #fee2e2; color: #991b1b; }

/* Section */
.section { background: white; border: 1px solid #e2e8f0; border-radius: 8px; padding: 24px; margin-bottom: 20px; }

/* Case Header */
.case-header { margin-bottom: 20px; }
.case-header h1 { margin-bottom: 8px; }
.case-meta { display: flex; gap: 16px; font-size: 14px; color: #64748b; flex-wrap: wrap; align-items: center; }

/* Upload Area */
.upload-area {
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: 16px;
}

.upload-area:hover, .upload-area.drag-over { border-color: #2563eb; background: #eff6ff; }
.upload-icon { font-size: 48px; margin-bottom: 12px; }
.upload-area p { color: #64748b; margin-bottom: 12px; }

/* Uploaded Files */
.uploaded-files { margin-top: 16px; }
.uploaded-files h3 { margin-bottom: 12px; font-size: 16px; }

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: #2563eb;
    border-radius: 4px;
    transition: width 0.3s;
}

.progress-fill.error { background: #dc2626; }

/* Estimate Grid */
.estimate-details { margin-bottom: 20px; }
.estimate-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }

.estimate-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.estimate-item strong { display: block; font-size: 24px; color: #1e293b; }
.estimate-item span { font-size: 12px; color: #64748b; }
.estimate-item.highlight { background: #eff6ff; border-color: #bfdbfe; }
.estimate-item.highlight strong { color: #2563eb; }

/* Processing Status */
.processing-status { text-align: center; padding: 20px; }
.processing-status p { margin-top: 8px; color: #64748b; }
.phase-text { font-weight: 500; color: #2563eb !important; }

/* Error Box */
.error-box { text-align: center; padding: 20px; }
.error-box h2 { color: #dc2626; margin-bottom: 8px; }
.error-box p { color: #64748b; margin-bottom: 16px; }

/* Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th {
    background: #f1f5f9;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: #475569;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: top;
}

.data-table tr:hover { background: #f8fafc; }

/* Review Table */
.review-table .col-date { width: 100px; white-space: nowrap; }
.review-table .col-provider { width: 160px; }
.review-table .col-facts { min-width: 300px; }
.review-table .col-comments { width: 120px; }
.review-table .col-pages { width: 80px; white-space: nowrap; }
.review-table .col-status { min-width: 200px; max-width: 320px; }

.row-verify { background: #fefce8 !important; }
.row-verify:hover { background: #fef9c3 !important; }
.row-unclear { background: #fef2f2 !important; }
.row-unclear:hover { background: #fee2e2 !important; }
.row-discrepancy { background: #fef2f2 !important; border-left: 4px solid #dc2626; }
.row-discrepancy .col-status { padding: 10px 12px; }

/* Flag Badges */
.flag-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.flag-verified { background: #d1fae5; color: #065f46; }
.flag-pending { background: #e2e8f0; color: #475569; }
.flag-verify { background: #fef3c7; color: #92400e; }
.flag-unclear { background: #fee2e2; color: #991b1b; }
.flag-discrepancy { background: #fee2e2; color: #991b1b; }
.flag-note {
    display: block;
    color: #64748b;
    font-size: 13px;
    line-height: 1.5;
    margin-top: 6px;
    padding: 8px 10px;
    background: #fff7f7;
    border: 1px solid #fecaca;
    border-radius: 6px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    max-height: 200px;
    overflow-y: auto;
}

/* Page Links */
.page-link { color: #2563eb; cursor: pointer; font-weight: 500; }
.page-link:hover { text-decoration: underline; }

/* Summary Bar */
.summary-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.summary-item {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 20px;
    text-align: center;
    flex: 1;
    min-width: 120px;
    cursor: pointer;
    transition: box-shadow 0.15s, transform 0.1s;
    user-select: none;
}
.summary-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.12); transform: translateY(-1px); }
.summary-item.active { box-shadow: 0 0 0 2px #2563eb; }

.summary-item strong { display: block; font-size: 24px; margin-bottom: 2px; }
.summary-item span { font-size: 12px; color: #64748b; }

.btn-resolve {
    padding: 3px 10px;
    font-size: 11px;
    border-radius: 4px;
    border: 1px solid #059669;
    background: #ecfdf5;
    cursor: pointer;
    color: #059669;
    font-weight: 600;
    margin-left: 4px;
}
.btn-resolve:hover { background: #059669; color: white; }

.filter-banner {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 10px 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.filter-banner span { color: #1d4ed8; font-weight: 500; }
.filter-banner button { background: none; border: none; color: #2563eb; cursor: pointer; font-weight: 600; font-size: 14px; }

.summary-clean { border-left: 3px solid #059669; }
.summary-clean strong { color: #059669; }
.summary-verify { border-left: 3px solid #d97706; }
.summary-verify strong { color: #d97706; }
.summary-unclear { border-left: 3px solid #dc2626; }
.summary-unclear strong { color: #dc2626; }
.summary-discrepancy { border-left: 3px solid #dc2626; }
.summary-discrepancy strong { color: #dc2626; }

/* Review Layout */
.review-layout { display: flex; gap: 16px; }

.review-table-panel {
    flex: 1;
    overflow-x: auto;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.review-table-panel.split { flex: 0.6; }

.review-pdf-panel {
    flex: 0.4;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    position: sticky;
    top: 20px;
}

.pdf-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
}

.pdf-panel-header h3 { font-size: 14px; }

.pdf-image-container { padding: 8px; }
.pdf-image-container img { width: 100%; height: auto; }

/* Warnings */
.warnings-box {
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.warnings-box p { color: #92400e; font-size: 14px; margin-bottom: 4px; }

/* Flagged Warning in Modal */
.flagged-warning {
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 16px;
}

.flagged-warning p { color: #92400e; font-size: 14px; margin: 0; }

/* Downloads */
.downloads-list { display: flex; flex-direction: column; gap: 12px; }

.download-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.download-icon { font-size: 36px; }
.download-info { flex: 1; }
.download-info h3 { font-size: 16px; margin-bottom: 4px; }
.file-size { font-size: 13px; color: #64748b; margin-right: 12px; }
.file-type { font-size: 12px; color: #2563eb; font-weight: 600; }

/* Danger Zone */
.danger-zone {
    margin-top: 40px;
    padding: 20px;
    border: 1px solid #fecaca;
    border-radius: 8px;
    background: #fff5f5;
}

.danger-zone h3 { color: #dc2626; margin-bottom: 8px; }
.danger-zone p { color: #64748b; font-size: 14px; margin-bottom: 16px; }

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 28px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h2 { font-size: 18px; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: #64748b; }
.modal-body { margin-bottom: 20px; }
.modal-body ul { margin-left: 20px; margin-top: 8px; }
.modal-body li { margin-bottom: 4px; font-size: 14px; color: #64748b; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; }

/* Case Instructions */
.instructions-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #f0f9ff;
    border: 1px solid #7dd3fc;
    border-radius: 6px;
    color: #0369a1;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.instructions-btn:hover { background: #e0f2fe; border-color: #38bdf8; }
.instructions-btn.has-instructions { background: #ecfdf5; border-color: #6ee7b7; color: #047857; }
.instructions-textarea {
    width: 100%;
    min-height: 150px;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    line-height: 1.5;
}
.instructions-textarea:focus { outline: none; border-color: #38bdf8; box-shadow: 0 0 0 3px rgba(56,189,248,0.1); }
.template-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 12px;
    background: white;
}
.instructions-warning {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 13px;
    color: #92400e;
    margin-top: 12px;
}
.instructions-saved {
    color: #047857;
    font-size: 13px;
    font-weight: 500;
    margin-top: 8px;
}

/* Empty State */
.empty-state { text-align: center; padding: 40px; color: #94a3b8; font-size: 15px; }

/* Loading */
.loading { text-align: center; padding: 20px; color: #94a3b8; }
