/* ==========================================================================
   Opened-document page (Results section)
   History rail on the left; the document on a white sheet with a type
   eyebrow, filename, one meta line and Extracted data / Checks / Insights
   tabs. Loaded after styles.css.
   ========================================================================== */

#results-section .section-page-heading,
#results-section .results-toolbar,
#results-section .documents-sidebar {
    display: none !important;
}

/* Edge to edge: the rail runs flush left, the sheet sits on a warm ground. */
#results-section.results-section.active { padding: 0; gap: 0; }

#results-section .results-layout {
    align-items: flex-start;
    border: 0;
    border-radius: 0;
    background: #F7F7F5;
    overflow: visible;
    min-height: calc(100vh - 56px);
}

#results-section .document-detail-panel {
    flex: 1;
    min-width: 0;
    padding: 28px 24px 48px;
    background: transparent;
    overflow: visible;
}

/* ---- History rail ----------------------------------------------------- */
.doc-rail {
    position: sticky;
    top: 56px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-sizing: border-box;
    width: 264px;
    height: calc(100vh - 56px);
    flex-shrink: 0;
    padding: 20px 12px;
    background: #FFFFFF;
    border-right: 1px solid #ECEBE9;
    font-family: var(--font-body);
}
.doc-rail-head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px; }
.doc-rail-title { font-size: 13px; font-weight: 600; line-height: 18px; color: #18181B; }
.doc-rail-toggle {
    display: inline-flex; padding: 3px; border: 0; border-radius: 6px;
    background: none; color: #737373; cursor: pointer;
}
.doc-rail-toggle:hover { background: #F5F5F4; color: #18181B; }
.doc-rail-search {
    display: flex; align-items: center; gap: 6px;
    height: 30px; margin: -4px 8px 0; padding: 0 10px;
    border: 1px solid #E7E5E4; border-radius: 8px;
    color: #737373;
}
.doc-rail-search:focus-within { border-color: #418D62; box-shadow: 0 0 0 3px #E8F5EC; }
.doc-rail-search input {
    flex: 1; min-width: 0; padding: 0; border: 0; outline: 0; background: none;
    font: inherit; font-size: 12px; color: #18181B;
}
.doc-rail-search input::placeholder { color: #A8A29E; }
.doc-rail-search input::-webkit-search-cancel-button { display: none; }
.doc-rail-kbd { font-family: inherit; font-size: 11px; line-height: 14px; color: #A8A29E; }
.doc-rail-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.doc-rail-group { display: flex; flex-direction: column; gap: 2px; }
.doc-rail-group-label {
    padding: 4px 8px 6px;
    font-size: 11px; font-weight: 500; letter-spacing: 0.06em; line-height: 14px;
    text-transform: uppercase; color: #737373;
}
.doc-rail-item {
    display: flex; align-items: flex-start; gap: 10px;
    width: 100%; padding: 8px; border: 0; border-radius: 8px;
    background: none; font: inherit; text-align: left; cursor: pointer;
}
.doc-rail-item:hover { background: #FAFAF9; }
.doc-rail-item.is-current { background: #EEF5F0; }
.doc-rail-dot {
    box-sizing: border-box; flex-shrink: 0;
    width: 6px; height: 6px; margin: 6px 1px 0;
    border-radius: 3px; background: #418D62;
}
.doc-rail-item.is-review .doc-rail-dot { background: #D97706; }
.doc-rail-item.is-processing .doc-rail-dot { background: none; border: 1.5px solid #A8A29E; }
.doc-rail-item.is-failed .doc-rail-dot { background: #DC2626; }
.doc-rail-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.doc-rail-name { font-size: 13px; line-height: 18px; color: #18181B; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-rail-item.is-current .doc-rail-name { font-weight: 500; }
.doc-rail-sub { font-size: 12px; line-height: 16px; color: #737373; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-rail-item.is-current .doc-rail-sub { color: #57534E; }
.doc-rail-item.is-processing .doc-rail-name { color: #57534E; }
.doc-rail-item.is-processing .doc-rail-sub { color: #A8A29E; }
.doc-rail-empty { padding: 8px; font-size: 12px; color: #A8A29E; }
.doc-rail-all {
    display: flex; align-items: center; gap: 6px;
    padding: 8px; border: 0; border-top: 1px solid #F0EFEE; background: none;
    font: inherit; font-size: 12px; font-weight: 500; line-height: 16px; color: #418D62;
    text-align: left; cursor: pointer;
}
.doc-rail-all:hover { color: #2F6B49; }
.doc-rail.is-collapsed { width: 48px; padding: 20px 8px; }
.doc-rail.is-collapsed > :not(.doc-rail-head),
.doc-rail.is-collapsed .doc-rail-title { display: none; }
.doc-rail.is-collapsed .doc-rail-head { justify-content: center; padding: 0; }
.doc-rail.is-collapsed .doc-rail-toggle svg { transform: scaleX(-1); }
@media (max-width: 900px) {
    .doc-rail { display: none; }
}

/* ---- Sheet + header ---------------------------------------------------- */
.doc-sheet {
    box-sizing: border-box;
    max-width: 1120px;
    margin: 0 auto;
    padding: 36px 32px 40px;
    background: #FFFFFF;
    border: 1px solid #ECEBE9;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(24, 24, 27, 0.04);
}
@media (max-width: 640px) {
    #results-section .document-detail-panel { padding: 16px; }
    .doc-sheet { padding: 24px 16px; }
}

#results-section .doc-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding: 0;
    border: 0;
    background: none;
}
.doc-page-header-main { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.doc-page-eyebrow {
    font-family: var(--font-body);
    font-size: 12px; font-weight: 500; letter-spacing: 0.06em; line-height: 16px;
    text-transform: uppercase; color: #418D62;
}
.doc-page-title {
    margin: 0;
    font-family: var(--font-body);
    font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 32px;
    color: #18181B;
    overflow-wrap: anywhere;
}
.doc-page-meta { font-family: var(--font-body); font-size: 13px; line-height: 18px; color: #57534E; }
.doc-page-eyebrow:empty,
.doc-page-meta:empty { display: none; }
.doc-page-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ---- Tabs: Extracted data / Checks / Insights -------------------------- */
#results-section .detail-tabs-container {
    min-height: 0;
    margin: 20px 0 32px;
    padding: 0;
    border-bottom: 1px solid #ECEBE9;
    background: none;
}
#results-section .tabs.doc-steps { display: flex; align-items: flex-end; gap: 24px !important; } /* beats .detail-tabs-container .tabs { gap: 0 !important } */
#results-section .doc-steps .tab {
    margin: 0 0 -1px;
    padding: 0 0 10px;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: none;
    box-shadow: none;
    font-family: var(--font-body);
    font-size: 13px; font-weight: 400; line-height: 18px;
    color: #737373;
}
#results-section .doc-steps .tab:hover { color: #18181B; }
#results-section .doc-steps .tab.active { color: #18181B; font-weight: 600; border-bottom-color: #18181B; }
#results-section .doc-steps .tab::after { display: none !important; }

#results-section .detail-content { padding: 0; overflow: visible; }

/* ---- Fraud Check: deterministic checklist ------------------------------ */
.fraud-checklist { display: flex; flex-direction: column; gap: 28px; font-family: var(--font-body); }

.fraud-risk-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    border: 1px solid #E7E5E4;
    border-radius: 12px;
    background: #FAFAFA;
}
.fraud-risk-card.is-low { background: #F3F8F4; border-color: #D5E8DC; }
.fraud-risk-card.is-medium { background: #FBF7EE; border-color: #F1E3C4; }
.fraud-risk-card.is-high { background: #FCEFEF; border-color: #F3C9C9; }
.fraud-risk-icon {
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; flex-shrink: 0; border-radius: 10px;
}
.is-low .fraud-risk-icon { background: #DCFCE7; color: #15803D; }
.is-medium .fraud-risk-icon { background: #FDE9C4; color: #B45309; }
.is-high .fraud-risk-icon { background: #FEE2E2; color: #B91C1C; }
.fraud-risk-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.fraud-risk-level { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; line-height: 26px; }
.is-low .fraud-risk-level { color: #15803D; }
.is-medium .fraud-risk-level { color: #92400E; }
.is-high .fraud-risk-level { color: #991B1B; }
.fraud-risk-reason { font-size: 13px; line-height: 18px; color: #57534E; }
.fraud-risk-ai { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.fraud-risk-ai-label { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 500; color: #57534E; }
.fraud-risk-ai-label svg { color: #418D62; }
.fraud-risk-ai-value { font-size: 20px; font-weight: 600; line-height: 24px; color: #18181B; }
.fraud-risk-ai-value small { margin-left: 2px; font-size: 12px; font-weight: 400; color: #A8A29E; }

.fraud-section { display: flex; flex-direction: column; gap: 12px; }
.fraud-section-title { margin: 0; font-size: 15px; font-weight: 600; line-height: 20px; color: #18181B; }
.fraud-check-list { display: flex; flex-direction: column; border-top: 1px solid #E7E5E4; }

.fraud-check-row { border-bottom: 1px solid #F0EFEE; }
.fraud-check-row > summary,
div.fraud-check-row {
    display: grid;
    grid-template-columns: 18px 180px 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 12px;
    list-style: none;
}
.fraud-check-row > summary { cursor: pointer; grid-template-columns: 18px 180px 1fr auto 14px; }
.fraud-check-row > summary::after { content: '⌄'; color: #A8A29E; font-size: 14px; line-height: 1; }
.fraud-check-row[open] > summary::after { content: '⌃'; }
.fraud-check-row > summary::-webkit-details-marker { display: none; }
.fraud-check-row.is-review { background: #FBF7EE; }
.fraud-check-row.is-fail { background: #FCEFEF; }
.fraud-check-icon {
    display: flex; align-items: center; justify-content: center;
    width: 18px; height: 18px; border-radius: 999px;
    font-size: 12px; font-weight: 700; line-height: 14px;
}
.fraud-check-icon.is-pass { background: #DCFCE7; color: #15803D; }
.fraud-check-icon.is-review { background: #FDE9C4; color: #B45309; }
.fraud-check-icon.is-fail { background: #FEE2E2; color: #B91C1C; }
.fraud-check-icon.is-not_run { background: #F5F5F4; color: #A8A29E; }
.fraud-check-label { font-size: 14px; font-weight: 600; color: #18181B; }
.fraud-check-detail { font-size: 13px; color: #57534E; min-width: 0; }
.fraud-check-status { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; text-align: right; }
.fraud-check-status.is-pass { color: #15803D; }
.fraud-check-status.is-review { color: #B45309; }
.fraud-check-status.is-fail { color: #B91C1C; }
.fraud-check-status.is-not_run { color: #A8A29E; }
.fraud-check-findings { padding: 0 12px 14px 42px; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px 20px; }

.fraud-flagged { border: 1px solid #F1E3C4; border-radius: 10px; overflow: hidden; }
.fraud-flagged-row {
    display: grid;
    grid-template-columns: 96px 1fr 240px 150px;
    gap: 16px;
    align-items: center;
    padding: 11px 16px;
    background: #FBF7EE;
    border-bottom: 1px solid #F1E3C4;
    font-size: 13px;
}
.fraud-flagged-row:last-child { border-bottom: 0; }
.fraud-flagged-date { color: #57534E; white-space: nowrap; }
.fraud-flagged-desc { font-weight: 500; color: #18181B; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fraud-flagged-reason { font-size: 12px; color: #92400E; }
.fraud-flagged-amount { text-align: right; font-weight: 500; color: #18181B; font-variant-numeric: tabular-nums; }

.fraud-meta { border-top: 1px solid #E7E5E4; border-bottom: 1px solid #E7E5E4; }
.fraud-meta > summary {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 0; cursor: pointer; list-style: none;
    font-size: 14px; font-weight: 600; color: #18181B;
}
.fraud-meta > summary::-webkit-details-marker { display: none; }
.fraud-meta > summary::after { content: '⌄'; color: #737373; font-size: 16px; }
.fraud-meta[open] > summary::after { content: '⌃'; }
.fraud-meta-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 24px; padding-bottom: 12px; }
.fraud-meta-cell { padding: 10px 0; border-top: 1px solid #F0EFEE; }
.fraud-meta-k { font-size: 10px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: #A8A29E; }
.fraud-meta-v { margin-top: 3px; font-size: 13px; color: #18181B; overflow-wrap: anywhere; }

/* ---- Extract: balance summary, one transaction table, foot rows -------- */
.extract-page { display: flex; flex-direction: column; gap: 32px; font-family: var(--font-body); }

.extract-balance { display: flex; flex-direction: column; gap: 14px; }
.extract-balance-strip { display: flex; gap: 16px; }
.extract-balance-cell { display: flex; flex-direction: column; gap: 6px; flex: 1 1 0; min-width: 0; }
.extract-balance-label { font-size: 12px; line-height: 16px; color: #737373; }
.extract-balance-value {
    font-size: 22px; font-weight: 600; letter-spacing: -0.01em; line-height: 28px;
    color: #18181B; font-variant-numeric: tabular-nums;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.extract-balance-value.is-credit { color: #15803D; }
.extract-reconcile {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-radius: 8px;
    font-size: 13px; line-height: 18px;
}
.extract-reconcile.is-review { background: #FBF7EE; color: #78350F; }
.extract-reconcile.is-pass { background: #EEF5F0; color: #2F6B49; }
.extract-reconcile-dot { flex-shrink: 0; width: 6px; height: 6px; border-radius: 3px; background: #418D62; }
.extract-reconcile.is-review .extract-reconcile-dot { background: #D97706; }
.extract-reconcile-text { flex: 1; min-width: 0; }
.extract-reconcile-jump {
    flex-shrink: 0; padding: 0; border: 0; background: none;
    font: inherit; font-weight: 500; color: #92400E; cursor: pointer;
}
.extract-reconcile-jump:hover { text-decoration: underline; text-underline-offset: 3px; }

.ledger { display: flex; flex-direction: column; gap: 12px; }
.ledger-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ledger-heading { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ledger-title { font-size: 15px; font-weight: 600; line-height: 20px; color: #18181B; }
.ledger-count { margin-left: 4px; font-size: 13px; font-weight: 400; color: #737373; }
.ledger-sub { font-size: 12px; line-height: 16px; color: #737373; }
.ledger-chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ledger-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px; border: 1px solid #E7E5E4; border-radius: 999px; background: #FFFFFF;
    font: inherit; font-size: 12px; font-weight: 500; line-height: 16px; color: #3F3F46;
    cursor: pointer;
}
.ledger-chip:hover { border-color: #D6D3D1; }
.ledger-chip.is-on { background: #18181B; border-color: #18181B; color: #FFFFFF; }
.ledger-chip-dot { width: 6px; height: 6px; border-radius: 3px; }
.ledger-chip.is-review .ledger-chip-dot { background: #D97706; }
.ledger-chip.is-corrected .ledger-chip-dot { background: #3B82F6; }
.ledger-chip.is-edited .ledger-chip-dot { background: #A8A29E; }

.ledger-table-wrap { border: 1px solid #E7E5E4; border-radius: 10px; overflow-x: auto; }
.ledger-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; line-height: 18px; }
.ledger-table th {
    padding: 10px 14px;
    background: #FAFAFA; border-bottom: 1px solid #F0EFEE;
    font-size: 11px; font-weight: 500; letter-spacing: 0.06em; line-height: 14px;
    text-transform: uppercase; color: #737373; text-align: left; white-space: nowrap;
}
.ledger-table td { padding: 10px 14px; border-bottom: 1px solid #F0EFEE; vertical-align: top; color: #18181B; }
.ledger-table tbody tr:last-child td { border-bottom: 0; }
.ledger-table .ledger-num { width: 1%; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ledger-table .ledger-date { width: 1%; white-space: nowrap; }
.ledger-table td.ledger-date { color: #57534E; font-variant-numeric: tabular-nums; box-shadow: inset 3px 0 0 transparent; }
.ledger-table .ledger-act { width: 20px; padding-left: 0; text-align: center; }
.ledger-desc { min-width: 220px; }
.ledger-desc-sub {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px;
    margin-top: 2px; font-size: 12px; line-height: 16px; color: #737373;
}
.ledger-row.is-review td { background: #FBF7EE; }
.ledger-row.is-review td.ledger-date { box-shadow: inset 3px 0 0 #D97706; }
.ledger-row.is-corrected td.ledger-date { box-shadow: inset 3px 0 0 #3B82F6; }
.ledger-row.is-edited td.ledger-date { box-shadow: inset 3px 0 0 #A8A29E; }
.ledger-row.is-summary td { background: #FAFAFA; color: #737373; font-style: italic; }
.ledger-row.is-flash td { animation: ledgerFlash 1.6s ease-out; }
@keyframes ledgerFlash { from { background: #FDE9C4; } }
.ledger-note.is-review { color: #92400E; }
.ledger-note.is-fixed { color: #1E4E8C; }
.ledger-actions { display: flex; align-items: center; gap: 8px; flex-basis: 100%; margin-top: 6px; }
.ledger-btn {
    padding: 4px 10px; border: 1px solid #E7D9BC; border-radius: 6px; background: #FFFFFF;
    font: inherit; font-size: 12px; font-weight: 500; line-height: 16px; color: #3F3F46; cursor: pointer;
}
.ledger-btn.is-primary { background: #18181B; border-color: #18181B; color: #FFFFFF; }
.ledger-link {
    padding: 0; border: 0; background: none;
    font: inherit; font-size: 12px; font-weight: 500; line-height: 16px; color: #57534E; cursor: pointer;
}
.ledger-link.is-review { padding-left: 4px; color: #92400E; }
.ledger-link.is-fixed { color: #1E4E8C; text-decoration: underline 1px; text-underline-offset: 2px; }
.ledger-icon-btn {
    display: inline-flex; padding: 2px; border: 0; border-radius: 4px;
    background: none; color: #57534E; cursor: pointer;
}
.ledger-icon-btn:hover { background: #F5F5F4; color: #18181B; }
.ledger-edit { border-radius: 4px; cursor: text; }
.ledger-edit:hover { background: #F5F5F4; box-shadow: 0 0 0 3px #F5F5F4; }
.ledger-edit.is-empty { color: #C4C0BC; }
.ledger-edit.is-credit { color: #15803D; }
.ledger-edit.is-fixed { color: #1E4E8C; font-weight: 500; }
.ledger-edit.is-review { color: #B45309; font-weight: 600; }
.ledger-input {
    box-sizing: border-box; width: 100%; min-width: 88px; height: 28px; padding: 0 8px;
    border: 1.5px solid #418D62; border-radius: 6px; background: #FFFFFF;
    box-shadow: 0 0 0 3px #E8F5EC; outline: none;
    font: inherit; font-size: 13px; color: #18181B;
}
.ledger-input.is-num { text-align: right; font-variant-numeric: tabular-nums; }
.ledger-foot { display: flex; justify-content: flex-end; }

/* Collapsed low-prominence rows at the foot of Extract. */
.extract-foot { border-top: 1px solid #F0EFEE; }
.extract-foot-row { border-bottom: 1px solid #F0EFEE; }
.extract-foot > .extract-foot-row:last-child { border-bottom: 0; }
.processing-timeline > .extract-foot-row { margin-top: 24px; border-top: 1px solid #F0EFEE; border-bottom: 0; }
.extract-foot-row > summary,
.extract-foot-plain { display: flex; align-items: center; gap: 10px; padding: 14px 0; list-style: none; cursor: pointer; }
.extract-foot-plain { cursor: default; }
.extract-foot-row > summary::-webkit-details-marker { display: none; }
.extract-foot-chevron { display: inline-flex; align-items: center; justify-content: center; width: 12px; height: 12px; flex-shrink: 0; }
.extract-foot-chevron::before {
    content: ''; width: 5px; height: 5px;
    border-right: 1.6px solid #A8A29E; border-bottom: 1.6px solid #A8A29E;
    transform: rotate(-45deg); transition: transform 0.15s;
}
details[open] > summary .extract-foot-chevron::before { transform: rotate(45deg); }
.extract-foot-title { font-size: 13px; line-height: 18px; color: #57534E; white-space: nowrap; }
.extract-foot-note { min-width: 0; font-size: 12px; line-height: 16px; color: #A8A29E; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.extract-foot-spacer { flex: 1; }
.extract-foot-link { padding: 0; border: 0; background: none; font: inherit; font-size: 12px; line-height: 16px; color: #737373; cursor: pointer; }
.extract-foot-link:hover { color: #18181B; text-decoration: underline; text-underline-offset: 3px; }
.extract-foot-body,
.extract-pipeline-body { padding-bottom: 16px; }
.extract-transcription {
    margin: 12px 0 20px;
    border: 1px solid #E7E5E4; border-radius: 8px;
    background: #FAFAF9;
}
.extract-page .extract-transcription { margin: -12px 0 0; }
.extract-transcription[hidden] { display: none; }
.extract-transcription-body {
    max-height: 480px; overflow: auto;
    padding: 12px 16px;
    font-size: 12.5px; line-height: 20px; color: #3F3F46;
}

/* ---- Right-hand panel: Pages ------------------------------------------- */
/* The page panel (#pdf-panel, injected by app.js) docks on the right.
   `body #pdf-panel` outranks the injected rule but still loses to the
   inline width the resize handle sets. */
@keyframes pdfPanelOpenRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes pdfPanelCloseRight { from { transform: translateX(0); } to { transform: translateX(100%); } }

body #pdf-panel {
    left: auto;
    right: 0;
    width: 380px;
    box-shadow: -18px 0 44px rgba(9, 9, 11, 0.06);
    border-left: 1px solid #E7E5E4;
    transform-origin: right center;
}
body #pdf-panel.pdf-panel-opening { animation-name: pdfPanelOpenRight; }
body #pdf-panel.pdf-panel-closing { animation-name: pdfPanelCloseRight; }
body #pdf-resize-handle { right: auto; left: -6px; }

/* The panel reserves its slot, so the page keeps one box beside it. */
@media (min-width: 1024px) {
    body.pdf-panel-open .main-content {
        margin-left: 0 !important;
        margin-right: var(--side-panel-width, 380px) !important;
        width: auto !important;
        max-width: none !important;
        flex: 1 1 auto !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    /* The history rail stays flush left beside the open page panel. */
    body.pdf-panel-open .main-content:has(#results-section.active) .results-section.active {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
}

#pdf-fab { left: auto; right: 0; transition: right 0.2s ease-in; }
body.pdf-panel-open #pdf-fab { left: auto; right: var(--pdf-panel-width, 380px); }
.pdf-fab-button {
    border-left: 1px solid var(--border-color, #E4E4E7);
    border-right: 0;
    border-radius: 8px 0 0 8px;
}

/* Opened-document page uses Geist throughout (older Analysis blocks set
   their eyebrow labels and numbers in Geist Mono). */
#results-section .detail-content :not(pre):not(code):not(kbd):not(samp) {
    font-family: var(--font-body) !important;
}

/* ---- Documents (History): flat table ---------------------------------- */
/* Scope (mine / organization) and sort order moved into the Filters panel. */
#history-section #sort-dropdown,
#history-section #history-scope-dropdown { display: none !important; }

#history-section #activity-feed {
    border: 1px solid #E7E5E4;
    border-radius: 12px;
    background: #FFFFFF;
    overflow: hidden;
}
#activity-feed .history-doc-head,
#activity-feed .history-doc-row {
    display: grid;
    grid-template-columns: 28px minmax(0, 2.4fr) minmax(0, 1.3fr) 120px 150px 32px;
    align-items: center;
    column-gap: 16px;
    padding: 0 16px;
}
#activity-feed .history-doc-head {
    height: 38px;
    background: #FAFAFA;
    border-bottom: 1px solid #F0EFEE;
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #737373;
}
#activity-feed .history-doc-row {
    min-height: 52px;
    margin: 0;
    border: 0;
    border-bottom: 1px solid #F0EFEE;
    border-radius: 0;
    background: #FFFFFF;
    font-family: var(--font-body);
    font-size: 13px;
    color: #3F3F46;
    cursor: pointer;
}
#activity-feed .history-doc-row:last-child { border-bottom: 0; }
#activity-feed .history-doc-row:hover { background: #FAFAF9; }
#activity-feed .history-doc-row.selected { background: #F3F8F4; }
.history-doc-name {
    font-size: 14px;
    font-weight: 500;
    color: #18181B;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.history-doc-cell { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-doc-status { display: inline-flex; align-items: center; gap: 6px; }
.history-doc-dot { width: 7px; height: 7px; border-radius: 999px; flex-shrink: 0; }
.history-doc-status.is-done .history-doc-dot { background: #418D62; }
.history-doc-status.is-processing .history-doc-dot { background: #3B82F6; }
.history-doc-status.is-failed .history-doc-dot { background: #DC2626; }
.history-doc-date { text-align: right; color: #737373; white-space: nowrap; }
#activity-feed .history-doc-row .row-actions { opacity: 0; justify-content: flex-end; }
#activity-feed .history-doc-row:hover .row-actions { opacity: 1; }
#activity-feed .history-doc-row .activity-checkbox { opacity: 0.35; }
#activity-feed .history-doc-row:hover .activity-checkbox,
#activity-feed .history-doc-row.selected .activity-checkbox { opacity: 1; }

/* ---- Opening a document: skeleton, then a soft fade-in ---------------- */
.doc-page-skeleton { display: flex; flex-direction: column; gap: 14px; }
.doc-skel {
    border-radius: 8px;
    background: linear-gradient(90deg, #F2F1F0 25%, #E9E8E6 50%, #F2F1F0 75%);
    background-size: 200% 100%;
    animation: docSkelShimmer 1.2s ease-in-out infinite;
}
.doc-skel-title { width: 180px; height: 22px; }
.doc-skel-row { display: flex; gap: 10px; }
.doc-skel-card { flex: 1; height: 64px; }
.doc-skel-strip { height: 58px; }
.doc-skel-line { height: 38px; }
@keyframes docSkelShimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

#results-section #detail-content > :not(.doc-page-skeleton) { animation: docContentIn 0.18s ease-out; }
@keyframes docContentIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
    .doc-skel, #results-section #detail-content > * { animation: none; }
}
.history-load-more { padding: 14px 16px; text-align: center; font-family: var(--font-body); font-size: 12px; color: #A8A29E; }

/* ---- Analysis: label / value line lists (payslip lines) */
.analysis-lines { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); column-gap: 32px; }
.analysis-line {
    display: flex; justify-content: space-between; gap: 16px;
    padding: 9px 0;
    border-bottom: 1px solid #F0EFED;
    font-size: 13px;
}
.analysis-line-label { color: #52525B; min-width: 0; overflow-wrap: anywhere; }
.analysis-line-value { color: #18181B; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }

body #pdf-panel-header {
    box-sizing: border-box;
    min-height: 59px;
    padding: 14px 18px;
    background: #FFFFFF;
    border-bottom: 1px solid #F4F4F5;
}
#pdf-panel-header-actions { display: flex; align-items: center; gap: 6px; }
#pdf-panel .pdf-bbox-eye-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; padding: 0;
    border: 0; border-radius: 7px;
    background: transparent; color: #3F3F46; box-shadow: none;
    cursor: pointer;
}
#pdf-panel .pdf-bbox-eye-btn { color: #71717A; }
#pdf-panel .pdf-bbox-eye-btn:hover { background: #F4F4F5; color: #18181B; }
#pdf-panel .pdf-bbox-eye-btn[aria-pressed="true"] { background: #E8F5EC; color: #2F6B49; border: 0; }

/* ---- Extract: canonical fields (vision-extracted types) ---------------- */
.extract-fields { display: flex; flex-direction: column; gap: 28px; margin-bottom: 28px; }
.extract-fields-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-bottom: 8px; border-bottom: 1px solid #E7E5E4; }
.extract-fields-title { font-size: 14px; font-weight: 600; color: #18181B; }
.extract-fields-count { font-size: 12px; color: #A8A29E; }
.extract-fields .analysis-line-value { white-space: normal; text-align: right; overflow-wrap: anywhere; }
.extract-fields-table-wrap { overflow-x: auto; }
.extract-fields-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.extract-fields-table th { padding: 10px 12px 8px 0; text-align: left; font-size: 11px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; color: #A8A29E; border-bottom: 1px solid #F0EFED; }
.extract-fields-table td { padding: 9px 12px 9px 0; border-bottom: 1px solid #F0EFED; color: #18181B; font-variant-numeric: tabular-nums; vertical-align: top; }
.extract-fields-table tr:last-child td { border-bottom: 0; }

/* Signed out: panels mounted on <body> never show over the login screen, even
   when a document open that was already in flight mounts one afterwards. */
body.kita-signed-out #pdf-panel,
body.kita-signed-out #pdf-page-modal,
body.kita-signed-out #ai-agent-widget { display: none !important; }

/* ---- Loan activity with nothing detected: one collapsed line ---- */
.loan-activity-collapsed { border: 1px solid var(--border-color); border-radius: 10px; margin: 16px 0; background: var(--bg-primary, #fff); }
.loan-activity-collapsed > summary { display: flex; align-items: baseline; gap: 10px; padding: 14px 16px; cursor: pointer; list-style: none; }
.loan-activity-collapsed > summary::-webkit-details-marker { display: none; }
.loan-activity-collapsed > summary::after { content: '▸'; margin-left: auto; color: var(--text-muted); transition: transform .15s; }
.loan-activity-collapsed[open] > summary::after { transform: rotate(90deg); }
.loan-activity-collapsed-title { font-weight: 600; font-size: 15px; color: var(--text-primary); }
.loan-activity-collapsed-note { font-size: 13px; color: var(--text-muted); }
.loan-activity-collapsed > .loan-activity-block { margin: 0; padding: 0 16px 16px; border: 0; }
.loan-activity-collapsed > .loan-activity-block > .sig-v3-head { display: none; }
