/* ──────────────────────────────────────────────────────────────────────────
   adhocreason.css
   Styles for the Reasoning Extraction page (adhocreason.html).
   Contains the subset of shared styles from adhococr.css that this page
   actually uses, plus the page-specific layout/result styles that previously
   lived inline in adhocreason.html.
   ────────────────────────────────────────────────────────────────────────── */

/* ── Shared base (copied from adhococr.css) ───────────────────────────────── */
:root {
    /* ── Pastel colour palette (24 colours) — matches adhococr.css ── */
    --kvp-color-0: #fca5a5; /* rose        */
    --kvp-color-1: #fdba74; /* orange      */
    --kvp-color-2: #fcd34d; /* amber       */
    --kvp-color-3: #fde047; /* yellow      */
    --kvp-color-4: #bef264; /* lime        */
    --kvp-color-5: #86efac; /* green       */
    --kvp-color-6: #6ee7b7; /* emerald     */
    --kvp-color-7: #5eead4; /* teal        */
    --kvp-color-8: #67e8f9; /* cyan        */
    --kvp-color-9: #7dd3fc; /* sky         */
    --kvp-color-10: #93c5fd; /* blue        */
    --kvp-color-11: #a5b4fc; /* indigo      */
    --kvp-color-12: #c4b5fd; /* violet      */
    --kvp-color-13: #d8b4fe; /* purple      */
    --kvp-color-14: #f0abfc; /* fuchsia     */
    --kvp-color-15: #f9a8d4; /* pink        */
    --kvp-color-16: #fecdd3; /* light rose  */
    --kvp-color-17: #fed7aa; /* light orange*/
    --kvp-color-18: #d9f99d; /* light lime  */
    --kvp-color-19: #99f6e4; /* mint        */
    --kvp-color-20: #bae6fd; /* light sky   */
    --kvp-color-21: #c7d2fe; /* light indigo*/
    --kvp-color-22: #f5d0fe; /* light fuchsia*/
    --kvp-color-23: #fbcfe8; /* light pink  */

    /* The tinted bar across the top of every dialog, as in the extension's side panel. */
    --dialog-header-bg: #f1f5f9;
    --dialog-header-border: #e2e8f0;
}

body {
    background: #f4f6f8;
    color: #1f2937;
}

.analyzer-page {
    min-height: 100dvh;
    height: 100dvh;
    overflow: hidden;
    box-sizing: border-box;
}

.analyzer-logo {
    height: 45px;
    width: auto;
}

/* The version number after the tool's name in the header. */
.analyzer-version {
    font-size: 0.8rem;
}

/* Shown by showUploadError (adhocreason.js), which sets display inline. */
#uploadError {
    display: none;
}

.ui-panel {
    background: #fff;
    border: 1px solid #e8eef5;
    border-radius: 0.9rem;
    padding: 1rem;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
}

/* ── Collapsible panels ──────────────────────────────────────────────── */
.section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    margin-bottom: 0.5rem;
    border-radius: 0.4rem;
}

    .section-header:focus-visible {
        outline: none;
        box-shadow: var(--focus-ring);
    }

    /* Grows so its chevron sits on the right, before the Results actions. */
    .section-header.section-header-inline {
        margin-bottom: 0;
        flex: 1 1 auto;
    }

/* Same rule as Invoice Capture (.section-toggle-icon in extractfile.css): on the right,
   pointing up while the section is open and down while it is collapsed. */
.section-chevron {
    margin-left: auto;
    font-size: 0.85rem;
    color: #64748b;
    transform: rotate(180deg);
    transition: transform 0.2s ease;
}

.section-header[aria-expanded="false"] .section-chevron {
    transform: rotate(0deg);
}

@media (prefers-reduced-motion: reduce) {
    .section-chevron {
        transition: none;
    }
}


/* ── Upload dropzone (copied from adhococr.css) ───────────────────────────── */
.upload-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 150px;
    padding: 1.25rem;
    border: 2px dashed #ffa500;
    border-radius: 1rem;
    background: linear-gradient(180deg, #fffcf5 0%, #ffeddb 100%);
    text-align: center;
    color: #0d6efd;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

    .upload-dropzone:hover,
    .upload-dropzone:focus-visible,
    .upload-dropzone.is-dragover {
        border-color: #0d6efd;
        background: #e9f3ff;
        transform: translateY(-1px);
        box-shadow: var(--focus-ring);
        outline: none;
    }

.upload-dropzone-icon {
    font-size: 2rem;
    line-height: 1;
}

.upload-dropzone-title {
    font-weight: 600;
    color: #0f172a;
}

.upload-dropzone-subtitle {
    font-size: 0.9rem;
    color: #52607a;
}

.upload-dropzone-compact {
    flex-direction: row;
    justify-content: flex-start;
    min-height: unset;
    padding: 0.6rem 1rem;
    gap: 0.75rem;
    text-align: left;
}

    .upload-dropzone-compact .upload-dropzone-icon {
        font-size: 1.4rem;
        flex-shrink: 0;
    }

    .upload-dropzone-compact .upload-dropzone-body {
        display: flex;
        flex-direction: column;
        gap: 0.1rem;
    }

/* ── Selected files list (copied from adhococr.css) ───────────────────────── */
.selected-files-summary {
    margin-top: 0.4rem;
}

.selected-files-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-top: 0.4rem;
}

.selected-file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.35rem 0.6rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
}

.selected-file-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.selected-file-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 0.35rem;
    background: #e8f0ff;
    color: #0d6efd;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.selected-file-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #0f172a;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
}

.selected-file-details {
    font-size: 0.75rem;
    color: #64748b;
}

/* File status badge (post-analysis) */
.selected-file-item.status-success .selected-file-icon {
    background: #dcfce7;
    color: #16a34a;
}

.selected-file-item.status-error .selected-file-icon {
    background: #fee2e2;
    color: #dc2626;
}

/* ── Cloud sources panel (copied from adhococr.css) ───────────────────────── */
.cloud-sources-panel {
    border: 1px dashed rgba(13, 110, 253, 0.25);
    background: #f8fbff;
    border-radius: 0.5rem;
    padding: 0.65rem 0.75rem;
}

.cloud-sources-divider {
    position: relative;
    text-align: center;
    color: #6c757d;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 0.25rem 0 0.5rem;
}

    .cloud-sources-divider::before {
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        top: 50%;
        height: 1px;
        background: rgba(0, 0, 0, 0.08);
        z-index: 0;
    }

    .cloud-sources-divider span {
        position: relative;
        background: #f8fbff;
        padding: 0 0.5rem;
        z-index: 1;
    }

#cloudAccountStatus {
    word-break: break-word;
}

/* ── Progress bar (copied from adhococr.css) ──────────────────────────────── */
.loading-progress {
    width: 100%;
    height: 0.65rem;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}

.loading-progress-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #0d6efd 0%, #6f42c1 100%);
    border-radius: inherit;
    transition: width 0.2s ease;
}

/* ── Modals (copied from adhococr.css) ─────────────────────────────────────── */
.app-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(15, 23, 42, 0.28);
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.app-modal-dialog {
    min-width: min(26rem, 100%);
    margin: auto;
}

.form-control:focus,
.form-select:focus,
.btn:focus-visible,
.dropdown-item:focus-visible {
    box-shadow: var(--focus-ring);
}

/* ── Cloud picker modal (created by adhoc-cloud.js, copied from adhococr.css) ─ */
body.cloud-picker-open {
    overflow: hidden;
}

.cloud-picker-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 1080; /* above bootstrap modal backdrop level */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.cloud-picker-modal {
    background: #fff;
    border-radius: 0.75rem;
    width: min(880px, 100%);
    height: min(720px, 90vh);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.cloud-picker-header {
    padding: 0.75rem 1rem;
    background: var(--dialog-header-bg);
    border-bottom: 1px solid var(--dialog-header-border);
}

.cloud-picker-toolbar {
    padding: 0.6rem 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    background: #f8f9fa;
}

.cloud-picker-source {
    width: auto;
    min-width: 12rem;
}

.cloud-picker-search {
    flex: 1 1 12rem;
    min-width: 12rem;
}

.cloud-picker-breadcrumb {
    padding: 0.4rem 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    font-size: 0.85rem;
}

.cloud-picker-crumb {
    background: none;
    border: 0;
    padding: 0.1rem 0.35rem;
    border-radius: 0.25rem;
    color: #0d6efd;
    cursor: pointer;
}

    .cloud-picker-crumb:hover {
        background: rgba(13, 110, 253, 0.08);
    }

    .cloud-picker-crumb.is-current {
        color: #212529;
        font-weight: 600;
        cursor: default;
    }

    .cloud-picker-crumb.is-current:hover {
        background: transparent;
    }

.cloud-picker-crumb-sep {
    color: #adb5bd;
}

.cloud-picker-select-all {
    padding: 0.25rem 1rem 0.4rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    margin: 0;
}

.cloud-picker-select-all .form-check-input {
    margin-top: 0;
    flex: 0 0 auto;
}

.cloud-picker-select-all .form-check-label {
    cursor: pointer;
    user-select: none;
}

.cloud-picker-select-all-count {
    margin-left: 0.25rem;
}

.cloud-picker-list {
    flex: 1 1 auto;
    overflow: auto;
    padding: 0.25rem 0.5rem;
}

.cloud-picker-loading,
.cloud-picker-empty {
    padding: 1.25rem;
    text-align: center;
    color: #6c757d;
}

.cloud-picker-row {
    display: grid;
    grid-template-columns: 2rem 1.5rem 1fr auto;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    border-radius: 0.35rem;
    cursor: pointer;
    user-select: none;
}

    .cloud-picker-row:hover {
        background: #f1f5ff;
    }

    .cloud-picker-row.is-folder .cloud-picker-row-icon {
        color: #f0ad4e;
    }

    .cloud-picker-row.is-file .cloud-picker-row-icon {
        color: #0d6efd;
    }

    .cloud-picker-row.is-disabled {
        opacity: 0.55;
        cursor: not-allowed;
    }

    .cloud-picker-row.is-disabled:hover {
        background: transparent;
    }

    .cloud-picker-row.cloud-picker-load-more {
        color: #0d6efd;
        font-weight: 500;
        background: rgba(13, 110, 253, 0.04);
        border: 1px dashed rgba(13, 110, 253, 0.25);
        margin-top: 0.35rem;
    }

    .cloud-picker-row.cloud-picker-load-more:hover {
        background: rgba(13, 110, 253, 0.10);
    }

    .cloud-picker-row.cloud-picker-load-more.is-loading {
        cursor: progress;
        opacity: 0.7;
    }

    .cloud-picker-row.cloud-picker-load-more .cloud-picker-row-icon {
        color: #0d6efd;
    }

.cloud-picker-row-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cloud-picker-status {
    padding: 0.4rem 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.04);
}

.cloud-picker-footer {
    padding: 0.6rem 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    background: #f8f9fa;
}

/* ──────────────────────────────────────────────────────────────────────────
   Page-specific styles (moved from adhocreason.html)
   ────────────────────────────────────────────────────────────────────────── */

/* Fill the fixed-height analyzer page and let each column scroll on its own
   so the full field list (and results) is reachable. .analyzer-page is
   height:100dvh with overflow:hidden and .py-3 (1rem top + 1rem bottom). */
html, body {
    height: 100%;
    overflow: hidden;
}

#reasonLayout {
    height: calc(100dvh - 2rem);
}

.reason-scroll-col {
    height: 100%;
    overflow-y: auto;
    min-height: 0;
}

/* The left column is a full-height white sidebar against the divider, as on Invoice Capture
   (.analyzer-sidebar-column in extractfile.css), rather than a card that ends after Results. */
.reason-sidebar-panel {
    min-height: 100%;
    box-sizing: border-box;
    padding: 1rem;
    background: #fff;
    border-right: 1px solid #dee2e6;
}

/* Below Bootstrap's lg breakpoint the columns stack, so let the page grow
   and scroll naturally instead of trapping content in two short panes. */
@media (max-width: 991.98px) {
    html, body {
        height: auto;
        overflow: auto;
    }

    /* The window (html) scrolls. A body with overflow: auto would be a scroll container of its own
       that never scrolls, and the sticky template bar and top of Results would stick to it, so not
       at all. */
    body {
        overflow: visible;
    }

    .analyzer-page {
        height: auto;
        min-height: 100dvh;
        overflow: visible;
    }

    #reasonLayout {
        height: auto;
    }

    .reason-scroll-col {
        height: auto;
        overflow: visible;
    }

    /* Stacked above the preview, the sidebar has no divider to sit against. */
    .reason-sidebar-panel {
        border: 1px solid #dee2e6;
        border-radius: 0.375rem;
    }
}

/* ── Adjustable split between the fields (left) and results (right) panes ── */
#reasonLayout.reason-split {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
}

.reason-pane {
    min-width: 0;
    min-height: 0;
}

.reason-resizer {
    display: none;
}

@media (min-width: 992px) {
    #reasonLayout.reason-split {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 0;
        align-items: stretch;
    }

    #reasonLayout.reason-split > .reason-pane-left {
        flex: 0 0 auto;
        width: var(--reason-split, 50%);
        min-width: 260px;
    }

    #reasonLayout.reason-split > .reason-pane-right {
        flex: 1 1 0;
        min-width: 260px;
    }

    .reason-resizer {
        flex: 0 0 12px;
        align-self: stretch;
        display: block;
        width: 12px;
        min-width: 12px;
        position: relative;
        cursor: col-resize;
        background: linear-gradient(180deg, #eef2f6 0%, #dde5ee 100%);
        border-left: 1px solid #d7dee8;
        border-right: 1px solid #d7dee8;
        user-select: none;
        touch-action: none;
    }

    .reason-resizer-grip {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 4px;
        height: 64px;
        border-radius: 999px;
        background: #93a4b8;
        box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.85);
    }

    .reason-resizer:hover,
    .reason-resizer:focus-visible,
    .reason-resizer.is-dragging {
        background: linear-gradient(180deg, #dcecff 0%, #cfe2ff 100%);
        outline: none;
    }

    #reasonLayout.reason-split.is-resizing {
        cursor: col-resize;
        user-select: none;
    }
}

.fields-section-header {
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* The top of the field list, as in the extension: the template bar and, in wide columns, the column
   headings. It sticks to the top while a long list of fields scrolls under it, on its own background,
   with the space below it as padding so no field shows through; it lets go at the end of the Fields
   section. The top padding gives it room when stuck, and the negative margin keeps it where it was
   otherwise. Its height is kept in --fields-sticky-height (AdhocResults.watchStickyHeight). */
.fields-sticky {
    position: sticky;
    top: 0;
    /* Above the Results bar (6), which follows it on the page. */
    z-index: 7;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    margin-top: -.5rem;
    padding: .5rem 0 .6rem;
    background: #fff;
}

.fields-template-picker {
    background: #f8fafc;
    border: 1px solid #e8eef5;
    border-radius: 0.6rem;
    padding: 0.5rem 0.625rem;
}

.template-picker-label {
    color: #475569;
    white-space: nowrap;
}

.fields-template-picker .form-select {
    flex: 1 1 160px;
    min-width: 150px;
    max-width: 240px;
}

.template-picker-divider {
    align-self: stretch;
    width: 1px;
    min-height: 1.5rem;
    background: #dbe3ec;
    margin: 0 .125rem;
}

@media (max-width: 575.98px) {
    .template-picker-divider {
        display: none;
    }
}

/* The field cards sit on a grey area so they stand out. */
#reasoningFields:not(:empty) {
    padding: .5rem;
    margin-bottom: .5rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
}

/* One card per field. Its first row (the drag handle, the name and remove) is the card's title bar,
   drawn by ::before behind that row across the card's full width; the type and Key, the options and
   the description follow below it. */
.reasoning-field-row {
    /* A card brought into view (Tab, Enter in a name, Add field) stops below the sticky template bar. */
    scroll-margin-top: var(--fields-sticky-height, 0px);
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
        "drag name remove"
        "typekey typekey typekey"
        "options options options"
        "question question question";
    gap: .5rem;
    align-items: start;
    margin-bottom: .5rem;
    padding: .4rem .6rem .6rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
    /* Rounds the corners of the title bar. */
    overflow: clip;
}

    .reasoning-field-row:last-child {
        margin-bottom: 0;
    }

    /* The title bar: a grid item over the first row, taken out to the card's edges by its negative
       margins. The items of that row come after it, so they are drawn on top. */
    .reasoning-field-row::before {
        content: "";
        grid-row: 1;
        grid-column: 1 / -1;
        align-self: stretch;
        margin: -.4rem -.6rem 0;
        background: #f1f5f9;
        border-bottom: 1px solid #e2e8f0;
    }

    /* The first row's items keep the same room below them inside the bar as above. */
    .reasoning-field-row .rf-drag,
    .reasoning-field-row .rf-name,
    .reasoning-field-row .rf-remove {
        margin-bottom: .4rem;
    }

    /* Picked up while dragging. */
    .reasoning-field-row.dragging {
        opacity: .55;
        box-shadow: 0 6px 16px rgba(15, 23, 42, 0.18);
    }

.reasoning-field-row .rf-drag {
    grid-area: drag;
    align-self: center;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 .1rem;
    color: #cbd5e1;
    cursor: grab;
    user-select: none;
}

.reasoning-field-row .rf-drag:hover {
    color: #94a3b8;
}

.reasoning-field-row.dragging .rf-drag {
    cursor: grabbing;
}

/* Column header row above the field list. Hidden on small screens where the
   row layout stacks and the placeholders provide enough context. */
.reasoning-fields-header {
    display: none;
}

/* Data type and the Key toggle share one line; the select flexes and the toggle keeps its
   intrinsic width so the two stay on a single row at every breakpoint. The wrapper is kept at
   its natural height because the row uses align-items: stretch at >=768px, which would
   otherwise stretch the select to fill the remaining grid track height. */
.reasoning-field-row .rf-typekey {
    grid-area: typekey;
    display: flex;
    align-items: center;
    gap: .5rem;
    min-width: 0;
    align-self: start;
}

.reasoning-field-row .rf-type {
    color: #64748b;
    font-size: .8125rem;
    flex: 1 1 auto;
    min-width: 0;
    max-width: 12rem;
}

/* A page without the Key toggle has the select straight in the row, with no wrapper to place it. */
.reasoning-field-row > .rf-type {
    grid-area: typekey;
    align-self: start;
}

.reasoning-field-row .rf-remove {
    grid-area: remove;
    align-self: center;
    color: #94a3b8;
    border-color: transparent;
    background: transparent;
    padding: .25rem .4rem;
}

.reasoning-field-row .rf-remove:hover,
.reasoning-field-row .rf-remove:focus-visible {
    color: #dc3545;
    background: rgba(220, 53, 69, .1);
    border-color: transparent;
}

.reasoning-field-row .rf-name {
    grid-area: name;
    font-weight: 600;
}

.reasoning-field-row .rf-question {
    grid-area: question;
}

.reasoning-field-row .rf-options {
    grid-area: options;
}

.reasoning-field-row .rf-key {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    align-self: center;
    flex: 0 0 auto;
    white-space: nowrap;
    font-size: .75rem;
    color: #64748b;
    cursor: pointer;
    user-select: none;
}

.reasoning-field-row .rf-key-input {
    margin: 0;
    cursor: pointer;
}

/* The toggle is unavailable for multi-value types, which cannot identify a record.
   pointer-events on the disabled input is left alone; the label carries the cursor because
   a disabled control does not generate pointer events of its own. */
.reasoning-field-row.key-blocked .rf-key {
    opacity: .45;
    cursor: not-allowed;
}

.reasoning-field-row.key-blocked .rf-key-input {
    pointer-events: none;
}

/* Highlight fields that make up the Unique Key so the record identity is scannable: the label, and
   a pale blue title bar. */
.reasoning-field-row:has(.rf-key-input:checked) .rf-key {
    color: #0d6efd;
    font-weight: 600;
}

.reasoning-field-row:has(.rf-key-input:checked)::before {
    background: #eff6ff;
    border-bottom-color: #dbeafe;
}

.reasoning-field-row .rf-options[hidden] {
    display: none;
}

@media (min-width: 768px) {
    .reasoning-field-row {
        /* Stack Field + Type in the left column with the Description on the right, then let the
           Options input span the whole width on its own row underneath. A leading grip column
           hosts the drag handle. The card has no title bar here: the Description sits beside the
           name, across the rows a bar would cover. */
        grid-template-columns: auto minmax(160px, 1fr) minmax(220px, 1.6fr) auto;
        grid-template-areas:
            "drag name question remove"
            "drag typekey question remove"
            "drag options options .";
        align-items: stretch;
        padding: .6rem;
    }

        .reasoning-field-row::before {
            display: none;
        }

        .reasoning-field-row .rf-drag,
        .reasoning-field-row .rf-name,
        .reasoning-field-row .rf-remove {
            margin-bottom: 0;
        }

    .reasoning-field-row .rf-drag {
        align-self: stretch;
    }

    .reasoning-field-row .rf-remove {
        align-self: start;
    }

    /* A Key field's card keeps a pale blue edge in place of the bar. */
    .reasoning-field-row:has(.rf-key-input:checked) {
        border-color: #bfdbfe;
        background: #eff6ff;
    }

    /* Its columns line up with the cards' below: the grey area's padding and border, and the card's. */
    .reasoning-fields-header {
        display: grid;
        grid-template-columns: auto minmax(160px, 1fr) minmax(220px, 1.6fr) auto;
        gap: .5rem;
        padding: 0 calc(.5rem + .6rem + 2px) .35rem;
        margin-bottom: .1rem;
        border-bottom: 1px solid #eef2f7;
    }

    .reasoning-fields-header .rfh-col {
        font-size: .7rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: .03em;
        color: #94a3b8;
    }

    .reasoning-fields-header .rfh-drag {
        /* Aligns with the drag-handle column. */
        width: 1rem;
    }

    .reasoning-fields-header .rfh-spacer {
        /* Aligns with the remove-button column. */
        width: 2rem;
    }
}

.reasoning-field-row textarea {
    min-height: 38px;
    resize: vertical;
}

@media (min-width: 768px) {
    /* Description spans the Field + Type rows; keep it compact so the full-width Options row fits. */
    .reasoning-field-row .rf-question {
        min-height: 38px;
        height: 100%;
    }
}

/* Its body is grey so the answer cards on it stand out, with room after the last one. */
/* overflow: clip rounds the corners like hidden did, but unlike hidden it does not stop the header
   inside from sticking. A card scrolled to stops below the sticky top of Results. */
.reasoning-result-card {
    position: relative;
    background: #f8fafc;
    border: 1px solid #e8eef5;
    border-radius: 0.9rem;
    margin-bottom: 1rem;
    padding-bottom: .75rem;
    overflow: clip;
    scroll-margin-top: var(--results-sticky-height, 0px);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

    .reasoning-result-card::before {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 3px;
        background: #0d6efd;
    }

    /* The document's name stays in view below the sticky top of Results while its rows scroll, as in
       the extension. Its height is kept in --results-head-height on the card. */
    .reasoning-result-card .rr-head {
    position: sticky;
    top: var(--results-sticky-height, 0px);
    z-index: 2;
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .75rem 1rem;
    font-weight: 600;
    color: #1f2937;
    background: #eff6ff;
    border-bottom: 1px solid #e8eef5;
    word-break: break-word;
}

.rr-head-icon {
    flex: 0 0 auto;
    font-size: 1.1rem;
    color: #0d6efd;
}

.rr-head-title {
    flex: 1 1 auto;
    min-width: 0;
    word-break: break-word;
}

.rr-head-count {
    flex: 0 0 auto;
    padding: .15rem .55rem;
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
    color: #4338ca;
    background: rgba(99, 102, 241, 0.12);
    border-radius: 999px;
}

/* One small card per answer, on the document card's grey body. Its left edge is the field's palette
   colour, shared with its regions on the document preview. */
.reasoning-result-field {
    position: relative;
    /* A card brought into view (Tab) stops below the sticky top of Results and the document header. */
    scroll-margin-top: calc(var(--results-sticky-height, 0px) + var(--results-head-height, 3rem));
    margin: .5rem .75rem 0;
    padding: .55rem .75rem .6rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-left: 4px solid var(--rr-color, #e2e8f0);
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
    /* Rounds the corners of the name bar across its top. */
    overflow: clip;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

    .reasoning-result-field:hover {
        border-top-color: #cbd5e1;
        border-right-color: #cbd5e1;
        border-bottom-color: #cbd5e1;
        box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
    }

/* The field's name is the card's title bar, across its top like a dialog's header: the negative
   margins take it out to the card's edges, its padding keeps the name in line with the answer below. */
.rr-row-head {
    display: flex;
    align-items: center;
    gap: .4rem;
    min-width: 0;
    margin: -.55rem -.75rem .45rem;
    padding: .4rem .75rem;
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
}

.rr-name {
    min-width: 0;
    font-size: .85rem;
    font-weight: 600;
    line-height: 1.3;
    color: #1f2937;
    overflow-wrap: anywhere;
}

/* Marks a result field that is part of the unique key (mirrors the Key checkbox in Fields). */
.rr-key-icon {
    font-size: .85em;
    vertical-align: baseline;
}

/* The OCR confidence pill beside the field name, coloured by its band (the field's palette colour stays
   on its evidence chip). The colours are the extension's theme.css success, warning and danger 700 on 50. */
.rr-confidence {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    margin-left: .25rem;
    padding: 0 .45rem;
    font-size: .7rem;
    font-weight: 600;
    line-height: 1.5;
    letter-spacing: normal;
    text-transform: none;
    white-space: nowrap;
    vertical-align: middle;
    border: 1px solid currentColor;
    border-radius: 999px;
}

    .rr-confidence[hidden] {
        display: none;
    }

    .rr-confidence .bi {
        font-size: .55rem;
    }

.rr-confidence-high { color: #15803D; background: #F0FDF4; }
.rr-confidence-medium { color: #B45309; background: #FFFBEB; }
.rr-confidence-low { color: #B91C1C; background: #FEF2F2; }

/* The filters above the result rows (adhoc-results.js), laid out as the extension's: All, Needs
   attention and Edited with their counts, then the text filter. The active filter takes this page's
   blue accent. */
.results-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem;
}

    .results-toolbar[hidden] {
        display: none;
    }

/* The top of Results, as in the extension, which sticks while a long list of answers scrolls under it:
   the title with the actions, then the filters. It has its own background, with the space below it as
   padding so no row shows through. The top padding gives the title room when stuck; the negative
   margin keeps it where it was otherwise, inside the panel's own padding. Its height is kept in
   --results-sticky-height (AdhocResults.watchStickyHeight) for the card header that sticks below it. */
.results-sticky {
    position: sticky;
    top: 0;
    z-index: 6;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    margin-top: -.5rem;
    padding: .5rem 0 .6rem;
    background: #fff;
}

    /* A collapsed section shows only its title and actions. */
    .results-sticky:has(.section-header[aria-expanded="false"]) .results-toolbar {
        display: none;
    }

.results-filters {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem;
}

.results-filter {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .15rem .55rem;
    font-size: .75rem;
    font-weight: 600;
    color: #475569;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    cursor: pointer;
}

    .results-filter:hover {
        color: #0a58ca;
        border-color: #9ec5fe;
    }

    .results-filter:focus-visible {
        outline: 2px solid #0d6efd;
        outline-offset: 1px;
    }

    .results-filter.is-active {
        color: #084298;
        background: #e7f1ff;
        border-color: #0d6efd;
    }

.results-filter-count {
    min-width: 1.1rem;
    padding: 0 .3rem;
    font-size: .68rem;
    text-align: center;
    color: inherit;
    background: rgba(15, 23, 42, .06);
    border-radius: 999px;
}

.results-search {
    flex: 1 1 10rem;
    min-width: 8rem;
    max-width: 20rem;
    margin-left: auto;
}

/* Said in place of a document's rows when the filters leave none of them. */
.rr-no-match {
    margin: 0;
    padding: .75rem 1rem;
    text-align: center;
}

    .rr-no-match[hidden] {
        display: none;
    }

.rr-answer-row {
    display: flex;
    /* The pencil/undo actions must stay beside the value — long answers wrap inside .rr-answer
       (min-width: 0) instead of pushing the buttons onto their own line. */
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: .5rem;
}

    /* The inline editor and its Save/Cancel bar are flex: 1 1 100% and need wrapping to claim
       the full width of the row. */
    .rr-answer-row.is-editing {
        flex-wrap: wrap;
    }

.rr-answer {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 1rem;
    line-height: 1.4;
    color: #1f2937;
    white-space: pre-wrap;
    /* The row no longer wraps, so a long unbroken value (URL, reference number) must break
       inside this column rather than overflow it and push the actions off the card. */
    overflow-wrap: anywhere;
}

    .rr-answer.is-empty {
        color: #9aa5b1;
        font-style: italic;
    }

    .rr-answer.is-overridden {
        padding-left: .5rem;
        border-left: 3px solid #ffa500;
    }

    /* How a custom-formatted answer is stored ("Saved as 2025-03-15"), or why it cannot be. */
    .rr-answer-saved {
        margin-top: .15rem;
        font-size: .75rem;
        font-style: normal;
        color: #6b7280;
    }

        .rr-answer-saved.is-warning {
            color: #b45309;
        }

.rr-answer-actions {
    display: flex;
    flex: 0 0 auto;
    align-self: flex-start;
    align-items: center;
    gap: .25rem;
}

    .rr-answer-actions[hidden] {
        display: none;
    }

.rr-override-badge {
    padding: .1rem .45rem;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
    white-space: nowrap;
    color: #a15c00;
    background: rgba(255, 165, 0, 0.16);
    border-radius: 999px;
}

.rr-answer-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .1rem .35rem;
    font-size: .85rem;
    line-height: 1;
    color: #64748b;
    background: transparent;
    border: 1px solid transparent;
    border-radius: .35rem;
    cursor: pointer;
}

    .rr-answer-btn[hidden] {
        display: none;
    }

    .rr-answer-btn:hover,
    .rr-answer-btn:focus-visible {
        color: #0d6efd;
        background: #eef2ff;
        border-color: #dbe4ff;
    }

    .rr-answer-btn-undo:hover,
    .rr-answer-btn-undo:focus-visible {
        color: #a15c00;
        background: rgba(255, 165, 0, 0.12);
        border-color: rgba(255, 165, 0, 0.3);
    }

.rr-answer-editor {
    flex: 1 1 100%;
}

.rr-answer-edit-actions {
    display: flex;
    flex: 1 1 100%;
    gap: .35rem;
}

.rr-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .35rem;
    margin-top: .4rem;
    padding: .4rem .55rem;
    font-size: .8rem;
    color: #475569;
    white-space: pre-wrap;
    background: #f8fafc;
    border: 1px solid #eef2f7;
    border-radius: .5rem;
}

.rr-meta-label {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    flex: 0 0 auto;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
    color: #0d6efd;
}

.rr-meta-rationale .rr-meta-label {
    color: #6f42c1;
}

.rr-meta-text {
    flex: 1 1 auto;
    min-width: 0;
}


/* ── Bootstrap overrides ── */
.btn-primary {
    --bs-btn-bg: #FFA500;
    --bs-btn-border-color: #ffb835;
    --bs-btn-hover-bg: #3191CF;
    --bs-btn-hover-border-color: #55a0d0;
    --bs-btn-active-color: #ffffff;
    --bs-btn-hover-color: #ffffff;
    --bs-btn-color: #ffffff;
}

/* ── Step badges (numbered flow) ── */
.step-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    margin-right: .5rem;
    border-radius: 50%;
    background: #FFA500;
    color: #fff;
    font-size: .8rem;
    font-weight: 700;
    line-height: 1;
    flex: 0 0 auto;
}

.step-badge-sm {
    width: 1.25rem;
    height: 1.25rem;
    font-size: .7rem;
    margin-right: .4rem;
    background: #6c757d;
}

/* ── Results empty state ── */
.results-empty {
    padding: 1.75rem 1rem;
    text-align: center;
}

.results-empty-icon {
    font-size: 2.25rem;
    color: #c7ccd1;
    line-height: 1;
    margin-bottom: .5rem;
}

.results-empty-title {
    font-weight: 600;
    font-size: 1rem;
    color: #495057;
    margin-bottom: .75rem;
}

.results-empty-steps {
    display: inline-flex;
    flex-direction: column;
    gap: .35rem;
    text-align: left;
}

.results-empty-steps > div {
    display: flex;
    align-items: center;
}

/* ── Document preview column (ported from adhococr.css) ───────────────────── */
.document-preview-column {
    min-width: 0;
    min-height: 0;
    overflow: auto;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 0.25rem;
}

.preview-toolbar {
    display: none;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.625rem 1rem;
    position: sticky;
    top: 0;
    z-index: 200;
    background: rgba(255, 255, 255, 0.97);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid #dde6f0;
    border-radius: 0.75rem;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.07), 0 1px 2px rgba(15, 23, 42, 0.04);
}

    .preview-toolbar.is-visible {
        display: flex;
    }

.preview-toolbar-content {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    justify-content: space-between;
}

.preview-zoom-label {
    min-width: 4rem;
    display: inline-block;
}

/* Document picker dropdown (thumbnails + labels) */
.document-picker {
    position: relative;
}

.document-picker-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

    /* Give the position label (e.g. "Document 1 of 3") a fixed footprint so the toggle button
       (and therefore the Next button next to it) keeps a constant width while navigating
       between documents. Longer text is truncated with an ellipsis instead of stretching the toolbar. */
    .document-picker-toggle #documentPickerLabel {
        display: inline-block;
        width: 7.5rem;
        min-width: 7.5rem;
        max-width: 7.5rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        text-align: left;
        vertical-align: middle;
    }

.document-picker-menu {
    max-height: 80vh;
    overflow-y: auto;
    padding: 0.75rem;
    min-width: 40rem;
}

    .document-picker-menu.show {
        display: grid;
        grid-template-columns: repeat(3, 200px);
        gap: 0.75rem;
    }

.document-picker-item {
    --document-picker-thumb-width: 176px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.4rem;
    border-radius: 0.5rem;
    cursor: pointer;
    border: 1px solid #e2e8f0;
    background: #fff;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

    .document-picker-item:hover,
    .document-picker-item:focus-visible {
        background: #f8fafc;
        border-color: #cbd5e1;
        outline: none;
        transform: translateY(-1px);
        box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
    }

    .document-picker-item.is-active {
        background: #e8f0ff;
        border-color: #0d6efd;
        box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.18);
    }

    /* Documents that have not finished extracting yet are listed so the user can see the queue,
       but they are not selectable: there is no preview or result to show for them. */
    .document-picker-item:disabled {
        cursor: default;
        opacity: 0.6;
    }

        .document-picker-item:disabled:hover {
            background: #fff;
            border-color: #e2e8f0;
            transform: none;
            box-shadow: none;
        }

.document-picker-item-status {
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.2;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    color: #475569;
    background: #f1f5f9;
}

    .document-picker-item-status.is-extracting {
        color: #1d4ed8;
        background: #dbeafe;
    }

    .document-picker-item-status.is-error {
        color: #b91c1c;
        background: #fee2e2;
    }

.extract-progress-dialog {
    max-width: 480px;
}

/* Persistent on-page extraction errors (mirrors the copy inside the progress modal). */
.extract-errors-page:empty {
    display: none;
}

.extract-errors-summary summary {
    cursor: pointer;
    font-weight: 600;
}

.extract-errors-summary-list {
    margin-top: 0.5rem;
    max-height: 9rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.document-picker-item-thumb-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--document-picker-thumb-width);
    height: 120px;
    border: 1px solid #e2e8f0;
    border-radius: 0.4rem;
    background: #f8fafc;
    color: #64748b;
    font-size: 2.4rem;
}

.document-picker-item-thumb {
    width: var(--document-picker-thumb-width);
    height: 120px;
    object-fit: contain;
    border: 1px solid #e2e8f0;
    border-radius: 0.4rem;
    background: #fff;
}

.document-picker-item-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #0f172a;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    text-align: center;
}

.multi-page-preview {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    position: relative;
    z-index: 1;
    align-items: flex-start;
}

.preview-page-container {
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    width: 100%;
    position: relative;
    z-index: 1;
    overflow: hidden;
}

.preview-page-wrapper {
    position: relative;
    background: #fff;
    border: 1px solid #dbe4f0;
    border-radius: 0.9rem;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
    overflow: hidden;
    transform-origin: top left;
}
    .preview-page-wrapper img,
    .preview-page-wrapper canvas {
        display: block;
        max-width: 100%;
        height: auto;
    }

/* Friendly message shown in place of pages when a document (or a single page) can't render. */
.preview-message {
    padding: 2rem 1.5rem;
    text-align: center;
    font-size: 0.9rem;
}

.preview-page-error {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 200px;
    min-height: 120px;
    padding: 1.5rem;
    text-align: center;
    font-size: 0.85rem;
    background: #f8fafc;
}

.page-number-overlay {
    position: absolute;
    top: 0;
    left: 0;
    background: #aaa;
    color: #fff;
    padding: 0.35rem 0.55rem;
    font-weight: 700;
    font-size: 0.85rem;
    z-index: 50;
    pointer-events: none;
    border-bottom-right-radius: 0.75rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* Evidence bounding-region overlay (ported from adhococr .kvp-box) */
.kvp-box {
    position: absolute;
    box-sizing: border-box;
    opacity: 0.85;
    stroke-width: 1;
}

    .kvp-box.is-active {
        opacity: 1;
        stroke-width: 2;
        stroke-dasharray: 4 4;
        animation: kvp-box-march 2s linear infinite;
    }

@keyframes kvp-box-march {
    from {
        stroke-dashoffset: 0;
    }

    to {
        stroke-dashoffset: 16;
    }
}

@media (prefers-reduced-motion: reduce) {
    .kvp-box.is-active {
        animation: none;
    }
}

/* Clickable evidence row that drives the document highlight */
.rr-meta-clickable {
    cursor: pointer;
    border-radius: 0.4rem;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

    /* Highlighted in the field's palette colour (its card's --rr-color), the colour of its region on
       the preview, tinted as much as the active region's fill. After a click it stays highlighted
       while its region is shown (setSelectedEvidence). */
    .rr-meta-clickable:hover,
    .rr-meta-clickable:focus-visible,
    .rr-meta-clickable.is-selected {
        background: color-mix(in srgb, var(--rr-color, #0d6efd) 22%, #fff);
        outline: none;
        box-shadow: 0 0 0 2px var(--rr-color, rgba(13, 110, 253, 0.25));
    }

/* Evidence row whose highlight is queued until the preview finishes rasterizing. */
.rr-meta-waiting {
    background: #fff8e6;
    cursor: progress;
}

    .rr-meta-waiting::after {
        content: 'waiting for preview\2026';
        margin-left: 0.4rem;
        font-size: 0.7rem;
        font-style: italic;
        color: #8a6d3b;
        white-space: nowrap;
    }

/* ── Ambient preview render indicator ─────────────────────────────────────
   Visible only while #documentPreviewColumn carries data-rendering, telling the user the
   pages are still rasterizing and that an evidence click will be applied once they land. */
.preview-render-status {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem 0.35rem;
}

[data-rendering] .preview-render-status {
    display: flex;
}

.preview-render-bar {
    position: relative;
    flex: 1 1 auto;
    height: 3px;
    border-radius: 2px;
    background: #e4e8ef;
    overflow: hidden;
}

    .preview-render-bar::after {
        content: '';
        position: absolute;
        inset-block: 0;
        width: 35%;
        border-radius: 2px;
        background: #0d6efd;
        animation: previewRenderSlide 1.1s ease-in-out infinite;
    }

.preview-render-text {
    flex: 0 0 auto;
    font-size: 0.75rem;
    color: #5c6570;
    white-space: nowrap;
}

@keyframes previewRenderSlide {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(320%);
    }
}

@media (prefers-reduced-motion: reduce) {
    .preview-render-bar::after {
        animation: none;
        width: 100%;
        opacity: 0.5;
    }
}

/* ── Document preview empty-state workflow animation (ported from extractfile.css) ── */
.preview-empty-workflow {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0.25rem;
    text-align: initial;
}

.workflow-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    flex-shrink: 0;
}

.workflow-step-dot {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 2px solid #cbd5e1;
    background: #f8fafc;
    color: #94a3b8;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.workflow-step-label {
    font-size: 1.2rem;
    color: #94a3b8;
    font-weight: 600;
    transition: color 0.2s;
    white-space: nowrap;
}

.workflow-step.is-active .workflow-step-dot {
    border-color: #0d6efd;
    background: #0d6efd;
    color: #fff;
}

.workflow-step.is-active .workflow-step-label {
    color: #0d6efd;
}

.workflow-step.is-complete .workflow-step-dot {
    border-color: #198754;
    background: #198754;
    color: #fff;
}

.workflow-step.is-complete .workflow-step-label {
    color: #198754;
}

.workflow-step-connector {
    flex: 1 1 auto;
    height: 2px;
    background: #e2e8f0;
    margin-bottom: 1.8rem;
    min-width: 2rem;
}

/* ── Workflow steps footer (top of preview empty state) ── */
.workflow-steps-footer {
    opacity: 0.5;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 0;
    padding: 1rem 1.5rem;
    margin-top: 1rem;
    border-top: 1px solid #e2e8f0;
    background: linear-gradient(to bottom, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 1rem 1rem 0 0;
    width: 100%;
}

    .workflow-steps-footer .workflow-step {
        flex: 0 0 auto;
        min-width: 4.5rem;
        max-width: 9rem;
        width: 20%;
        position: relative;
    }

    .workflow-steps-footer .workflow-step-dot {
        width: 2.75rem;
        height: 2.75rem;
        font-size: 1.15rem;
        border-width: 2px;
        box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
        transition: border-color 0.25s, background 0.25s, color 0.25s, box-shadow 0.25s, transform 0.25s;
    }

    .workflow-steps-footer .workflow-step-label {
        font-size: 0.72rem;
        font-weight: 700;
        letter-spacing: 0.03em;
        text-transform: uppercase;
        transition: color 0.25s;
    }

.workflow-steps-footer .workflow-step-connector {
    flex: 1 1 auto;
    min-width: 1rem;
    max-width: 5rem;
    align-self: flex-start;
    margin-top: 1.375rem;
    height: 2px;
    background: linear-gradient(to right, #cbd5e1, #e2e8f0);
    border-radius: 999px;
    transition: background 0.3s;
}

.workflow-steps-footer .workflow-step.is-active .workflow-step-dot {
    box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.15), 0 4px 12px rgba(13, 110, 253, 0.25);
    transform: scale(1.08);
}

.workflow-steps-footer .workflow-step.is-active .workflow-step-label {
    font-weight: 800;
}

.workflow-steps-footer .workflow-step.is-complete .workflow-step-dot {
    box-shadow: 0 0 0 3px rgba(25, 135, 84, 0.12), 0 2px 8px rgba(25, 135, 84, 0.18);
}

.workflow-steps-footer .workflow-step-connector.is-complete {
    background: linear-gradient(to right, #198754, #20c997);
}

/* ── Workflow step animations ── */
.workflow-images {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    border-radius: 0.75rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.workflow-anim {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.75s ease-in-out;
    pointer-events: none;
    padding: 2.5rem;
}

    .workflow-anim.is-active {
        opacity: 0.5;
    }

.wf-anim-caption {
    font-size: 1.56rem;
    color: #94a3b8;
    font-weight: 500;
    text-align: center;
    margin-top: 1.2rem;
    letter-spacing: 0.01em;
}

/* Step 1: Upload */
.wf-anim-upload {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.wf-anim-cloud {
    font-size: 8rem;
    color: #3b82f6;
    line-height: 1;
    animation: wf-cloud-float 2.8s ease-in-out infinite;
    filter: drop-shadow(0 8px 28px rgba(59, 130, 246, 0.35));
}

.wf-anim-dropzone {
    width: 18rem;
    height: 9rem;
    border: 2.5px dashed #93c5fd;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(219, 234, 254, 0.35);
    animation: wf-zone-pulse 2.8s ease-in-out infinite;
    overflow: hidden;
}

.wf-anim-file {
    font-size: 3.6rem;
    color: #60a5fa;
    animation: wf-file-rise 2.8s ease-in-out infinite;
    display: block;
    line-height: 1;
}

@keyframes wf-cloud-float {
    0%, 100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-14px);
    }
}

@keyframes wf-file-rise {
    0% {
        transform: translateY(60px);
        opacity: 0;
    }

    18% {
        transform: translateY(0);
        opacity: 1;
    }

    68% {
        transform: translateY(0);
        opacity: 1;
    }

    95% {
        transform: translateY(-68px);
        opacity: 0;
    }

    100% {
        transform: translateY(60px);
        opacity: 0;
    }
}

@keyframes wf-zone-pulse {
    0%, 100% {
        border-color: #93c5fd;
    }

    50% {
        border-color: #3b82f6;
        box-shadow: inset 0 0 0 3px rgba(59, 130, 246, 0.07);
    }
}

/* Step 2: Fields */
.wf-anim-fields {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    width: 100%;
    max-width: 28rem;
}

.wf-anim-fields-input {
    width: 100%;
    height: 4.5rem;
    background: #f1f5f9;
    border: 1.5px solid #cbd5e1;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
}

.wf-anim-cursor {
    color: #3b82f6;
    font-weight: 300;
    font-size: 2.2rem;
    animation: wf-blink 1s step-end infinite;
}

.wf-anim-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
}

.wf-anim-chip {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1d4ed8;
    border-radius: 999px;
    padding: 0.4rem 1.5rem;
    font-size: 1.44rem;
    font-weight: 600;
    opacity: 0;
    transform: translateX(-16px) scale(0.88);
    animation: wf-chip-in 3.2s ease-in-out infinite;
    animation-delay: var(--d, 0s);
}

@keyframes wf-blink {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

@keyframes wf-chip-in {
    0% {
        opacity: 0;
        transform: translateX(-16px) scale(0.88);
    }

    18% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }

    72% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }

    90% {
        opacity: 0;
        transform: translateX(0) scale(0.92);
    }

    100% {
        opacity: 0;
        transform: translateX(-16px) scale(0.88);
    }
}

/* Step 3: Extract */
.wf-anim-doc {
    width: 14rem;
    height: 18rem;
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-radius: 0.5rem;
    box-shadow: 0 8px 36px rgba(15, 23, 42, 0.09);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 1.6rem;
    gap: 0.8rem;
}

.wf-anim-doc-lines span {
    display: block;
    height: 0.9rem;
    background: #e2e8f0;
    border-radius: 999px;
    margin-bottom: 0.8rem;
}

    .wf-anim-doc-lines span:nth-child(1) {
        width: 85%;
    }

    .wf-anim-doc-lines span:nth-child(2) {
        width: 70%;
    }

    .wf-anim-doc-lines span:nth-child(3) {
        width: 90%;
    }

    .wf-anim-doc-lines span:nth-child(4) {
        width: 55%;
    }

.wf-anim-scan-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(to right, transparent, #3b82f6, transparent);
    box-shadow: 0 0 20px 8px rgba(59, 130, 246, 0.45);
    animation: wf-scan 2s ease-in-out infinite;
    top: 0;
}

.wf-anim-sparkles {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.wf-sparkle {
    position: absolute;
    color: #f59e0b;
    opacity: 0;
    animation: wf-sparkle-pop 2s ease-in-out infinite;
}

.wf-sparkle-1 {
    font-size: 2.5rem;
    top: 8%;
    left: 78%;
    animation-delay: 0s;
}

.wf-sparkle-2 {
    font-size: 2.1rem;
    top: 50%;
    left: 82%;
    animation-delay: 0.65s;
}

.wf-sparkle-3 {
    font-size: 1.8rem;
    top: 82%;
    left: 74%;
    animation-delay: 1.3s;
}

@keyframes wf-scan {
    0% {
        top: 0%;
        opacity: 0;
    }

    6% {
        opacity: 1;
    }

    94% {
        opacity: 1;
    }

    100% {
        top: 100%;
        opacity: 0;
    }
}

@keyframes wf-sparkle-pop {
    0% {
        opacity: 0;
        transform: scale(0.4) rotate(-15deg);
    }

    35%, 60% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }

    100% {
        opacity: 0;
        transform: scale(0.6) rotate(12deg);
    }
}

/* Step 3 idle CTA (before extraction starts) */
.wf-anim-extract-idle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.wf-anim-extract {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    position: relative;
    transition: opacity 0.4s ease;
}
/* While extracting: hide idle CTA, show scanner */
#workflowImages.is-extracting .wf-anim-extract-idle {
    display: none;
}

#workflowImages.is-extracting .wf-anim-extract {
    display: flex;
}

.wf-anim-cta-btn {
    display: inline-flex;
    align-items: center;
    gap: 1rem;
    background: linear-gradient(135deg, #FFA500 0%, #ff8c00 100%);
    color: #fff;
    font-size: 1.8rem;
    font-weight: 700;
    padding: 1.1rem 2.5rem;
    border-radius: 0.6rem;
    box-shadow: 0 8px 28px rgba(255, 165, 0, 0.4);
    animation: wf-cta-pulse 2.2s ease-in-out infinite;
    letter-spacing: 0.01em;
    pointer-events: none;
}

    .wf-anim-cta-btn .bi {
        font-size: 2.1rem;
        animation: wf-cta-star-spin 2.2s ease-in-out infinite;
    }

@keyframes wf-cta-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 8px 28px rgba(255, 165, 0, 0.4);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 12px 44px rgba(255, 165, 0, 0.6);
    }
}

@keyframes wf-cta-star-spin {
    0%, 100% {
        transform: rotate(0deg) scale(1);
    }

    50% {
        transform: rotate(15deg) scale(1.15);
    }
}

@media (prefers-reduced-motion: reduce) {
    .wf-anim-cloud,
    .wf-anim-file,
    .wf-anim-dropzone,
    .wf-anim-cursor,
    .wf-anim-chip,
    .wf-anim-scan-line,
    .wf-sparkle,
    .wf-anim-cta-btn,
    .wf-anim-cta-btn .bi {
        animation: none !important;
    }

    .wf-anim-chip {
        opacity: 1;
        transform: none;
    }
}

/* ── Sign out confirmation (sign-out.js; a native <dialog>, as the extension's confirm dialog) ── */
.signout-dialog {
    /* Bootstrap sets these on .modal, which a native <dialog> is not, and .modal-content reads them. */
    --bs-modal-padding: 1rem;
    --bs-modal-color: var(--bs-body-color);
    --bs-modal-bg: var(--bs-body-bg);
    --bs-modal-border-color: var(--bs-border-color-translucent);
    --bs-modal-border-width: var(--bs-border-width);
    --bs-modal-border-radius: var(--bs-border-radius-lg);
    --bs-modal-box-shadow: var(--bs-box-shadow);
    --bs-modal-inner-border-radius: calc(var(--bs-border-radius-lg) - (var(--bs-border-width)));
    --bs-modal-header-padding: 1rem 1rem;
    --bs-modal-header-border-color: var(--bs-border-color);
    --bs-modal-header-border-width: var(--bs-border-width);
    --bs-modal-title-line-height: 1.5;
    --bs-modal-footer-gap: 0.5rem;
    --bs-modal-footer-border-color: var(--bs-border-color);
    --bs-modal-footer-border-width: var(--bs-border-width);
    width: min(26rem, calc(100% - 2rem));
    padding: 0;
    border: 0;
    background: transparent;
    overflow: visible;
}

    .signout-dialog .modal-content {
        box-shadow: var(--bs-modal-box-shadow);
    }

    .signout-dialog::backdrop {
        background: rgba(15, 23, 42, 0.38);
    }

    .signout-dialog[open] .modal-content {
        animation: signout-dialog-in 0.14s ease-out;
    }

@keyframes signout-dialog-in {
    from { opacity: 0; transform: translateY(6px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .signout-dialog[open] .modal-content { animation: none; }
}

/* Every dialog's title sits in a tinted bar across its top, with a line under it, as in the extension's
   side panel (.app-modal .modal-header in sidepanel.css). */
.app-modal .modal-header,
.signout-dialog .modal-header {
    padding: .75rem 1rem;
    background: var(--dialog-header-bg);
    border-bottom: 1px solid var(--dialog-header-border);
}

.signout-dialog-header {
    align-items: flex-start;
    gap: .45rem;
}

.signout-dialog-icon {
    font-size: 1.1rem;
    line-height: 1.3;
    color: #b02a37;
}

.signout-dialog-message {
    color: #475569;
    line-height: 1.45;
}
