/* ==========================================================================
   Opened-document page (Results section)
   Header with back link + application pill, Extracted data / Checks /
   Insights tabs, persistent source panel, Recent documents rail on the left.
   Loaded after styles.css.
   ========================================================================== */

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

/* ---- Left column: back link, open documents, page viewer ---------------- */
:root { --open-docs-w: 320px; --open-docs-h: calc((100vh - 56px) / 3); }
#results-section .documents-sidebar {
    display: flex; flex-direction: column;
    width: var(--open-docs-w);
    padding: 0;
    border-right: 1px solid #ECEBE9;
    background: #FFFFFF;
    font-family: var(--font-body);
}
.open-docs-back {
    display: flex; align-items: center; gap: 6px; flex-shrink: 0;
    padding: 18px 20px 18px 26px;
    border: 0; border-bottom: 1px solid #ECEBE9; background: none;
    font: 500 13px/18px var(--font-body); color: #418D62; text-align: left; cursor: pointer;
}
.open-docs-back:hover { color: #2F6B49; }
.open-docs-list { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 12px 16px 16px; }
.open-doc { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 10px; border-radius: 8px; }
.open-doc:hover { background: #FAFAF9; }
.open-doc.is-active { background: #EEF5F0; }
.open-doc-open { display: flex; align-items: center; gap: 8px; flex: 1 1 0; min-width: 0; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; }
.open-doc-name { font-size: 13px; line-height: 18px; color: #18181B; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.open-doc.is-active .open-doc-name { font-weight: 500; }
.open-doc-dot { width: 8px; height: 8px; border-radius: 999px; flex-shrink: 0; background: #36865C; }
.open-doc-dot.is-processing { background: #D97706; animation: open-doc-pulse 1.4s ease-in-out infinite; }
.open-doc-dot.is-failed { background: #DC2626; }
.open-doc-dot.is-pending { background: #D6D3D1; }
@keyframes open-doc-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .open-doc-dot.is-processing { animation: none; } }
.open-doc-close { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 6px; background: none; color: #57534E; opacity: 0.55; cursor: pointer; }
.open-doc.is-active .open-doc-close, .open-doc-close:hover, .open-doc-close:focus-visible { opacity: 1; }
.open-doc-close:hover { background: #ECEBE9; }
[data-theme="dark"] #results-section .documents-sidebar { background: #1A1F26; border-color: #30363D; }
[data-theme="dark"] .open-docs-back { border-color: #30363D; color: #7FCF9D; }
[data-theme="dark"] .open-doc.is-active { background: #16281D; }
[data-theme="dark"] .open-doc-name { color: #E7E9EA; }
[data-theme="dark"] .open-doc-close { color: #C4C9CE; }

@media (min-width: 1024px) {
    #results-section.results-section.active { padding-left: calc(var(--open-docs-w) + 24px) !important; }
    /* The column is fixed to the window's left edge: open documents in the
       top third, the page viewer (#pdf-panel) in the rest. */
    #results-section .documents-sidebar { position: fixed; top: 56px; bottom: 0; left: 0; z-index: 20; }
    .open-docs-list { flex: 0 0 auto; height: calc(var(--open-docs-h) - 55px); }
}

/* The page viewer: injected by app.js into the left column. Only the pages
   and the bounding-box eye, floating over them. */
#documents-sidebar #pdf-panel { border-top: 1px solid #ECEBE9; }
#pdf-panel-header { position: absolute; top: 16px; right: 20px; z-index: 2; }
#pdf-panel .pdf-bbox-eye-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; padding: 0;
    border: 1px solid #E7E5E4; border-radius: 8px;
    background: #FFFFFF; color: #18181B; box-shadow: 0 1px 3px rgba(24, 24, 27, 0.08);
    cursor: pointer;
}
#pdf-panel .pdf-bbox-eye-btn:hover { border-color: #C9C6C2; }
#pdf-panel .pdf-bbox-eye-btn[aria-pressed="true"] { border-color: #418D62; background: #E8F5EC; color: #2F6B49; box-shadow: none; }
#pdf-panel-body { flex: 1 1 auto; min-height: 0; overflow: hidden auto; padding: 16px; }
[data-theme="dark"] #documents-sidebar #pdf-panel { background: #161B22; border-color: #30363D; }
[data-theme="dark"] #pdf-panel .pdf-bbox-eye-btn { border-color: #30363D; background: #1A1F26; color: #E7E9EA; }

#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;
}

/* ---- Header ------------------------------------------------------------ */
.doc-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding: 20px 28px;
    background: #FFFFFF;
}

.doc-page-header-main {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    flex: 1 1 240px;
    min-width: 0;
}
/* The sheet always fills its column; a long filename truncates rather than
   widening the page, and Export wraps under it on narrow windows. */
#results-section .doc-sheet { width: 100%; }
#results-section .doc-page-header { flex-wrap: wrap; }

/* ---- 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-back:hover { color: #18181B; }

.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-eyebrow:empty { display: none; }

.doc-page-title { margin: 0; max-width: 100%; font-family: var(--font-body); font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 32px; color: #18181B; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.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 0; padding: 0; border-bottom: 0; }
#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; margin-top: 32px; overflow: visible; }

/* ---- Checks: headline, top finding, check rows ------------------------ */
.fraud-checklist { display: flex; flex-direction: column; gap: 22px; font-family: var(--font-body); }

.checks-head { display: flex; flex-direction: column; gap: 9px; }
.checks-headline { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -0.025em; line-height: 30px; color: #18181B; }
.checks-disclaimer { margin: 0; font-size: 14px; line-height: 21px; color: #626B65; }

.fraud-section { display: flex; flex-direction: column; gap: 12px; }
.fraud-section-head { display: flex; flex-direction: column; gap: 5px; }
.fraud-section-title { margin: 0; font-size: 16px; font-weight: 600; line-height: 20px; color: #18181B; }
.fraud-section-subtitle { margin: 0; font-size: 13px; line-height: 16px; color: #626B65; }
.fraud-check-list { display: flex; flex-direction: column; border-top: 1px solid #E2E7E4; }

.fraud-check-row { border-bottom: 1px solid #E2E7E4; }
.fraud-check-row > summary,
div.fraud-check-row {
    display: grid;
    grid-template-columns: 170px 104px minmax(0, 1fr) 115px;
    align-items: center;
    gap: 18px;
    min-height: 70px;
    padding: 12px 0;
    list-style: none;
}
.fraud-check-row > summary { cursor: pointer; }
.fraud-check-row > summary::-webkit-details-marker { display: none; }
.fraud-check-label { font-size: 14px; font-weight: 500; line-height: 18px; color: #18181B; }
.fraud-check-status { padding: 0; border-radius: 0; background: none; font-size: 13px; font-weight: 400; line-height: 16px; letter-spacing: 0; text-transform: none; }
.fraud-check-status.is-pass { color: #39875A; }
.fraud-check-status.is-review { color: #8A5C13; }
.fraud-check-status.is-fail { color: #B91C1C; }
.fraud-check-status.is-not_run { color: #626B65; }
.fraud-check-detail { font-size: 13px; line-height: 19px; color: #444C47; min-width: 0; }
.fraud-check-action-cell { display: flex; justify-content: flex-end; text-align: right; }
.fraud-check-action {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-size: 13px;
    line-height: 16px;
    color: #39875A;
    cursor: pointer;
}
.fraud-check-action:hover { text-decoration: underline; text-underline-offset: 3px; }
.fraud-check-row[open] .fraud-check-action { text-decoration: underline; text-underline-offset: 3px; }
.fraud-check-findings { padding: 0 0 14px 188px; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px 20px; }

.checks-technical > summary {
    padding: 0;
    cursor: pointer;
    list-style: none;
    font-size: 13px;
    line-height: 20px;
    color: #626B65;
}
.checks-technical > summary::-webkit-details-marker { display: none; }
.checks-technical > summary::before { content: '› '; }
.checks-technical[open] > summary::before { content: '⌄ '; }
.checks-technical-body { display: flex; flex-direction: column; gap: 12px; padding-top: 12px; }
.checks-technical-note { margin: 0; font-size: 13px; line-height: 20px; color: #444C47; }
.checks-technical-note strong { font-weight: 600; color: #18181B; }

@media (max-width: 760px) {
    .fraud-check-row > summary,
    div.fraud-check-row { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; min-height: 0; }
    .fraud-check-detail { grid-column: 1 / -1; }
    .fraud-check-action-cell { grid-column: 1 / -1; justify-content: flex-start; }
    .fraud-check-findings { padding-left: 0; }
}

.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; overflow: hidden; text-overflow: ellipsis; }
.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-title { font-size: 13px; font-weight: 600; color: #18181B; }
.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-cell {
    display: flex; flex-direction: column; gap: 2px;
    flex: 1 1 0; min-width: 0;
    padding: 12px 16px;
    border-right: 1px solid #F0EFEE;
}
.extract-balance-cell:last-child { border-right: 0; }
.extract-balance-label { font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: #737373; }
.extract-balance-value { font-size: 15px; font-weight: 600; color: #18181B; font-variant-numeric: tabular-nums; }
.extract-balance-value.is-credit { color: #15803D; }
.extract-balances { display: flex; flex-direction: column; gap: 14px; }

/* ---- Review banner (_renderReviewBanner): one summary, one action ------ */
.review-banner { display: flex; align-items: center; gap: 20px; padding: 18px; border-radius: 8px; font-family: var(--font-body); }
.review-banner.is-review { background: var(--rv-review-bg); }
.review-banner.is-ok { background: var(--rv-ok-bg); }
.review-banner.is-neutral { background: var(--rv-head); }
.review-banner-text { display: flex; flex-direction: column; gap: 6px; flex: 1 1 0; min-width: 0; }
.review-banner-title { font-size: 15px; font-weight: 600; line-height: 18px; }
.is-review .review-banner-title { color: var(--rv-review-ink); }
.is-ok .review-banner-title { color: var(--rv-ok-ink); }
.is-neutral .review-banner-title { color: var(--rv-ink); }
.review-banner-detail { font-size: 14px; line-height: 21px; color: var(--rv-ink); }
.is-ok .review-banner-detail, .is-neutral .review-banner-detail { color: var(--rv-body); }
.review-banner-action {
    flex-shrink: 0;
    padding: 10px 12px;
    border: 1px solid #DDD5C2;
    border-radius: 6px;
    background: var(--rv-surface);
    font-family: inherit;
    font-size: 14px;
    line-height: 18px;
    color: var(--rv-ink);
    cursor: pointer;
}
.review-banner-action:hover { border-color: #C9BDA2; }
.is-ok .review-banner-action { border-color: #CFE0D5; }
.review-banner.is-compact { gap: 10px; padding: 10px 14px; }
.review-banner.is-review.is-compact { background: #FBF7EE; }
.review-banner-dot { width: 6px; height: 6px; border-radius: 3px; flex-shrink: 0; }
.is-review .review-banner-dot { background: #D97706; }
.is-ok .review-banner-dot { background: #418D62; }
.is-compact .review-banner-detail { flex: 1 1 auto; min-width: 0; font-size: 13px; line-height: 18px; }
.is-review.is-compact .review-banner-detail { color: #78350F; }
.is-ok.is-compact .review-banner-detail { color: #286845; }
.is-compact .review-banner-action { padding: 0; border: 0; background: none; font-size: 13px; font-weight: 500; color: #92400E; }
.is-ok.is-compact .review-banner-action { color: #286845; }
.is-compact .review-banner-action:hover { text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 640px) {
    .review-banner:not(.is-compact) { flex-direction: column; align-items: flex-start; gap: 12px; }
}

/* A row opened from Checks or a review banner. */
#results-section .is-source-target,
#results-section .is-source-target > td { background: #FBF1DC !important; transition: background 0.3s; }

.ledger { display: flex; flex-direction: column; gap: 12px; }
.ledger-head { display: flex; align-items: center; 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: 18px; font-weight: 600; letter-spacing: -0.01em; line-height: 24px; color: #18181B; }
.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-page {
    padding: 0; border: 0; background: none; white-space: nowrap;
    font: inherit; font-size: 11px; line-height: 16px; color: #A8A29E; cursor: pointer;
}
.ledger-page:hover { color: #18181B; text-decoration: underline 1px; text-underline-offset: 2px; }
.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. */
/* Extracted data sections (raw transcription, extracted fields,
   transactions) share one header: 18px title, muted count, tools right. */
/* Each section starts at a hairline rule, like the design's section breaks. */
.extract-section { display: flex; flex-direction: column; gap: 16px; padding-top: 24px; border-top: 1px solid #ECEBE9; }
[data-theme="dark"] .extract-section { border-top-color: #30363D; }
.extract-section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 26px; }
.extract-section-heading { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.extract-section-title { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; line-height: 24px; color: #18181B; }
.extract-section-count { font-size: 14px; font-weight: 400; line-height: 20px; color: #737373; }
.extract-section-actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.extract-section-link { padding: 0; border: 0; background: none; font: inherit; font-size: 13px; font-weight: 500; line-height: 18px; color: #418D62; cursor: pointer; }
.extract-section-link:hover { text-decoration: underline; text-underline-offset: 3px; }
details.extract-section > summary { list-style: none; cursor: pointer; }
details.extract-section > summary::-webkit-details-marker { display: none; }
.extract-section-expand { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; box-sizing: border-box; border: 1px solid #E7E5E4; border-radius: 999px; }
.extract-section-expand::before {
    content: ''; width: 5px; height: 5px; margin-top: -3px;
    border-right: 1.6px solid #57534E; border-bottom: 1.6px solid #57534E;
    transform: rotate(45deg); transition: transform 0.15s;
}
details[open] > summary .extract-section-expand::before { margin-top: 3px; transform: rotate(-135deg); }
.processing-timeline > .extract-section { margin-bottom: 24px; }
.extract-transcription-body {
    max-height: 480px; overflow: auto;
    padding: 12px 16px;
    border: 1px solid #E7E5E4; border-radius: 8px; background: #FAFAF9;
    font-size: 12.5px; line-height: 20px; color: #3F3F46;
}

/* ---- Right-hand panel: source document -------------------------------- */
/* 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 {
    width: 100%;
    border: 1px solid #E7E5E4;
    border-radius: 14px;
    background: #FFFFFF;
    overflow: hidden;
}
#activity-feed .history-doc-head,
#activity-feed .history-doc-row {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 180px 140px 110px;
    align-items: center;
    column-gap: 16px;
    padding: 0 20px;
}
#activity-feed .history-doc-head {
    padding-block: 10px;
    border-bottom: 1px solid #F0EFEE;
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 500;
    line-height: 16px;
    color: #737373;
}
#activity-feed .history-doc-row {
    height: 56px;
    margin: 0;
    border: 0;
    border-bottom: 1px solid #F0EFEE;
    border-radius: 0;
    background: #FFFFFF;
    font-family: var(--font-body);
    font-size: 13px;
    line-height: 18px;
    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-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.history-doc-name {
    min-width: 0;
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
    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-muted { color: #A8A29E; }
.history-doc-app {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 220px;
    height: 26px;
    padding: 0 8px;
    border: 1px solid #E7E5E4;
    border-radius: 999px;
    background: #FFFFFF;
    font-family: inherit;
    font-size: 12px;
    color: #3F3F46;
    white-space: nowrap;
    cursor: pointer;
}
.history-doc-app span { overflow: hidden; text-overflow: ellipsis; }
.history-doc-app:hover { border-color: #418D62; color: #2F6B49; }
.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-status.is-review .history-doc-dot { background: #D97706; }
.history-doc-date { text-align: right; color: #737373; white-space: nowrap; }
/* Row actions (application, delete) and the selection checkbox take no
   column: they appear on hover / keyboard focus, and the checkbox sits in
   the row's left gutter. */
#activity-feed .history-doc-row .row-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; opacity: 0; }
#activity-feed .history-doc-row:hover .row-actions,
#activity-feed .history-doc-row:focus-within .row-actions { opacity: 1; }
#activity-feed .history-doc-row .activity-checkbox {
    position: absolute;
    left: 0;
    top: 0;
    width: 20px;
    height: 100%;
    margin: 0;
    border-radius: 0;
    background: none;
    opacity: 0;
}
#activity-feed .history-doc-row .activity-checkbox .checkbox-custom { width: 14px; height: 14px; border-width: 1.5px; border-radius: 3px; }
#activity-feed .history-doc-row .activity-checkbox input:checked + .checkbox-custom::after { left: 3.5px; top: 0.5px; width: 4px; height: 8px; }
#activity-feed .history-doc-row:hover .activity-checkbox,
#activity-feed .history-doc-row:focus-within .activity-checkbox,
#activity-feed .history-doc-row.selected .activity-checkbox { opacity: 1; }

/* Heading: design shows search only; Filters is icon-sized next to it and the
   rest (upload, new application, export) sit behind "⋯". */
#history-section.active { max-width: 1328px; padding-top: 48px; }
#history-section .section-page-heading { align-items: center; }
#history-section .section-page-title { font-size: 28px; line-height: 34px; letter-spacing: -0.02em; }
#history-section .section-page-actions .search-sort-container { gap: 8px; }
#history-section .section-page-actions .search-wrapper { width: 280px; flex: none; }
#history-section .section-page-actions .search-icon { left: 12px; color: #737373; }
#history-section .section-page-actions .search-input {
    max-width: none;
    height: 38px;
    padding: 0 36px 0 35px;
    border-radius: 10px;
}
#history-section .section-page-actions .search-input::placeholder { color: #8A8A8A; }
#history-section .section-page-actions .clear-search-btn { width: 24px; height: 24px; }
#history-section .section-page-actions .filter-pill-btn,
.history-more-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 38px;
    min-width: 38px;
    padding: 0 11px;
    border: 1px solid #E7E5E4;
    border-radius: 10px;
    background: #FFFFFF;
    color: #57534E;
    cursor: pointer;
}
.history-more-btn:hover { border-color: #D6D3D1; color: #18181B; }
#summary-download-dropdown { position: relative; }
.history-more-menu {
    left: auto;
    right: 0;
    min-width: 200px;
    max-height: none;
    padding: 4px;
    border: 1px solid #E7E5E4;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(24, 24, 27, 0.08);
}
.history-more-menu .folder-dropdown-item {
    padding: 8px 10px;
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 13px;
}
.history-more-label {
    margin-top: 4px;
    padding: 8px 10px 4px;
    border-top: 1px solid #F0EFEE;
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #A8A29E;
}
@media (max-width: 900px) {
    #history-section .section-page-heading { flex-wrap: wrap; }
    #history-section .section-page-actions { width: 100%; }
    #history-section .section-page-actions .search-sort-container { flex: 1; flex-direction: row; }
    #history-section .section-page-actions .search-wrapper { width: auto; flex: 1; }
    #activity-feed .history-doc-head,
    #activity-feed .history-doc-row { grid-template-columns: minmax(0, 1fr) 96px 72px; }
    #activity-feed .history-doc-head > :nth-child(2),
    #activity-feed .history-doc-row > :nth-child(3) { display: none; }
}

/* ---- 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: var(--skel-gradient);
    background-size: 200% 100%;
    animation: skelShimmer 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; }

#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; }


/* ---- Extracted data: typed result views (Paper "Results v2/v3") -------- */
.extract-page, .result-view, .tx-v3, .review-banner {
    --rv-ink: #18181B; --rv-text: #202522; --rv-body: #444C47; --rv-muted: #626B65; --rv-faint: #737373;
    --rv-line: #E2E7E4; --rv-line-soft: #F0EFEE; --rv-head: #F7F8F8; --rv-surface: #FFFFFF;
    --rv-review-bg: #FCF7EB; --rv-review-ink: #8A5C13; --rv-review-bar: #D97706;
    --rv-ok-bg: #F1F7F3; --rv-ok-ink: #286845; --rv-in: #15803D;
    --rv-fixed-bar: #3B82F6; --rv-edited-bar: #A8A29E; --rv-link: #39875A;
}
[data-theme="dark"] .extract-page, [data-theme="dark"] .result-view, [data-theme="dark"] .tx-v3, [data-theme="dark"] .review-banner {
    --rv-ink: #e7e9ea; --rv-text: #e7e9ea; --rv-body: #c4c9ce; --rv-muted: #a1a7ad; --rv-faint: #8b929a;
    --rv-line: #30363d; --rv-line-soft: #21262d; --rv-head: #1f252c; --rv-surface: #1a1f26;
    --rv-review-bg: #2e2716; --rv-review-ink: #e7b66a; --rv-ok-bg: #16281d; --rv-ok-ink: #7fcf9d; --rv-in: #6fcf8f;
    --rv-link: #7fcf9d;
}
.result-view { display: flex; flex-direction: column; gap: 22px; font-family: var(--font-body); }
.result-section { display: flex; flex-direction: column; gap: 14px; }
.result-section-title { margin: 0; font-size: 16px; font-weight: 600; line-height: 20px; color: var(--rv-ink); }
.result-section-count { margin-left: 4px; font-size: 13px; font-weight: 400; color: var(--rv-faint); }
.result-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; margin: 0; }
.result-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.result-field-label { font-size: 13px; line-height: 16px; color: var(--rv-muted); }
.result-field-value { margin: 0; font-size: 15px; font-weight: 500; line-height: 21px; color: var(--rv-ink); overflow-wrap: anywhere; }
.extract-field-unreadable { color: #B45309; font-weight: 500; }
.extract-field-page {
    margin-left: 6px; padding: 0; border: 0; background: none;
    font: inherit; font-size: 11px; font-weight: 400; color: var(--rv-muted); cursor: pointer;
}
.extract-field-page:hover { color: var(--rv-ink); text-decoration: underline 1px; text-underline-offset: 2px; }
.result-figures { display: flex; gap: 28px; padding: 17px 0; border-top: 1px solid var(--rv-line); border-bottom: 1px solid var(--rv-line); }
.result-figure { display: flex; flex: 1 1 0; flex-direction: column; gap: 8px; min-width: 0; }
.result-figure-label { font-size: 13px; line-height: 16px; color: var(--rv-muted); }
.result-figure-value { font-size: 23px; font-weight: 600; line-height: 28px; letter-spacing: -0.03em; color: var(--rv-ink); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.result-figure-value.is-in { color: var(--rv-in); }
.result-figure-value .result-missing { font-size: 15px; letter-spacing: 0; }
.result-figures.is-insight { gap: 32px; padding: 12px 0 24px; border-top: 0; }
.result-figures.is-insight .result-figure-label { font-size: 14px; line-height: 18px; }
.result-figures.is-insight .result-figure-value { font-size: 28px; line-height: 42px; letter-spacing: 0; }
.result-figures.is-insight .result-figure:first-child .result-figure-value { font-size: 36px; letter-spacing: -0.03em; }
.result-table-wrap { overflow-x: auto; border: 1px solid var(--rv-line); border-radius: 7px; }
.result-table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 20px; }
.result-table th { padding: 10px 14px; background: var(--rv-head); border-bottom: 1px solid var(--rv-line); text-align: left; font-size: 12px; font-weight: 500; color: var(--rv-muted); white-space: nowrap; }
.result-table td { padding: 14px; border-bottom: 1px solid var(--rv-line); color: var(--rv-text); vertical-align: top; overflow-wrap: anywhere; }
.result-table tbody tr:last-child td { border-bottom: 0; }
.result-table .is-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.result-table tr.is-total td { font-weight: 600; }
.result-table tr.is-arrears td, .result-table tr.is-failed td, .result-table tr.is-review td { background: var(--rv-review-bg); }
.result-table tr[hidden] { display: none; }
/* Extracted fields: a citation chip per value that was located on the page. */
.field-cite { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border: 1px solid #D6E6DC; border-radius: 999px; background: #FFFFFF; color: #2F6B49; font: 500 12px/16px var(--font-body); white-space: nowrap; cursor: pointer; }
.field-cite:hover { border-color: #418D62; }
.field-cite:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.field-cite-none { color: #A8A29E; }
.result-table tr.is-cited td { background: #F3F8F5; }
.result-table tr.is-cited td:first-child { box-shadow: inset 3px 0 0 #418D62; }
.result-table tr.is-cited .field-cite { border-color: #418D62; background: #418D62; color: #FFFFFF; }
[data-theme="dark"] .field-cite { border-color: #2D4A38; background: #1A1F26; color: #7FCF9D; }
[data-theme="dark"] .result-table tr.is-cited td { background: #16281D; }
.result-table-more { display: block; width: 100%; padding: 10px 14px; border: 0; border-top: 1px solid var(--rv-line); background: var(--rv-head); color: var(--rv-muted); font: 500 12px/16px var(--font-body); text-align: right; cursor: pointer; }
.result-cell-sub { margin-top: 2px; font-size: 12px; line-height: 16px; color: var(--rv-muted); }
.result-note { margin: 0; font-size: 13px; line-height: 20px; color: var(--rv-muted); }
.result-link { padding: 0; border: 0; background: none; color: var(--rv-link); font: 13px/16px var(--font-body); cursor: pointer; align-self: flex-start; }
.result-link:hover { text-decoration: underline; }
.result-missing { font-weight: 400; color: var(--rv-faint); }
.result-missing[data-missing="not_found"], .result-missing[data-missing="unreadable"] { color: var(--rv-review-ink); }
.result-missing.is-flash { outline: 2px solid var(--rv-review-bar); outline-offset: 2px; border-radius: 3px; }
.result-lines { margin: 0; padding: 0; list-style: none; font-size: 14px; line-height: 23px; color: var(--rv-body); }
.result-disclosure { border-top: 1px solid var(--rv-line); }
.result-disclosure > summary { padding: 14px 0; font-size: 13px; color: var(--rv-muted); cursor: pointer; }
.result-disclosure[open] > summary { padding-bottom: 16px; }
.result-disclosure > .result-view, .result-disclosure > .result-section { margin-bottom: 16px; }
.result-insights-head { display: flex; flex-direction: column; gap: 9px; }
.result-insights-title { margin: 0; font-size: 24px; font-weight: 600; line-height: 30px; letter-spacing: -0.025em; color: var(--rv-ink); }
.result-insights-scope { margin: 0; font-size: 14px; line-height: 21px; color: var(--rv-muted); }
.result-insights-block { gap: 16px; padding-bottom: 22px; border-bottom: 1px solid var(--rv-line); }
.result-insights-block:last-child { border-bottom: 0; }

/* Bank transactions (Paper 4KY) */
.tx-v3 { display: flex; flex-direction: column; gap: 14px; font-family: var(--font-body); }
.tx-v3-dot { flex-shrink: 0; width: 6px; height: 6px; border-radius: 3px; background: var(--rv-in); }
.is-review > .tx-v3-dot, .tx-v3-dot.is-review { background: var(--rv-review-bar); }
.tx-v3-dot.is-corrected { background: var(--rv-fixed-bar); }
.tx-v3-dot.is-edited { background: var(--rv-edited-bar); }
.tx-v3-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.tx-v3-heading { display: flex; flex-direction: column; gap: 4px; }
.tx-v3-title { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; line-height: 24px; color: var(--rv-ink); }
.tx-v3-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tx-v3-search { width: 160px; padding: 5px 10px; border: 1px solid #E7E5E4; border-radius: 999px; background: var(--rv-surface); color: var(--rv-ink); font: 12px/16px var(--font-body); }
.tx-v3-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.tx-v3-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid #E7E5E4; border-radius: 999px; background: var(--rv-surface); color: #3F3F46; font: 500 12px/16px var(--font-body); cursor: pointer; }
.tx-v3-chip.is-active { border-color: var(--rv-ink); background: var(--rv-ink); color: var(--rv-surface); }
.tx-v3-chip-count { font-variant-numeric: tabular-nums; }
.tx-v3-editbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px; border-radius: 8px; background: var(--rv-head); font-size: 12px; color: var(--rv-muted); }
.tx-v3-editbar-text { flex: 1 1 240px; }
.tx-v3-btn { display: inline-flex; align-items: center; padding: 4px 10px; border: 1px solid #E7D9BC; border-radius: 6px; background: var(--rv-surface); color: #3F3F46; font: 500 12px/16px var(--font-body); cursor: pointer; }
.tx-v3-btn.is-primary { border-color: var(--rv-ink); background: var(--rv-ink); color: var(--rv-surface); }
.tx-v3-btn.is-quiet { border-color: transparent; background: none; color: var(--rv-muted); }
.tx-v3-link { padding: 0; border: 0; background: none; color: #92400E; font: 500 13px/18px var(--font-body); cursor: pointer; }
.tx-v3-link.is-review { font-size: 12px; line-height: 16px; }
.tx-v3-table-wrap { overflow-x: auto; border: 1px solid #E7E5E4; border-radius: 10px 10px 0 0; }
.tx-v3-table { width: 100%; border-collapse: collapse; font-size: 13px; line-height: 18px; }
.tx-v3-table th { padding: 9px 12px; background: #FAFAFA; border-bottom: 1px solid var(--rv-line-soft); text-align: left; font-size: 11px; font-weight: 500; line-height: 14px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--rv-faint); white-space: nowrap; }
.tx-v3-table td { padding: 10px 12px; border-bottom: 1px solid var(--rv-line-soft); color: var(--rv-ink); vertical-align: middle; }
.tx-v3-table th:first-child, .tx-v3-table td:first-child { padding-left: 14px; }
.tx-v3-table .is-num { width: 96px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx-v3-table .is-in { color: var(--rv-in); }
.tx-v3-row > td:first-child { box-shadow: inset 3px 0 0 transparent; }
.tx-v3-row.is-review > td:first-child { box-shadow: inset 3px 0 0 var(--rv-review-bar); }
/* Auto-fixed and edited rows look the same: one grey bar, one change tag. */
.tx-v3-row.is-corrected > td:first-child,
.tx-v3-row.is-edited > td:first-child { box-shadow: inset 3px 0 0 var(--rv-edited-bar); }
.tx-v3-row.is-review > td { background: #FBF7EE; vertical-align: top; }
.tx-v3-row.is-summary > td { color: var(--rv-muted); font-style: italic; }
.tx-v3-row[hidden] { display: none; }
.tx-v3-date { width: 64px; color: #57534E; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tx-v3-desc { min-width: 200px; }
.tx-v3-desc-text { display: block; color: var(--rv-ink); }
.tx-v3-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; margin-top: 2px; font-size: 12px; line-height: 16px; color: var(--rv-faint); }
.tx-v3-sep { color: var(--rv-faint); }
.tx-v3-change { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 1px 3px 1px 8px; border: 1px solid #E7E5E4; border-radius: 999px; background: #FAFAF9; color: #57534E; font-size: 12px; line-height: 16px; overflow-wrap: anywhere; }
.tx-v3-change:not(:has(.tx-v3-change-revert)) { padding-right: 8px; }
.tx-v3-change-revert { display: inline-flex; flex-shrink: 0; align-items: center; justify-content: center; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 999px; background: none; color: #57534E; cursor: pointer; }
.tx-v3-change-revert:hover { background: #ECEBE9; color: #18181B; }
.tx-v3-change-revert:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 1px; }
[data-theme="dark"] .tx-v3-change { border-color: #30363D; background: #1F252C; color: #C4C9CE; }
[data-theme="dark"] .tx-v3-change-revert { color: #C4C9CE; }
[data-theme="dark"] .tx-v3-change-revert:hover { background: #30363D; color: #E7E9EA; }
.tx-v3-note.is-review { color: #92400E; }
.is-review .tx-v3-balance { color: #B45309; font-weight: 600; }
.tx-v3-tag { padding: 0 6px; border-radius: 4px; background: var(--rv-head); color: var(--rv-body); }
.tx-v3-review-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.tx-v3-empty { color: #C4C0BC; }
.tx-v3-act { width: 28px; text-align: center; }
.tx-v3-icon { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 5px; background: none; color: #C4C0BC; font-size: 13px; cursor: pointer; }
.tx-v3-icon:hover, .tx-v3-icon:focus-visible { background: var(--rv-head); color: #57534E; }
.tx-v3-handle { width: 24px; color: var(--rv-faint); }
.tx-v3-handle .drag-handle { cursor: grab; }
.tx-editable-cell { cursor: text; border-radius: 4px; }
.tx-editable-cell:hover { background: var(--rv-head); }
.tx-editable-cell:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 1px; }
/* Inline edit: the cell's own text becomes editable in place — same font and
   wrapping, marked only by a tint and an underline, so nothing is covered. */
.tx-editable-cell.tx-cell-editing { outline: none; background: #F3F8F5; box-shadow: inset 0 -1.5px 0 #418D62; border-radius: 3px; white-space: pre-wrap; cursor: text; caret-color: #2F6B49; }
[data-theme="dark"] .tx-editable-cell.tx-cell-editing { background: #16281D; box-shadow: inset 0 -1.5px 0 #6FCF8F; }
.tx-v3-foot { display: flex; align-items: center; gap: 12px; margin-top: -14px; padding: 10px 17px; border: 1px solid #E7E5E4; border-top: 0; border-radius: 0 0 10px 10px; background: #FAFAFA; font-size: 12px; line-height: 16px; color: #57534E; }
.tx-v3-add { display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; background: none; color: #418D62; font: 500 12px/16px var(--font-body); cursor: pointer; }
.tx-v3-showing { margin-left: auto; font-weight: 500; }
.tx-v3-foot .tx-v3-link { color: #57534E; font-size: 12px; }
[data-theme="dark"] .tx-v3-table th, [data-theme="dark"] .tx-v3-foot { background: var(--rv-head); }
[data-theme="dark"] .tx-v3-row.is-review > td { background: var(--rv-review-bg); color: var(--rv-review-ink); }
@media (max-width: 640px) {
    .result-fields { grid-template-columns: minmax(0, 1fr); }
    .result-figures { flex-wrap: wrap; gap: 16px 24px; }
    .result-figure { flex: 1 1 40%; }
    .tx-v3-search { width: 100%; }
}

/* 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,
body.kita-signed-out #ai-agent-fab { display: none !important; }

.doc-page-actions .btn-ghost-sm { height: 32px; padding: 0 12px; border: 1px solid #E7E5E4; border-radius: 8px; font-size: 13px; font-weight: 500; color: #18181B; }
/* Document views as a numbered 1 → 2 → 3 timeline of clickable pills. The
   step number is a CSS counter (hidden tabs are skipped); one connector line
   runs behind the row and the pills' white backgrounds sit on top of it. */
#results-section .detail-tabs-container > .tabs.doc-tabs { flex: 1 1 auto; }
#results-section .tabs.doc-tabs {
    justify-content: space-between; align-items: center; gap: 16px !important; padding: 4px; counter-reset: doc-step;
    background: linear-gradient(#E7E5E4, #E7E5E4) center / calc(100% - 8px) 2px no-repeat;
}
#results-section .doc-tabs .tab {
    display: flex !important; align-items: center; gap: 10px; flex: 0 0 auto !important; margin: 0; padding: 6px 16px 6px 6px;
    border: 1px solid #E2E0DD; border-radius: 999px; background: #FFFFFF; box-shadow: 0 1px 2px rgba(24, 24, 27, 0.06), 0 2px 6px rgba(24, 24, 27, 0.04);
    counter-increment: doc-step; font-family: var(--font-body); font-size: 14px; font-weight: 500; line-height: 20px; color: #57534E; cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, color 0.15s;
}
#results-section .doc-tabs .tab:hover { color: #18181B; background: #FFFFFF; border-color: #C9C6C2; box-shadow: 0 2px 4px rgba(24, 24, 27, 0.08), 0 4px 10px rgba(24, 24, 27, 0.06); }
#results-section .doc-tabs .tab.active { font-weight: 600; color: #18181B; border-color: #418D62; background: #F3F8F5; box-shadow: 0 0 0 3px #E3F0E8; }
#results-section .doc-tabs .tab::before {
    content: counter(doc-step) !important; display: inline-flex !important; align-items: center; justify-content: center; flex-shrink: 0;
    position: static !important; transform: none !important; margin: 0 !important; width: 28px; height: 28px; box-sizing: border-box; border: 1.5px solid #D6D3D1; border-radius: 50%;
    background: #FFFFFF; font-size: 13px; font-weight: 600; line-height: 16px; color: #57534E;
}
#results-section .doc-tabs .tab.active::before { border-color: #418D62; background: #418D62; color: #FFFFFF; }
#results-section .doc-tabs .tab::after { display: none !important; }
#results-section .doc-tabs .tab:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
[data-theme="dark"] #results-section .tabs.doc-tabs { background-image: linear-gradient(#30363D, #30363D); }
[data-theme="dark"] #results-section .doc-tabs .tab { color: #A1A7AD; border-color: #30363D; background: #1A1F26; box-shadow: none; }
[data-theme="dark"] #results-section .doc-tabs .tab:hover { color: #E7E9EA; border-color: #484F58; }
[data-theme="dark"] #results-section .doc-tabs .tab.active { color: #E7E9EA; border-color: #418D62; background: #16281D; box-shadow: 0 0 0 3px rgba(65, 141, 98, 0.25); }
[data-theme="dark"] #results-section .doc-tabs .tab::before { border-color: #30363D; background: #1A1F26; color: #A1A7AD; }
[data-theme="dark"] #results-section .doc-tabs .tab.active::before { border-color: #418D62; background: #418D62; color: #FFFFFF; }

/* ---- 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; }

/* ---- Opened document on narrow windows (kept last so it wins) ------------ */
/* Below 1024px the left column scrolls with the page instead of being fixed:
   beside the document down to 900px (sticky, full height), then above it. The
   viewer stays in the column throughout. Every column may shrink. */
@media (max-width: 1023px) {
    #results-section .results-layout { align-items: stretch; }
    #results-section .document-detail-panel, #results-section .doc-sheet, #results-section .detail-tabs-container { min-width: 0; }
    #results-section .documents-sidebar { position: sticky; top: 56px; height: calc(100vh - 56px); align-self: flex-start; }
    .open-docs-list { flex: 0 0 auto; max-height: calc(var(--open-docs-h) - 55px); }
}
@media (max-width: 900px) {
    #results-section .documents-sidebar { position: static; width: 100%; height: auto; max-height: none; border-right: 0; border-bottom: 1px solid #ECEBE9; }
    .open-docs-list { max-height: 168px; }
    #documents-sidebar #pdf-panel { flex: none; height: min(60vh, 520px); }
}
@media (max-width: 640px) {
    #results-section .doc-tabs .tab { gap: 8px; padding: 4px 12px 4px 4px; font-size: 13px; }
    #results-section .doc-tabs .tab::before { width: 24px; height: 24px; font-size: 12px; }
    .extract-balance-strip { flex-wrap: wrap; row-gap: 16px; }
    .extract-balance-cell { flex: 1 1 40%; }
}

/* Documents: empty list */
#activity-feed .history-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 72px 24px; text-align: center; }
#activity-feed .history-empty-icon { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin-bottom: 8px; border-radius: 12px; background: #F3F8F4; color: #36865C; }
#activity-feed .history-empty-title { margin: 0; font: 600 16px/22px var(--font-body); color: #18181B; }
#activity-feed .history-empty-detail { margin: 0; max-width: 420px; font: 400 14px/20px var(--font-body); color: #637069; }
#activity-feed .history-empty-btn { margin-top: 14px; height: 36px; padding: 0 16px; border: 1px solid #E2E7E4; border-radius: 999px; background: #fff; font: 500 13px var(--font-body); color: #18181B; cursor: pointer; }
#activity-feed .history-empty-btn:hover { border-color: #C9D3CD; }
#activity-feed .history-empty-btn.is-primary { border-color: #286845; background: #286845; color: #fff; }
#activity-feed .history-empty-btn.is-primary:hover { background: #1F5537; }
