/* Engineering MCP Platform — System Website */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --blue: #2563eb;
    --blue-dark: #1d4ed8;
    --green: #16a34a;
    --red: #dc2626;
    --yellow: #ca8a04;
    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #e5e5e5;
    --gray-300: #d4d4d4;
    --gray-400: #a3a3a3;
    --gray-500: #737373;
    --gray-600: #525252;
    --gray-700: #404040;
    --gray-800: #262626;
    --gray-900: #171717;
    --radius: 6px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--gray-900);
    background: var(--gray-50);
    line-height: 1.6;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.site-header {
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.site-header .logo {
    font-weight: 600;
    font-size: 1rem;
    color: var(--gray-900);
    text-decoration: none;
}
.site-header nav { display: flex; gap: 1.25rem; align-items: center; }
.site-header nav a { color: var(--gray-600); font-size: 0.9rem; }
.site-header nav a:hover { color: var(--gray-900); text-decoration: none; }

.main { max-width: 800px; margin: 0 auto; padding: 2rem 1.5rem; }

.site-footer {
    border-top: 1px solid var(--gray-200);
    padding: 1.5rem;
    text-align: center;
    color: var(--gray-400);
    font-size: 0.8rem;
    margin-top: 3rem;
}

/* Typography */
h1 { font-size: 1.75rem; font-weight: 600; margin-bottom: 1rem; }
h2 { font-size: 1.35rem; font-weight: 600; margin: 1.5rem 0 0.75rem; }
h3 { font-size: 1.1rem; font-weight: 600; margin: 1.25rem 0 0.5rem; }
p { margin-bottom: 0.75rem; }

/* Status indicators */
.status-bar {
    display: flex;
    gap: 1.5rem;
    padding: 0.75rem 1rem;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 2rem;
    flex-wrap: wrap;
}
.status-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--gray-600);
}
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.status-dot.green { background: var(--green); }
.status-dot.red { background: var(--red); }
.status-dot.yellow { background: var(--yellow); }
.status-dot.gray { background: var(--gray-400); }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-secondary { background: var(--gray-200); color: var(--gray-800); }
.btn-secondary:hover { background: var(--gray-300); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.85rem; }

/* Cards */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: border-color 0.15s;
}
.card:hover { border-color: var(--blue); }
.card.disabled { opacity: 0.5; pointer-events: none; }
.card h3 { margin-top: 0; }
.card p { font-size: 0.9rem; color: var(--gray-600); margin-bottom: 0.5rem; }
.card .badge { font-size: 0.75rem; color: var(--gray-400); font-style: italic; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.9rem; font-weight: 500; margin-bottom: 0.3rem; color: var(--gray-700); }
.form-group input[type="text"],
.form-group input[type="password"] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.95rem;
}
.form-group input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px rgba(37,99,235,0.15); }

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* Code blocks */
pre, code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}
code { font-size: 0.875em; background: var(--gray-100); padding: 0.15em 0.35em; border-radius: 3px; }
pre {
    background: var(--gray-800);
    color: #e5e5e5;
    padding: 1rem;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 1rem 0;
    font-size: 0.85rem;
    line-height: 1.5;
}
pre code { background: none; padding: 0; color: inherit; }

/* Steps */
.steps { counter-reset: step; }
.step { margin-bottom: 1.5rem; padding-left: 2.5rem; position: relative; }
.step::before {
    counter-increment: step;
    content: counter(step);
    position: absolute;
    left: 0;
    top: 0;
    width: 1.75rem;
    height: 1.75rem;
    background: var(--blue);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
}
.step h3 { margin-top: 0.1rem; }

/* Collapsible / accordion */
details { margin-bottom: 0.5rem; }
details summary {
    cursor: pointer;
    padding: 0.75rem 1rem;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-weight: 500;
    font-size: 0.95rem;
    list-style: none;
}
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "▸ "; color: var(--gray-400); }
details[open] summary::before { content: "▾ "; }
details[open] summary { border-radius: var(--radius) var(--radius) 0 0; }
details .details-body {
    padding: 1rem;
    border: 1px solid var(--gray-200);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    background: #fff;
}

/* Verify page */
.verify-step {
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: var(--radius);
    background: var(--gray-100);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.verify-step.pass { background: #f0fdf4; }
.verify-step.fail { background: #fef2f2; }
.verify-step .icon { font-size: 1.1rem; }

/* Token display */
.token-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--gray-100);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-family: monospace;
    font-size: 0.9rem;
    margin: 0.5rem 0;
}

/* Callout */
.callout {
    border-left: 3px solid var(--blue);
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    background: #eff6ff;
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 0.9rem;
}
.callout.warning { border-color: var(--yellow); background: #fffbeb; }
.callout.danger { border-color: var(--red); background: #fef2f2; }

/* Tool docs (rendered from markdown) */
.tool-doc h1 { font-size: 1.5rem; }
.tool-doc table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
.tool-doc th, .tool-doc td { border: 1px solid var(--gray-200); padding: 0.5rem 0.75rem; text-align: left; font-size: 0.9rem; }
.tool-doc th { background: var(--gray-100); font-weight: 600; }
.tool-doc blockquote { border-left: 3px solid var(--gray-300); padding-left: 1rem; color: var(--gray-600); margin: 0.75rem 0; }

/* Health dashboard */
.subtitle { color: var(--gray-500); margin-bottom: 1.5rem; }

.health-summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-weight: 500;
}
.health-ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.health-warn { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.health-time { margin-left: auto; font-size: 0.8rem; font-weight: 400; opacity: 0.7; }

.health-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.health-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
}
.health-card.healthy { border-left: 3px solid var(--green); }
.health-card.degraded { border-left: 3px solid var(--yellow); }
.health-card.down { border-left: 3px solid var(--red); }

.health-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-100);
}
.health-card-header h3 { margin: 0; font-size: 0.95rem; flex: 1; }
.health-badge {
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    background: var(--gray-100);
    color: var(--gray-600);
}
.health-card.healthy .health-badge { background: #dcfce7; color: #166534; }
.health-card.degraded .health-badge { background: #fef9c3; color: #854d0e; }
.health-card.down .health-badge { background: #fecaca; color: #991b1b; }

.health-card-body { padding: 0.75rem 1rem; }

.health-detail {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    font-size: 0.85rem;
    color: var(--gray-600);
}
.health-detail span:last-child { font-weight: 500; color: var(--gray-800); }

.health-error {
    font-size: 0.8rem;
    color: var(--red);
    margin-top: 0.25rem;
    word-break: break-word;
}

.disk-bar-container { margin-top: 0.25rem; }
.disk-bar {
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}
.disk-bar-fill {
    height: 100%;
    background: var(--green);
    border-radius: 4px;
    transition: width 0.3s;
}
.disk-bar-fill.warning { background: var(--yellow); }
.disk-bar-fill.danger { background: var(--red); }
.disk-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--gray-500);
}

/* Tabs */
.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--gray-200);
    margin-bottom: 1.5rem;
}
.tab {
    padding: 0.6rem 1.25rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--gray-500);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-weight: 500;
}
.tab:hover { color: var(--gray-800); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Upload zone */
.upload-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--blue);
    background: #eff6ff;
}
.upload-icon { font-size: 2rem; color: var(--gray-400); margin-bottom: 0.5rem; }
.upload-hint { font-size: 0.85rem; color: var(--gray-400); margin-bottom: 0.25rem; }

.upload-item {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.6rem 0.75rem;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-top: 0.5rem;
    font-size: 0.85rem;
}
.upload-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-size { color: var(--gray-500); }
.upload-progress { width: 80px; height: 6px; background: var(--gray-200); border-radius: 3px; overflow: hidden; }
.upload-bar { height: 100%; background: var(--blue); border-radius: 3px; transition: width 0.2s; }
.upload-status { font-size: 0.8rem; color: var(--gray-500); }
.upload-status.success { color: var(--green); }
.upload-status.error { color: var(--red); }

/* Event log */
.event-log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}
.event-log-title { font-weight: 600; font-size: 0.95rem; }
.event-log-status { font-size: 0.8rem; color: var(--gray-400); }
.event-log {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: #fff;
}
.event-row {
    display: grid;
    grid-template-columns: 120px 160px 140px 1fr;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.8rem;
    align-items: center;
}
.event-row:last-child { border-bottom: none; }
.event-row.severity-warning { background: #fffbeb; }
.event-row.severity-error { background: #fef2f2; }
.event-time { color: var(--gray-400); font-family: monospace; font-size: 0.75rem; }
.event-type { font-weight: 500; color: var(--gray-700); }
.event-file { color: var(--gray-500); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-msg { color: var(--gray-600); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Document list (rejected, revision) */
.doc-list { }
.doc-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}
.doc-name { font-weight: 500; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    font-weight: 500;
}
.doc-badge.rejected { background: #fecaca; color: #991b1b; }
.doc-badge.duplicate { background: #fef9c3; color: #854d0e; }
.doc-badge.revision_candidate { background: #dbeafe; color: #1e40af; }
.doc-reason { color: var(--gray-500); font-size: 0.8rem; }
.doc-size { color: var(--gray-400); font-size: 0.8rem; }
.doc-time { color: var(--gray-400); font-size: 0.75rem; }
.empty { color: var(--gray-400); text-align: center; padding: 2rem; }

/* Narrow form pages */
.narrow { max-width: 440px; margin: 2rem auto; }

/* --- Phase 5: Bundle & Revision styles --- */

/* Tab links (non-button tabs) */
.tab-link {
    display: inline-block; padding: 0.5rem 1rem; text-decoration: none;
    color: var(--blue); font-size: 0.85rem; border-bottom: 2px solid transparent;
}
.tab-link:hover { border-bottom-color: var(--blue); }

/* Bundle assignment on upload */
.bundle-assign-section {
    margin: 1rem 0; padding: 1rem; background: var(--gray-50);
    border: 1px solid var(--gray-200); border-radius: var(--radius);
}
.toggle-label { font-weight: 600; cursor: pointer; }
.toggle-label input { margin-right: 0.5rem; }
.bundle-search-row { position: relative; margin-top: 0.75rem; }
.bundle-results {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 10;
    background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius);
    max-height: 200px; overflow-y: auto; box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.bundle-result-item { padding: 0.5rem 0.75rem; cursor: pointer; }
.bundle-result-item:hover { background: var(--gray-100); }
.bundle-or { text-align: center; color: var(--gray-400); margin: 0.5rem 0; font-size: 0.85rem; }
.bundle-new-row { margin-bottom: 0.5rem; }
#new-bundle-fields { margin-top: 0.5rem; display: flex; flex-direction: column; gap: 0.4rem; }
.bundle-role-row { margin-top: 0.5rem; display: flex; align-items: center; gap: 0.5rem; }
.bundle-role-row label { font-weight: 500; font-size: 0.85rem; }

/* Input fields */
.input-field {
    padding: 0.4rem 0.6rem; border: 1px solid var(--gray-300); border-radius: var(--radius);
    font-size: 0.85rem; width: 100%; font-family: inherit;
}
.input-field:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px rgba(37,99,235,0.15); }
.search-field { max-width: 300px; }

/* Buttons */
.btn {
    padding: 0.4rem 0.8rem; border: 1px solid var(--gray-300); border-radius: var(--radius);
    background: var(--blue); color: #fff; cursor: pointer; font-size: 0.85rem; font-family: inherit;
}
.btn:hover { background: var(--blue-dark); }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.8rem; }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #b91c1c; }
.btn-confirm { background: var(--green); }
.btn-confirm:hover { background: #15803d; }
.btn-reject { background: var(--gray-500); color: #fff; }
.btn-reject:hover { background: var(--gray-600); }

/* Bundle toolbar */
.bundle-toolbar {
    display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem;
}

/* Bundle table */
.bundle-table { border: 1px solid var(--gray-200); border-radius: var(--radius); overflow: hidden; }
.bundle-table-header {
    display: grid; grid-template-columns: 2fr 1fr 1fr 80px 100px 100px;
    padding: 0.5rem 0.75rem; background: var(--gray-100); font-weight: 600; font-size: 0.8rem;
    color: var(--gray-600); border-bottom: 1px solid var(--gray-200);
}
.bundle-row {
    display: grid; grid-template-columns: 2fr 1fr 1fr 80px 100px 100px;
    padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--gray-100);
    text-decoration: none; color: inherit; font-size: 0.85rem;
}
.bundle-row:hover { background: var(--gray-50); }
.bundle-name { font-weight: 600; color: var(--blue); }
.doc-count { text-align: center; }
.bundle-date { color: var(--gray-400); font-size: 0.8rem; }

/* Bundle detail */
.breadcrumb { font-size: 0.85rem; color: var(--gray-500); margin-bottom: 1rem; }
.breadcrumb a { color: var(--blue); text-decoration: none; }
.bundle-header { margin-bottom: 1.5rem; }
.bundle-meta-row {
    display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.4rem;
}
.bundle-meta-row label { width: 120px; font-weight: 500; font-size: 0.85rem; color: var(--gray-600); }
.inline-edit { max-width: 400px; }
.save-status { font-size: 0.8rem; color: var(--green); margin-left: 0.5rem; }
.inferred-banner {
    padding: 0.6rem 1rem; background: #fef9c3; border: 1px solid #fde047;
    border-radius: var(--radius); font-size: 0.85rem; margin-bottom: 1rem;
}

/* Role dropdown in bundle docs */
.role-select {
    padding: 0.2rem 0.4rem; border: 1px solid var(--gray-300); border-radius: var(--radius);
    font-size: 0.8rem; font-family: inherit;
}
.bundle-doc-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.bundle-add-section { margin: 1.5rem 0; }

/* Revision candidate actions */
.revision-row { flex-direction: column; align-items: flex-start; }
.doc-row-main { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.doc-candidates { margin: 0.4rem 0; }
.candidate-option { display: inline-flex; align-items: center; gap: 0.25rem; margin-right: 1rem; font-size: 0.85rem; }
.candidate-label { font-size: 0.8rem; color: var(--gray-500); margin-bottom: 0.25rem; }
.candidate-id { font-family: monospace; font-size: 0.8rem; }
.doc-actions { display: flex; gap: 0.5rem; margin-top: 0.4rem; }

/* Revision chain */
.revision-chain-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.chain-link { font-size: 0.8rem; color: var(--gray-500); }
.chain-link code { font-size: 0.75rem; background: var(--gray-100); padding: 0.1rem 0.3rem; border-radius: 3px; }
.doc-badge.current { background: #dcfce7; color: #166534; }
.doc-badge.superseded { background: #fee2e2; color: #991b1b; }

/* Modal */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 100;
    display: flex; align-items: center; justify-content: center;
}
.modal {
    background: #fff; border-radius: var(--radius); padding: 1.5rem; max-width: 480px; width: 90%;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.modal h2 { margin-bottom: 1rem; }
.form-group { margin-bottom: 0.75rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 500; margin-bottom: 0.25rem; }
.required { color: var(--red); }
.modal-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }
.modal-error { color: var(--red); font-size: 0.85rem; margin-top: 0.5rem; }
.muted { color: var(--gray-400); }

/* --- Phase 7: Developer panel styles --- */
.clickable { cursor: pointer; }
.clickable:hover { background: var(--gray-50); }

.json-block {
    background: var(--gray-900); color: #a5f3fc; padding: 1rem;
    border-radius: var(--radius); font-family: monospace; font-size: 0.8rem;
    white-space: pre-wrap; word-break: break-all; overflow-x: auto;
    max-height: 300px; overflow-y: auto;
}

.page-viewer {
    display: flex; flex-wrap: wrap; gap: 1rem; margin: 1rem 0;
}
.page-thumb {
    display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
}
.page-thumb img {
    max-width: 200px; max-height: 280px; border: 1px solid var(--gray-200);
    border-radius: var(--radius); box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.page-thumb span { font-size: 0.75rem; color: var(--gray-500); }

.doc-badge.extracting_docling { background: #dbeafe; color: #1e40af; }
.doc-badge.extracting_mineru { background: #ede9fe; color: #5b21b6; }
.doc-badge.comparing { background: #d1fae5; color: #065f46; }
.doc-badge.extraction_failed { background: #fee2e2; color: #991b1b; }
.doc-badge.failed { background: #fee2e2; color: #991b1b; }
.doc-badge.warning { background: #fef3c7; color: #92400e; }

/* --- Phase 8: Side-by-side extraction viewer --- */
.extraction-header {
    display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.extraction-header h2 { margin: 0; }

.extraction-columns {
    display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-top: 1.5rem;
}
@media (max-width: 900px) {
    .extraction-columns { grid-template-columns: 1fr; }
}
.extraction-col {
    min-width: 0;
}
.col-heading {
    padding: 0.5rem 0.75rem; border-radius: var(--radius) var(--radius) 0 0;
    margin-bottom: 0.75rem; font-size: 1rem;
}
.docling-heading { background: #dbeafe; color: #1e40af; }
.mineru-heading { background: #ede9fe; color: #5b21b6; }

.extraction-col h4 {
    font-size: 0.85rem; color: var(--gray-600); margin: 0.75rem 0 0.25rem;
    display: flex; align-items: center; gap: 0.5rem;
}
.extraction-status { min-height: 1.5rem; }
.processing-indicator {
    display: inline-block; padding: 0.25rem 0.75rem; border-radius: var(--radius);
    background: #fef3c7; color: #92400e; font-size: 0.85rem; font-weight: 500;
    animation: pulse-bg 2s ease-in-out infinite;
}
@keyframes pulse-bg {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* --- Phase 9: Comparison tab styles --- */
.comparison-controls {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1rem;
}
.comparison-controls h2 { margin: 0; }
.outcome-filters { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.outcome-filter {
    padding: 0.3rem 0.75rem; border-radius: var(--radius); border: 1px solid var(--gray-300);
    background: #fff; cursor: pointer; font-size: 0.85rem; color: var(--gray-600);
}
.outcome-filter:hover { background: var(--gray-100); }
.outcome-filter.active { background: var(--blue); color: #fff; border-color: var(--blue); }

.doc-badge.outcome-agree { background: #d1fae5; color: #065f46; }
.doc-badge.outcome-minor_differences { background: #fef3c7; color: #92400e; }
.doc-badge.outcome-significant_disagreement { background: #fee2e2; color: #991b1b; }
.doc-badge.outcome-docling_only { background: var(--gray-200); color: var(--gray-600); }
.doc-badge.outcome-unknown { background: var(--gray-100); color: var(--gray-500); }

.comparison-summary { margin: 1rem 0; }
.summary-grid {
    display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 0.5rem;
}
.summary-stat {
    display: flex; flex-direction: column; align-items: center;
    padding: 0.75rem 1rem; background: #fff; border: 1px solid var(--gray-200);
    border-radius: var(--radius); min-width: 80px;
}
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); }
.stat-label { font-size: 0.75rem; color: var(--gray-500); text-transform: uppercase; }

.heatmap-container {
    display: flex; flex-wrap: wrap; gap: 3px; margin: 0.75rem 0;
}
.heatmap-cell {
    width: 32px; height: 32px; border-radius: 3px; display: flex;
    align-items: center; justify-content: center; cursor: pointer;
    font-size: 0.65rem; color: var(--gray-700); font-weight: 500;
    border: 1px solid rgba(0,0,0,0.08);
}
.heatmap-cell:hover { outline: 2px solid var(--blue); outline-offset: 1px; }

.diff-page { margin: 1rem 0; padding: 1rem; background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius); }
.diff-page h4 { margin: 0 0 0.75rem; display: flex; align-items: center; gap: 0.5rem; }
.diff-element {
    margin: 0.5rem 0; padding: 0.5rem; background: var(--gray-50); border-radius: var(--radius);
}
.diff-type {
    display: inline-block; padding: 0.15rem 0.5rem; background: var(--gray-200);
    border-radius: 3px; font-size: 0.75rem; font-weight: 500; text-transform: uppercase;
}
.diff-sim {
    margin-left: 0.5rem; font-size: 0.8rem; color: var(--gray-500);
}
.diff-columns {
    display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-top: 0.5rem;
}
.diff-col pre {
    font-size: 0.75rem; white-space: pre-wrap; word-break: break-word;
    background: var(--gray-100); padding: 0.5rem; border-radius: 3px;
    max-height: 150px; overflow-y: auto; margin: 0.25rem 0 0;
}
.diff-col strong { font-size: 0.8rem; color: var(--gray-600); }
@media (max-width: 700px) {
    .diff-columns { grid-template-columns: 1fr; }
}

/* --- Phase 10: Enrichment page styles --- */
.main.wide { max-width: 1200px; }

.entity-counts {
    display: flex; gap: 0.4rem; align-items: center;
}
.ec {
    font-size: 0.7rem; font-weight: 600; padding: 0.1rem 0.4rem;
    border-radius: 3px; background: var(--gray-100); color: var(--gray-600);
}

.doc-badge.enr-type { background: #dbeafe; color: #1e40af; }
.doc-badge.enr-category { background: #ede9fe; color: #5b21b6; }
.doc-badge.enriching { background: #fef3c7; color: #92400e; }
.doc-badge.enrichment_failed { background: #fee2e2; color: #991b1b; }
.doc-badge.chunking { background: #d1fae5; color: #065f46; }
.doc-badge.complete, .doc-badge.ready { background: #dcfce7; color: #166534; }

/* Entity sub-tabs */
.entity-tab-bar {
    display: flex; gap: 0; border-bottom: 2px solid var(--gray-200); margin-bottom: 1rem;
}
.entity-tab {
    padding: 0.5rem 1rem; border: none; background: none; cursor: pointer;
    font-size: 0.85rem; color: var(--gray-500); border-bottom: 2px solid transparent;
    margin-bottom: -2px; font-weight: 500;
}
.entity-tab:hover { color: var(--gray-800); }
.entity-tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.entity-tab-content { display: none; }
.entity-tab-content.active { display: block; }
.entity-count { font-size: 0.85rem; color: var(--gray-500); margin-bottom: 0.75rem; }

/* Entity tables */
.table-scroll { overflow-x: auto; }
.entity-table {
    width: 100%; border-collapse: collapse; font-size: 0.8rem;
    background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius);
}
.entity-table th {
    background: var(--gray-100); padding: 0.5rem 0.6rem; text-align: left;
    font-weight: 600; color: var(--gray-600); border-bottom: 1px solid var(--gray-200);
    white-space: nowrap; font-size: 0.75rem; text-transform: uppercase;
}
.entity-table td {
    padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--gray-100);
    max-width: 200px; overflow: hidden; text-overflow: ellipsis;
}
.entity-table tr:hover { background: var(--gray-50); }
.entity-table .num { text-align: right; font-family: monospace; font-size: 0.8rem; }
.entity-table .conditions { font-size: 0.75rem; color: var(--gray-500); max-width: 150px; }
.entity-table .provenance, .provenance {
    font-size: 0.7rem; color: var(--gray-400);
}
.prov-text { white-space: nowrap; }
.doc-name-cell { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: var(--blue); }
.sortable.sort-asc::after { content: " \u25B2"; font-size: 0.6rem; }
.sortable:not(.sort-asc)::after { content: " \u25BC"; font-size: 0.6rem; opacity: 0.3; }

/* Register cards */
.register-card { margin-bottom: 0.5rem; }
.register-card summary { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.reg-name { font-weight: 600; font-family: monospace; }
.reg-addr { font-family: monospace; color: var(--gray-500); font-size: 0.85rem; }
.bitfield-table { margin-top: 0.5rem; }
.bitfield-table th, .bitfield-table td { font-size: 0.75rem; padding: 0.3rem 0.5rem; }

/* Figure gallery */
.figure-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem; margin: 1rem 0;
}
.figure-card {
    background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius);
    overflow: hidden;
}
.figure-img-wrap {
    background: var(--gray-100); display: flex; align-items: center; justify-content: center;
    min-height: 120px; max-height: 300px; overflow: hidden;
}
.figure-img-wrap img {
    max-width: 100%; max-height: 300px; object-fit: contain;
}
.figure-info { padding: 0.75rem; }
.figure-info strong { font-size: 0.9rem; display: block; margin-bottom: 0.25rem; }
.figure-info p { font-size: 0.8rem; color: var(--gray-600); margin: 0.25rem 0; }
.figure-tags { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.4rem; }
.figure-tag {
    font-size: 0.7rem; padding: 0.1rem 0.4rem; border-radius: 3px;
    background: #eff6ff; color: var(--blue); font-weight: 500;
}

/* Cost summary */
.cost-summary { margin-bottom: 1rem; }
