/* CSS Variables */
:root {
    --bg-primary: #0f1419;
    --bg-secondary: #1a1f26;
    --bg-tertiary: #242b33;
    --bg-hover: #2d353f;
    --text-primary: #e7e9ea;
    --text-secondary: #8b98a5;
    --text-muted: #6e7681;
    --border-color: #2f3336;
    --accent-blue: #1d9bf0;
    --accent-green: #00ba7c;
    --accent-red: #f4212e;
    --accent-yellow: #ffd400;
    --accent-purple: #7856ff;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    --radius: 8px;
    --radius-lg: 12px;
}

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

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

.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.logo-icon { font-size: 24px; }
.logo h1 { font-size: 18px; font-weight: 700; }
.header-actions { display: flex; gap: 12px; }

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary { background: var(--accent-blue); color: white; }
.btn-primary:hover { background: #1a8cd8; }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-small { padding: 4px 10px; font-size: 11px; }
.btn-block { width: 100%; margin-top: 12px; }
.btn-close { background: none; border: none; color: var(--text-secondary); font-size: 24px; cursor: pointer; }
.link-btn { background: none; border: none; color: var(--accent-blue); cursor: pointer; text-decoration: underline; font-size: inherit; }

/* Main Layout */
.main {
    display: grid;
    grid-template-columns: 260px 1fr 320px;
    flex: 1;
    overflow: hidden;
    height: calc(100vh - 56px);
}

/* Sidebar */
.sidebar {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar h2 { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.5px; }

/* Compact Upload */
.upload-compact {
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    padding: 12px;
}

.drop-zone-compact {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
    transition: all 0.2s;
    cursor: pointer;
}

.drop-zone-compact:hover,
.drop-zone-compact.dragover {
    border-color: var(--accent-blue);
    background: rgba(29, 155, 240, 0.05);
}

.drop-icon-small { font-size: 20px; margin-right: 8px; }

.file-list-compact {
    margin-top: 10px;
    max-height: 100px;
    overflow-y: auto;
}

.file-item-compact {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    margin-bottom: 4px;
    font-size: 12px;
}

.file-item-compact .remove-file {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
}

/* Criteria */
.criteria-section { flex: 1; }

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.criteria-list { display: flex; flex-direction: column; gap: 6px; }

.criterion-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    font-size: 12px;
}

.criterion-status {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 2px;
    cursor: pointer;
    border: 2px solid var(--border-color);
}

.criterion-status.met { background: var(--accent-green); border-color: var(--accent-green); }
.criterion-status.partial { background: var(--accent-yellow); border-color: var(--accent-yellow); }
.criterion-status.not-met { background: var(--accent-red); border-color: var(--accent-red); }

.criterion-content { flex: 1; }
.criterion-text { display: block; margin-bottom: 4px; }
.criterion-actual { font-size: 11px; color: var(--accent-blue); font-weight: 500; }
.criterion-gap { font-size: 10px; color: var(--accent-red); }

.criteria-score {
    margin-top: 12px;
    padding: 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.score-value { font-weight: 700; color: var(--accent-blue); }

.firm-profiles select { width: 100%; }
.input { width: 100%; padding: 8px 12px; background: var(--bg-tertiary); border: 1px solid var(--border-color); border-radius: var(--radius); color: var(--text-primary); font-size: 13px; }
.input:focus { outline: none; border-color: var(--accent-blue); }

/* Center Content */
.content {
    padding: 20px;
    overflow-y: auto;
    background: var(--bg-primary);
}

.hidden { display: none !important; }

/* Empty State */
.empty-state-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-muted);
}

.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state-center h3 { font-size: 18px; margin-bottom: 8px; color: var(--text-secondary); }
.empty-state-center p { font-size: 14px; }

/* Deal Overview */
.deal-overview-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
}

.deal-overview-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.deal-overview-header h2 { font-size: 24px; font-weight: 700; }

.industry-badge {
    background: var(--accent-purple);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.business-model {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
}

.deal-overview-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.overview-item {
    background: var(--bg-tertiary);
    padding: 12px;
    border-radius: var(--radius);
    text-align: center;
}

.overview-label {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.overview-value {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.overview-value.positive { color: var(--accent-green); }
.overview-value.negative { color: var(--accent-red); }
.overview-value.warning { color: var(--accent-yellow); }

/* Summary Section */
.summary-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
}

.summary-section h2 { font-size: 18px; margin-bottom: 16px; }

.summary-main-content {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    border-left: 4px solid var(--accent-blue);
}

.summary-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.summary-column {
    background: var(--bg-tertiary);
    padding: 16px;
    border-radius: var(--radius);
}

.summary-column h3 { font-size: 14px; margin-bottom: 12px; }
.summary-column.risks { border-left: 3px solid var(--accent-red); }
.summary-column.strengths { border-left: 3px solid var(--accent-green); }
.summary-column ul { padding-left: 16px; font-size: 13px; color: var(--text-secondary); }
.summary-column li { margin-bottom: 6px; }

.summary-followup {
    background: var(--bg-tertiary);
    padding: 16px;
    border-radius: var(--radius);
    border-left: 3px solid var(--accent-yellow);
}

.summary-followup h3 { font-size: 14px; margin-bottom: 12px; }
.summary-followup ul { padding-left: 16px; font-size: 13px; color: var(--text-secondary); }
.summary-followup li { margin-bottom: 6px; }

/* Industry Section */
.industry-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
}

.industry-section h2 { font-size: 18px; margin-bottom: 16px; }

.industry-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.industry-card {
    background: var(--bg-tertiary);
    padding: 16px;
    border-radius: var(--radius);
}

.industry-card h4 {
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 10px;
}

.industry-card ul { padding-left: 16px; font-size: 13px; color: var(--text-secondary); }
.industry-card li { margin-bottom: 6px; }
.industry-card p { font-size: 13px; color: var(--text-secondary); }

.industry-risk {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.industry-risk:last-child { border-bottom: none; }
.industry-risk-text { flex: 1; font-size: 13px; }
.industry-risk-severity {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
}

.severity-high { background: rgba(244, 33, 46, 0.2); color: var(--accent-red); }
.severity-medium { background: rgba(255, 212, 0, 0.2); color: var(--accent-yellow); }
.severity-low { background: rgba(0, 186, 124, 0.2); color: var(--accent-green); }

/* Charts Section */
.charts-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
}

.charts-section h2 { font-size: 18px; margin-bottom: 16px; }

.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.chart-card {
    background: var(--bg-tertiary);
    padding: 16px;
    border-radius: var(--radius);
}

.chart-card h4 {
    font-size: 14px;
    margin-bottom: 4px;
}

.chart-page-ref {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.chart-container {
    height: 180px;
    margin-bottom: 12px;
}

.chart-insight {
    font-size: 12px;
    color: var(--accent-blue);
    padding: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    border-left: 3px solid var(--accent-blue);
}

/* Results Panel */
.results-panel {
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.results-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    padding: 8px;
    gap: 4px;
}

.tab {
    flex: 1;
    padding: 8px 12px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius);
    transition: all 0.2s;
}

.tab:hover { background: var(--bg-tertiary); }
.tab.active { background: var(--accent-blue); color: white; }

.results-content { flex: 1; overflow-y: auto; }

.tab-content { display: none; padding: 16px; }
.tab-content.active { display: block; }

.results-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.results-header h3 { font-size: 14px; flex: 1; }
.count-badge { background: var(--bg-tertiary); padding: 2px 8px; border-radius: 10px; font-size: 12px; }

.results-list { display: flex; flex-direction: column; gap: 12px; }
.empty-state { color: var(--text-muted); font-size: 13px; text-align: center; padding: 20px; }

/* Result Items */
.result-item {
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    padding: 12px;
    border-left: 3px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
}

.result-item:hover { background: var(--bg-hover); }
.result-item.red { border-left-color: var(--accent-red); }
.result-item.green { border-left-color: var(--accent-green); }
.result-item.yellow { border-left-color: var(--accent-yellow); }

.result-item h4 { font-size: 13px; margin-bottom: 4px; }
.result-item .result-category { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; }
.result-item .result-explanation { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }

.result-item .citation {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
    padding: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    margin-bottom: 8px;
}

.result-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
}

.page-badge {
    background: var(--bg-secondary);
    padding: 2px 8px;
    border-radius: 4px;
    color: var(--accent-blue);
}

.severity-badge, .strength-badge, .importance-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
}

.severity-badge.critical { background: rgba(244, 33, 46, 0.3); color: var(--accent-red); }
.severity-badge.high { background: rgba(244, 33, 46, 0.2); color: var(--accent-red); }
.severity-badge.medium { background: rgba(255, 212, 0, 0.2); color: var(--accent-yellow); }
.severity-badge.low { background: rgba(0, 186, 124, 0.2); color: var(--accent-green); }

.strength-badge.strong { background: rgba(0, 186, 124, 0.3); color: var(--accent-green); }
.strength-badge.moderate { background: rgba(0, 186, 124, 0.2); color: var(--accent-green); }
.strength-badge.notable { background: rgba(29, 155, 240, 0.2); color: var(--accent-blue); }

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden { display: none; }

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 { font-size: 16px; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 12px; }

.criteria-editor { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.criteria-edit-item { display: flex; gap: 10px; }
.criteria-edit-item input { flex: 1; }
.remove-criterion { background: none; border: none; color: var(--accent-red); cursor: pointer; font-size: 18px; }

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 20, 25, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-overlay.hidden { display: none; }

.loading-content { text-align: center; }

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

.loading-content p { color: var(--text-secondary); }

/* Responsive */
@media (max-width: 1200px) {
    .main {
        grid-template-columns: 240px 1fr 280px;
    }
    .deal-overview-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    .main {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
    }
    .sidebar { border-right: none; border-bottom: 1px solid var(--border-color); }
    .results-panel { border-left: none; border-top: 1px solid var(--border-color); }
    .deal-overview-grid { grid-template-columns: repeat(2, 1fr); }
    .summary-columns { grid-template-columns: 1fr; }
    .industry-content { grid-template-columns: 1fr; }
    .charts-grid { grid-template-columns: 1fr; }
}
