:root {
    --bg: #f5f6f8;
    --panel: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #d1d5db;
    --accent: #264653;
    --accent-light: #eef4f5;
    --fixed-shell-bg: #eef2f5;
    --fixed-shell-panel: #f8fafc;
    --danger: #9f1239;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.45;
}

a { color: var(--accent); }

.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1.5rem;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}

.brand a {
    font-weight: 700;
    font-size: 1.2rem;
    text-decoration: none;
    color: var(--text);
}

.nav {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.container {
    width: calc(100% - 2rem); /* fluid: use all available width (was capped at 1180px) */
    margin: 1.5rem auto;
}

.site-footer {
    width: calc(100% - 2rem); /* fluid: use all available width (was capped at 1180px) */
    margin: 2rem auto;
    color: var(--muted);
    font-size: 0.9rem;
}

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.card.narrow { max-width: 620px; }
.card.muted { background: var(--accent-light); }

.grid.two {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.page-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

h1, h2 { margin-top: 0; }

button, .button {
    display: inline-block;
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    cursor: pointer;
    font: inherit;
}

button:hover, .button:hover { opacity: 0.92; }

.button.secondary {
    background: #fff;
    color: var(--accent);
}

.link-button {
    padding: 0;
    background: transparent;
    color: var(--accent);
    border: 0;
    text-decoration: underline;
}

.inline-form { margin: 0; }

.form-row { margin-bottom: 1rem; }
.form-row label { display: block; font-weight: 700; margin-bottom: 0.25rem; }
.form-row input, .form-row select, .form-row textarea {
    width: 100%;
    padding: 0.55rem;
    border: 1px solid var(--border);
    border-radius: 6px;
}
.help { color: var(--muted); font-size: 0.9rem; margin: 0.25rem 0 0; }

.filter-form {
    display: flex;
    gap: 0.5rem;
    align-items: end;
}

.filter-form select { padding: 0.5rem; min-width: 240px; }

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    text-align: left;
    border-bottom: 1px solid var(--border);
    padding: 0.6rem;
    vertical-align: top;
}

.metadata {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 0.5rem 1rem;
}
.metadata dt { font-weight: 700; }
.metadata dd { margin: 0; word-break: break-word; }

.messages { margin-bottom: 1rem; }
.message {
    padding: 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #fff;
}
.message.success { border-color: #15803d; }
.message.warning { border-color: #b45309; }
.message.error { border-color: var(--danger); }
.stat { font-size: 2.2rem; font-weight: 700; margin: 0; }
code { background: #f3f4f6; padding: 0.1rem 0.25rem; border-radius: 4px; }

.button-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.extract-page {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    margin-top: 1rem;
}

.extract-page pre {
    white-space: pre-wrap;
    word-break: break-word;
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    max-height: 24rem;
    overflow: auto;
}

.citation {
    color: var(--muted);
    font-size: 0.9rem;
}

.search-form input[type="search"] {
    min-width: 280px;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.search-result {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    margin-top: 1rem;
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #f9fafb;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--muted);
}

.compact-table {
    font-size: 0.92rem;
}

.compact-table td,
.compact-table th {
    padding: 0.4rem;
}
.select-row {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    color: #334155;
}
.copy-button {
    margin: 0.25rem 0 0.5rem 0;
}
.top-gap {
    margin-top: 1rem;
}
.form-grid p {
    display: grid;
    gap: 0.25rem;
    margin-bottom: 0.85rem;
}

/* Release 1.0 production/accountant intelligence additions */
.grid.three {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}
.form-grid p { margin-top: 0; }
.form-grid input,
.form-grid select,
.form-grid textarea {
    width: 100%;
    padding: 0.55rem;
    border: 1px solid var(--border);
    border-radius: 6px;
}
pre {
    white-space: pre-wrap;
    word-break: break-word;
}

/* Release 1.0.1 context-sensitive help.  Kept for old templates; v1.8.0a uses the fixed Help utility button instead. */
.context-help-bar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    background: #eef4f5;
    border: 1px solid var(--border);
    border-left: 5px solid var(--accent);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}
.context-help-bar span {
    display: block;
    color: var(--muted);
    font-size: 0.92rem;
    margin-top: 0.15rem;
}
.help-layout {
    display: grid;
    grid-template-columns: minmax(220px, 280px) 1fr;
    gap: 1rem;
}
.help-nav ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}
.help-nav li { margin: 0.35rem 0; }
.help-topic-section {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    margin-top: 1rem;
}
.help-topic-section:first-of-type {
    border-top: 0;
    padding-top: 0;
}
.help-summary {
    color: var(--muted);
    font-size: 1.05rem;
}
@media (max-width: 760px) {
    .context-help-bar,
    .help-layout {
        display: block;
    }
    .context-help-bar .button {
        margin-top: 0.75rem;
    }
}

/* Release 1.0.3 account management */
.button.danger,
button.danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}
.badge.danger {
    border-color: var(--danger);
    color: var(--danger);
    background: #fff1f2;
}

.warning-card {
    border-color: #b45309;
}

.warning-text {
    color: #92400e;
    font-weight: 700;
}

/* Release 1.1.1 compact grouped search results */
.search-result-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
}
.search-result-meta {
    color: var(--muted);
    margin: 0.25rem 0 0;
}
.search-hit-list-panel {
    margin-top: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f9fafb;
}
.search-hit-list-panel summary {
    cursor: pointer;
    padding: 0.75rem 1rem;
    font-weight: 700;
}
.search-hit-list {
    margin: 0;
    padding: 0 1rem 1rem 2.2rem;
}
.search-hit {
    padding: 0.75rem 0;
    border-top: 1px solid var(--border);
}
.search-hit-main {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}
.search-hit-link {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    text-decoration: none;
}
.search-hit-link:hover strong,
.search-hit-link:focus strong {
    text-decoration: underline;
}
.search-hit-open-label {
    color: var(--muted);
    font-size: 0.9rem;
}
.search-snippet {
    margin: 0.5rem 0;
}
.search-snippet mark {
    padding: 0 0.15rem;
    border-radius: 3px;
}
:target {
    scroll-margin-top: 1rem;
}
.extract-page:target,
tr:target {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}
@media (max-width: 760px) {
    .search-result-header {
        display: block;
    }
    .search-result-header .button-row {
        margin-top: 0.75rem;
    }
}

/* Release 1.1.2 / 1.1.2a navigation and location path bar */
.site-header {
    flex-wrap: wrap;
    gap: 1rem;
}

.nav {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.45rem;
}

.nav-link,
.nav-dropdown > summary {
    display: inline-flex;
    align-items: center;
    min-height: 2.1rem;
    padding: 0.35rem 0.55rem;
    border-radius: 6px;
    color: var(--accent);
    text-decoration: none;
    cursor: pointer;
    list-style: none;
}

.nav-dropdown > summary::-webkit-details-marker {
    display: none;
}

.nav-dropdown > summary::after {
    content: " ▾";
    font-size: 0.8rem;
    color: var(--muted);
}

.nav-link:hover,
.nav-link:focus,
.nav-dropdown > summary:hover,
.nav-dropdown > summary:focus {
    background: var(--accent-light);
}

.nav-dropdown {
    position: relative;
}

.nav-dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 0.25rem);
    min-width: 210px;
    z-index: 20;
    display: grid;
    gap: 0.15rem;
    padding: 0.4rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
}

.nav-dropdown-menu a,
.nav-menu-button {
    display: block;
    width: 100%;
    padding: 0.55rem 0.65rem;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--accent);
    text-align: left;
    text-decoration: none;
    font: inherit;
    cursor: pointer;
}

.nav-dropdown-menu a:hover,
.nav-dropdown-menu a:focus,
.nav-menu-button:hover,
.nav-menu-button:focus {
    background: var(--accent-light);
}

.nav-form {
    margin: 0;
}

@media (max-width: 760px) {
    .site-header {
        align-items: flex-start;
    }
    .nav {
        width: 100%;
        justify-content: flex-start;
    }
    .nav-dropdown {
        position: static;
    }
    .nav-dropdown-menu {
        left: 1rem;
        right: 1rem;
        min-width: unset;
    }
}

/* Release 1.1.3 upload progress and source-path tree views */
.upload-progress-panel {
    margin: 1rem 0;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #f9fafb;
}

.upload-progress-panel progress {
    width: 100%;
    height: 1.1rem;
}

.upload-error-panel {
    margin: 1rem 0;
}

.source-tree {
    margin-top: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #f9fafb;
    padding: 0.4rem;
}

.source-tree-node {
    margin: 0.25rem 0;
}

.source-tree-node summary {
    cursor: pointer;
    padding: 0.45rem 0.55rem;
    border-radius: 6px;
    list-style: none;
}

.source-tree-node summary::-webkit-details-marker {
    display: none;
}

.source-tree-node summary::before {
    content: "▸";
    display: inline-block;
    width: 1rem;
    color: var(--muted);
}

.source-tree-node[open] > summary::before {
    content: "▾";
}

.source-tree-node summary:hover,
.source-tree-node summary:focus {
    background: var(--accent-light);
}

.source-tree-folder-name {
    font-weight: 700;
}

.source-tree-count {
    margin-left: 0.4rem;
    color: var(--muted);
    font-size: 0.86rem;
}

.source-tree-children {
    margin-left: 1.25rem;
    padding-left: 0.75rem;
    border-left: 1px solid var(--border);
}

.source-tree-document {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) auto;
    gap: 0.15rem 0.75rem;
    align-items: baseline;
    padding: 0.45rem 0.55rem;
    margin: 0.25rem 0;
    border-radius: 6px;
    background: #fff;
    border: 1px solid #e5e7eb;
}

.source-tree-document-title {
    font-weight: 700;
}

.source-tree-document-meta,
.source-tree-path {
    color: var(--muted);
    font-size: 0.86rem;
}

.source-tree-path {
    grid-column: 1 / -1;
    word-break: break-word;
}

.source-tree-actions {
    display: inline-flex;
    gap: 0.55rem;
    flex-wrap: wrap;
    font-size: 0.86rem;
}

@media (max-width: 760px) {
    .source-tree-document {
        display: block;
    }
    .source-tree-document-meta,
    .source-tree-actions,
    .source-tree-path {
        display: block;
        margin-top: 0.2rem;
    }
}

.danger-link {
    color: var(--danger);
    font-weight: 700;
}

.source-tree-select {
    align-self: start;
    padding-top: 0.1rem;
}

.source-tree-select input {
    width: 1rem;
    height: 1rem;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.source-tree-document-selectable {
    grid-template-columns: auto minmax(180px, 1fr) auto;
}

.source-tree-document-selectable .source-tree-path {
    grid-column: 2 / -1;
}

/* Release 1.2.1 licence enforcement UI */
.licence-banner {
    width: calc(100% - 2rem); /* fluid: use all available width (was capped at 1180px) */
    margin: 0.75rem auto 0;
    padding: 0.65rem 0.85rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #fff7ed;
    color: #7c2d12;
}

.licence-banner.override {
    background: #eef4f5;
    color: var(--accent);
}

.licence-banner a {
    margin-left: 0.5rem;
    font-weight: 700;
}

.licence-quota-summary {
    display: grid;
    gap: 0.75rem;
    margin: 0.75rem 0;
}

.licence-quota-summary.compact {
    gap: 0.55rem;
}

.licence-override-note {
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--border);
    border-left: 5px solid var(--accent);
    border-radius: 8px;
    background: var(--accent-light);
    font-weight: 700;
}

.quota-row {
    padding: 0.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.quota-row-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
}

.quota-meter {
    height: 0.8rem;
    margin-top: 0.45rem;
    border-radius: 999px;
    overflow: hidden;
    background: #e5e7eb;
}

.quota-meter span {
    display: block;
    height: 100%;
    min-width: 0.25rem;
    background: var(--accent);
}

.quota-row.warning .quota-meter span { background: #b45309; }
.quota-row.danger .quota-meter span { background: var(--danger); }
.quota-row.override .quota-meter span { background: #64748b; }

.badge.override {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

button[disabled],
.button[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Release 1.2.2 subscription/manual licence support */
.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.licence-token-output {
    width: 100%;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.85rem;
    margin: 1rem 0;
}

.licence-banner.restricted {
    background: #fff7ed;
}

/* Release 1.2.3 search scope filters and safer delete controls */
.stacked-search-form {
    display: block;
}

.search-filter-row {
    display: grid;
    grid-template-columns: minmax(240px, 1.5fr) minmax(190px, 1fr) minmax(190px, 1fr) auto;
    gap: 0.75rem;
    align-items: end;
}

.search-filter-row label {
    display: block;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.search-filter-row input[type="search"],
.search-filter-row select {
    width: 100%;
    min-width: 0;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.search-submit-cell {
    white-space: nowrap;
}

.search-filter-tree {
    margin: 0.75rem 1rem 1rem;
    background: #fff;
}

.source-tree-folder-select {
    display: inline-flex;
    align-items: center;
    margin-right: 0.35rem;
    vertical-align: middle;
}

.source-tree-folder-select input,
.source-tree-select input {
    width: 1rem;
    height: 1rem;
}

.source-tree-document-compact {
    grid-template-columns: auto minmax(180px, 1fr) auto;
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
}

.small-button,
button.small-button,
.button.small-button {
    padding: 0.25rem 0.45rem;
    font-size: 0.84rem;
    border-radius: 5px;
}

@media (max-width: 860px) {
    .search-filter-row {
        grid-template-columns: 1fr;
    }
    .search-submit-cell {
        white-space: normal;
    }
}

.detail-list { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1rem; }
.detail-list dt { font-weight: 700; }
.detail-list dd { margin: 0; }
.small-button { padding: 0.25rem 0.5rem; font-size: 0.9rem; }
.danger-zone { border-color: #c0392b; }

/* Release 1.3.2d: keep the search folder filter usable on large workspaces. */
.search-filter-tree {
    max-height: 24rem;
    overflow: auto;
}

.search-scope-clear {
    margin-left: 1rem;
    margin-bottom: 0.5rem;
}

/* Release 1.4.3 user processing dashboard */
.grid.four {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}
.processing-summary-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}
.processing-history-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}
.processing-history-actions .inline-form {
    margin: 0;
}
.choose-documents-scope-summary {
    margin-top: 0.35rem;
}
.processing-status-line {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    margin: 0.75rem 0;
}
.processing-progress-fill {
    height: 100%;
    background: var(--accent);
    width: 0;
    transition: width 0.4s ease;
}
.processing-job-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    background: #fff;
}
.processing-job-row:last-child { border-bottom: 0; }
.processing-job-row pre {
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 8rem;
    overflow: auto;
}
.processing-status-running { background: #eef4f5; }
.processing-status-paused { background: #fffbeb; }
.badge.success { border-color: #15803d; color: #15803d; }
.badge.warning { border-color: #b45309; color: #b45309; }
.empty-note { padding: 1rem; }

/* Release 1.4.4 processing admin triage dashboard */
.metric-list {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) auto;
    gap: 0.45rem 1rem;
    margin: 0.75rem 0 0;
}
.metric-list dt { color: var(--muted); }
.metric-list dd { margin: 0; font-weight: 700; text-align: right; }
.triage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 0.75rem;
}
.triage-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.85rem;
    background: #f9fafb;
}
.triage-card h3 {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    align-items: center;
    margin: 0 0 0.5rem;
}
.triage-card pre {
    max-height: 8rem;
    overflow: auto;
}
.tab-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin: 0.75rem 0 1rem;
}
.tab-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
    text-decoration: none;
}
.tab-link.active {
    border-color: var(--accent);
    background: var(--accent-light);
    font-weight: 700;
}
.warning-row {
    background: #fffbeb;
}
.badge.danger {
    border-color: var(--danger);
    color: var(--danger);
    background: #fff1f2;
}
.admin-worker-diagnostics table,
.admin-processing-overview table {
    margin-top: 0.75rem;
}

/* Release 1.5 LLM-assisted research */
.llm-claim {
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
    margin-top: 0.75rem;
}
.llm-claim:first-child {
    border-top: 0;
    padding-top: 0;
    margin-top: 0;
}
.llm-evidence-list blockquote {
    margin: 0.5rem 0 1rem;
    padding: 0.75rem 1rem;
    border-left: 4px solid var(--border);
    background: #f9fafb;
}

/* v1.5.1 normal-user UI cleanup */
.site-header {
    gap: 1rem;
    flex-wrap: wrap;
}

.site-header-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-width: 280px;
    flex: 1 1 360px;
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.jamain-brand {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.jamain-brand img {
    display: block;
    height: 34px;
    width: auto;
}

.user-status {
    color: var(--muted);
    font-size: 0.88rem;
    white-space: nowrap;
}

.site-footer {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
}

.workflow-heading {
    align-items: flex-start;
}

.document-workflow-card {
    margin-bottom: 1rem;
}

.workflow-steps {
    display: grid;
    grid-template-columns: repeat(4, minmax(120px, 1fr));
    gap: 0.5rem;
    margin: 1rem 0;
}

.workflow-steps span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.workflow-steps strong {
    display: inline-grid;
    place-items: center;
    width: 1.55rem;
    height: 1.55rem;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 0.85rem;
}

.upload-action-row {
    align-items: center;
}

@media (max-width: 900px) {

    .workflow-steps {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }
}

@media (max-width: 700px) {
    .site-header-main {
        flex-basis: 100%;
    }

    .nav {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .workflow-steps {
        grid-template-columns: 1fr;
    }
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.55rem;
}

.checkbox-row input[disabled] + span {
    opacity: 0.65;
}

.indented-help {
    margin-left: 1.65rem;
}

.compact-actions {
    gap: 0.35rem;
}

.button.small,
button.small {
    padding: 0.35rem 0.55rem;
    font-size: 0.88rem;
}

.job-row-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.processing-status-cancelling {
    background: #fff7dd;
}

@media (max-width: 900px) {
    .job-row-actions {
        justify-content: flex-start;
    }
}

/* Release 1.5.2c processing pagination */
.pagination-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin: 0.75rem 0 1rem;
}

.pagination-controls.bottom {
    margin: 1rem 0 0;
}

.pagination-status {
    color: #4b5563;
    font-size: 0.95rem;
}

.button.disabled,
.button.disabled:hover {
    opacity: 0.55;
    cursor: default;
    pointer-events: none;
}

.source-tree input[data-tree-select].tree-indeterminate,
.source-tree input[data-tree-select]:indeterminate {
    accent-color: #9ca3af;
}

.search-pagination-controls {
    border-top: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
    padding: 0.65rem 0;
}

.search-pagination-controls.bottom {
    border-bottom: 0;
}
.empty-workflow-card {
    border: 1px solid #d5dbe3;
    border-left: 5px solid var(--accent);
    border-radius: 0.75rem;
    background: #f8fafc;
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
}

.empty-workflow-card {
    max-width: 720px;
}

.empty-workflow-card h3 {
    margin-top: 0;
}

/* Release 1.5.2h source setup help */
.message.info { border-color: #2563eb; }
.setup-guide-card code { word-break: break-all; }
.setup-steps { padding-left: 1.5rem; }
.setup-steps li { margin: 0.65rem 0; }

.admin-auto-refresh {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) auto;
    gap: 1rem;
    align-items: center;
}

.admin-refresh-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    justify-content: flex-end;
}

@media (max-width: 760px) {
    .admin-auto-refresh {
        grid-template-columns: 1fr;
    }

    .admin-refresh-controls {
        justify-content: flex-start;
    }
}

/* Release 1.5.2n expanded help content */
.help-command-block {
    background: #111827;
    color: #f9fafb;
    border-radius: 0.5rem;
    padding: 0.9rem 1rem;
    overflow-x: auto;
    white-space: pre;
    font-size: 0.92rem;
    line-height: 1.45;
}

.help-topic-list {
    margin-top: 0.5rem;
}

/* Release 1.8.0 fixed workflow shell */
.fixed-ui-shell {
    position: sticky;
    top: 0;
    z-index: 60;
    background: var(--fixed-shell-bg);
    border-bottom: 1px solid #cbd5e1;
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.06);
}

.fixed-ui-shell .site-header {
    padding: 0.55rem 1.25rem;
    align-items: center;
    background: var(--fixed-shell-panel);
}

.utility-help-button {
    margin-left: 0.35rem;
    border: 1px solid #cbd5e1;
    background: #fff;
}

.utility-help-button::before {
    content: "?";
    display: inline-grid;
    place-items: center;
    width: 1rem;
    height: 1rem;
    margin-right: 0.3rem;
    border-radius: 999px;
    background: var(--accent-light);
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 700;
}

.workflow-nav {
    gap: 0.25rem;
}

.nav-utility-cluster {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.workflow-nav-link.active,
.nav-dropdown > summary.active {
    background: var(--accent-light);
    color: var(--text);
    font-weight: 700;
}

.fixed-ui-shell .licence-banner {
    margin-top: 0;
    margin-bottom: 0;
    padding: 0.5rem 0.65rem;
}

.workflow-container {
    margin-top: 1rem;
}

.global-progress-panel {
    position: fixed;
    left: 50%;
    bottom: 0.75rem;
    transform: translateX(-50%);
    z-index: 70;
    width: calc(100% - 2rem); /* fluid: use all available width (was capped at 1180px) */
    max-height: 35vh;
    overflow: auto;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.22);
}

/* While the fixed progress panel is on screen, reserve scroll space so the
   last page content (e.g. the Upload page's Recent uploads panel) can clear it
   instead of being overlapped. site.js toggles this class only when a panel is
   actually present, so no space is reserved on idle pages. */
body.has-active-progress .workflow-container {
    padding-bottom: calc(35vh + 1.5rem);
}

.global-progress-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    margin-bottom: 0.55rem;
}

.global-progress-list {
    display: grid;
    gap: 0.5rem;
}

.global-progress-job {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(160px, 280px) auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb;
}

.global-progress-job span,
.global-progress-job small {
    display: block;
    color: var(--muted);
}

.global-progress-job progress {
    width: 100%;
    height: 1rem;
}

.site-footer {
    padding-bottom: 1rem;
}

@media (max-width: 900px) {
    .fixed-ui-shell .site-header {
        width: 100%;
        border-left: 0;
        border-right: 0;
        border-radius: 0;
    }

    .global-progress-job {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .fixed-ui-shell {
        position: static;
    }
}

/* Release 1.8.1: workspace workflow selection and quieter quota context. */
.licence-quota-summary.subtle {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.45rem;
    margin: 0.45rem 0 0.75rem;
    font-size: 0.88rem;
}

.licence-quota-summary.subtle .quota-row {
    padding: 0.45rem 0.55rem;
    background: #f8fafc;
}

.licence-quota-summary.subtle .quota-meter {
    height: 0.45rem;
    margin-top: 0.3rem;
}

.licence-quota-summary.subtle .help {
    margin: 0.25rem 0 0;
    font-size: 0.82rem;
}

.scope-summary {
    display: inline-flex;
    gap: 0.45rem;
    align-items: baseline;
    min-height: 2.35rem;
    padding: 0.35rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
}

.compact-row-actions {
    flex-wrap: wrap;
    gap: 0.3rem;
    margin: 0;
}

.compact-row-actions .inline-form {
    margin: 0;
}

/* Release 1.8.1a: workspace edit/invite dialog cleanup. */
.modal-card {
    max-width: 920px;
    margin-left: auto;
    margin-right: auto;
}

.workspace-edit-dialog .button-row {
    margin-top: 0.75rem;
}

.danger-zone {
    border-color: #fecdd3;
    background: #fff7f8;
}

/* Release 1.8.1b: workspace dropdown and persisted workspace state. */
.workspace-switcher-dropdown {
    flex: 0 1 auto;
}

.workspace-switcher-summary {
    max-width: min(34vw, 360px);
    border: 1px solid #cbd5e1;
    background: #fff;
}

.workspace-switcher-summary strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.workspace-switcher-prefix {
    margin-right: 0.35rem;
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.workspace-switcher-menu {
    left: 0;
    right: auto;
    min-width: min(360px, calc(100vw - 2rem));
}

.nav-dropdown-heading {
    padding: 0.35rem 0.65rem 0.25rem;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.workspace-switcher-option {
    display: grid;
    gap: 0.12rem;
}

.workspace-switcher-option span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.workspace-switcher-option small {
    color: var(--muted);
    font-size: 0.78rem;
}

.workspace-switcher-option.active {
    background: var(--accent-light);
    color: var(--text);
    font-weight: 700;
}

.workspace-switcher-menu hr {
    width: 100%;
    margin: 0.35rem 0;
    border: 0;
    border-top: 1px solid var(--border);
}

@media (max-width: 900px) {
    .workspace-switcher-summary {
        max-width: 100%;
    }
}

/* Release 1.8.1c: current workspace now lives in the Workspace dropdown only. */
.workflow-container {
    margin-top: 0.85rem;
}

.transfer-notice {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1200;
    max-width: min(460px, calc(100vw - 2rem));
    background: #0f172a;
    color: #fff;
    padding: 0.6rem 0.9rem;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.35);
    font-size: 0.9rem;
    line-height: 1.4;
    text-align: center;
}

.ask-form textarea {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 0.6rem;
}

.ask-preparing {
    margin: 0.6rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
    animation: ask-preparing-pulse 1.4s ease-in-out infinite;
}

.ask-preparing::before {
    content: "● ";
    color: var(--accent, #2563eb);
}

@keyframes ask-preparing-pulse {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 1; }
}

.conversation-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.conversation-list-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: baseline;
    flex-wrap: wrap;
}

.conversation-thread {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-turn {
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.chat-turn:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.chat-role {
    display: inline-block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin-bottom: 0.2rem;
}

.chat-question {
    background: var(--accent-light);
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    margin-bottom: 0.6rem;
}

.chat-question p {
    margin: 0;
}

.chat-answer {
    padding: 0 0.2rem;
}

.transfer-notice[hidden] {
    display: none;
}

.share-link-list {
    list-style: none;
    margin: 0 0 0.75rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.share-link-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.share-link-url {
    flex: 1 1 320px;
    min-width: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85rem;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #f8fafc;
}

.share-link-meta {
    flex: 0 0 auto;
}

.inline-summary-overview {
    margin: 0.15rem 0 0.6rem;
    line-height: 1.5;
}

/* Floating, non-cited summary preview shown on hover over a search-result title. */
.doc-summary-popup {
    position: absolute;
    z-index: 1000;
    max-width: 22rem;
    padding: 0.6rem 0.75rem;
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.18);
    font-size: 0.85rem;
    line-height: 1.45;
    /* Let the pointer pass through so moving toward the popup doesn't fight the
       trigger's mouseout; the popup is a read-only preview. */
    pointer-events: none;
}

.doc-summary-popup[hidden] {
    display: none;
}

.doc-summary-popup .doc-summary-popup-label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted, #64748b);
}

/* Release 1.8.2a: 100-row paging controls for the Documents explorer. */
.document-list-pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin: 0.5rem 0 0.75rem;
}

.document-list-pager-bottom {
    margin: 0.75rem 0 0;
}

.document-list-range {
    color: var(--muted);
    font-size: 0.9rem;
}

.document-list-pager-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.button.disabled,
.button[aria-disabled="true"] {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

@media (max-width: 700px) {
    .document-list-pager {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* Release 1.8.2b: virtual folder controls. */
.folder-inline-form {
    margin: 0.6rem 0;
}

.folder-inline-form label {
    display: block;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 0.25rem;
}

.folder-inline-controls {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.folder-inline-controls input[type="text"] {
    min-width: 0;
    flex: 1 1 auto;
    padding: 0.45rem;
    border: 1px solid var(--border);
    border-radius: 6px;
}

button.small,
.button.small {
    padding: 0.35rem 0.55rem;
    font-size: 0.86rem;
}

/* Release 1.8.3: upload page cleanup and two-row fixed header. */
.fixed-ui-shell .site-header {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.45rem;
}

.fixed-ui-shell .site-header-main {
    width: 100%;
    flex: none;
}

.fixed-ui-shell .workflow-nav {
    width: 100%;
    justify-content: flex-start;
}

.upload-layout {
    display: grid;
    grid-template-columns: minmax(320px, 2fr) minmax(260px, 1fr);
    gap: 1rem;
    align-items: start;
}

.upload-page-heading {
    margin-bottom: 1rem;
}

.upload-sources-card {
    position: sticky;
    top: 6.4rem;
}

.upload-source-item {
    display: grid;
    gap: 0.45rem;
    padding: 0.75rem 0;
    border-top: 1px solid var(--border);
}

.upload-source-item:first-of-type {
    border-top: 0;
}

.upload-source-item.primary {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
    padding: 0.75rem;
    margin: 0.75rem 0;
}

.upload-source-item span {
    display: block;
    color: var(--muted);
    font-size: 0.9rem;
}

.upload-transfer-progress-panel {
    max-height: none;
}

.upload-transfer-progress-job {
    grid-template-columns: minmax(220px, 1fr) minmax(160px, 280px) auto;
}

.upload-transfer-progress-meter {
    align-self: center;
}

@media (max-width: 900px) {
    .upload-layout {
        grid-template-columns: 1fr;
    }
    .upload-sources-card {
        position: static;
    }
    .upload-transfer-progress-job {
        grid-template-columns: 1fr;
    }
}

/* Release 1.8.3a: compact account status and upload source cleanup. */
.global-account-status-panel {
    position: fixed;
    left: 50%;
    bottom: 0.75rem;
    transform: translateX(-50%);
    z-index: 70;
    width: calc(100% - 2rem); /* fluid: use all available width (was capped at 1180px) */
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
}

.global-account-status-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
    font-size: 0.9rem;
}

.global-account-status-row a {
    margin-left: auto;
    white-space: nowrap;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: var(--text);
    font-size: 0.84rem;
    white-space: nowrap;
}

.status-pill.ok,
.status-pill.override {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.status-pill.warning {
    border-color: #fde68a;
    background: #fffbeb;
}

.status-pill.danger {
    border-color: #fecaca;
    background: #fef2f2;
}

.compact-warning {
    align-self: center;
    margin: 0;
    font-size: 0.9rem;
}

.site-footer {
    padding-bottom: 3.8rem;
}

@media (max-width: 800px) {
    .global-account-status-panel {
        border-radius: 12px;
    }
    .global-account-status-row {
        gap: 0.4rem;
    }
    .global-account-status-row a {
        margin-left: 0;
    }
}

/* Release 1.8.3c: workspace source selection and scroll-preserving navigation. */
.workspace-source-selection {
    display: grid;
    gap: 0.5rem;
    margin: 0.75rem 0;
}

.workspace-source-choice {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: #fff;
}

.workspace-source-choice input {
    margin-top: 0.15rem;
}

.workspace-source-table {
    margin-top: 1rem;
}

/* Release 1.8.4 processing workflow simplification */
.processing-scope-card {
    margin-bottom: 1rem;
}

.processing-scope-form .form-grid {
    margin-bottom: 0.75rem;
}

.processing-action-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
}

.processing-action-form {
    margin-top: auto;
}

.compact-metrics {
    margin-top: 0;
}

.compact-metrics dt,
.compact-metrics dd {
    padding: 0.2rem 0;
}

.processing-current-card {
    margin-bottom: 1.5rem;
}

.processing-current-card .processing-job-row .help {
    margin-bottom: 0;
}

.form-grid.three {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

/* Release 1.8.5 admin/setup consolidation */
.admin-nav-menu {
    min-width: 260px;
}

.admin-nav-menu hr {
    width: 100%;
    border: 0;
    border-top: 1px solid var(--border);
    margin: 0.25rem 0;
}

.admin-setup-grid .card,
.setup-action-card {
    min-height: 100%;
}

.setup-action-card h2 {
    margin-bottom: 0.35rem;
}

.compact-workflow-steps {
    margin: 0.75rem 0;
}

.setup-guide-card details > summary {
    cursor: pointer;
    color: var(--accent);
}

.top-gap {
    margin-top: 1rem;
}

/* Release 1.8.6 search/research/AI/intelligence workflow cleanup */
.analysis-page-heading h1 {
    margin-bottom: 0.2rem;
}

.analysis-step-card,
.analysis-filter-card {
    margin-bottom: 1rem;
}

.analysis-step-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.analysis-step-heading h2 {
    margin: 0.25rem 0 0;
}

.analysis-context-banner {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.65rem;
    background: var(--accent-light);
    margin-bottom: 0.75rem;
}
.analysis-metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.compact-metadata {
    margin-top: 0.75rem;
}

.analysis-summary-preview {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.65rem;
    background: #fff;
}

.save-search-inline {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.save-search-inline input[type="text"] {
    min-width: 260px;
    padding: 0.45rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.metric-card {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.metric-card strong {
    font-size: 2rem;
    line-height: 1;
}

.metric-label {
    color: var(--muted);
    font-size: 0.9rem;
}

.intelligence-filter-form {
    flex-wrap: wrap;
}

.intelligence-overview-grid .card p {
    margin: 0.35rem 0;
}

@media (max-width: 760px) {
    .analysis-step-heading,
    .analysis-page-heading,
    .page-heading.analysis-page-heading {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* Release 1.8.6b shared choose-documents and research dialog cleanup */
.choose-documents-panel {
    margin-bottom: 1rem;
}

.compact-search-row {
    grid-template-columns: minmax(280px, 1fr) auto;
}

.workflow-dialog {
    width: min(1100px, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    border: none;
    border-radius: 1rem;
    padding: 0;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.3);
}

.workflow-dialog::backdrop {
    background: rgba(15, 23, 42, 0.45);
}

.workflow-dialog .modal-card {
    margin: 0;
    max-height: calc(100vh - 2rem);
    overflow: auto;
}

.dialog-actions {
    justify-content: flex-end;
    margin-top: 1rem;
}

/* Release 1.8.6l processing enrichment preview */
.enrichment-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 0.6rem;
}

.enrichment-preview-box {
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.7rem;
    background: var(--accent-light);
}

.enrichment-preview-box strong,
.enrichment-preview-box span {
    display: block;
}

.enrichment-preview-box span {
    color: var(--muted);
    margin-top: 0.25rem;
}

.enrichment-preview-box.warning-box {
    border-color: #b45309;
}

/* Release 1.8.6p: consolidated document-detail intelligence panel. */
.document-intelligence-panel .page-heading {
    margin-bottom: 0.75rem;
}

.document-intelligence-section {
    border-top: 1px solid var(--border);
    margin-top: 1rem;
    padding-top: 1rem;
}

.document-intelligence-section h3 {
    margin-top: 0;
}

.citation-panel {
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-top: 0.65rem;
    padding: 0.55rem 0.75rem;
}

.citation-panel > summary {
    cursor: pointer;
    color: var(--accent);
    font-weight: 600;
}

.citation-panel[open] > summary {
    margin-bottom: 0.5rem;
}

.compact-metadata {
    margin-bottom: 0.75rem;
}

/* Release 2.7.1: collapsible document-detail panels and denser Word text. */
.collapsible-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.collapsible-title-row {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
}

.collapsible-title-row h2 {
    margin: 0;
}

.panel-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.85rem;
    height: 1.85rem;
    padding: 0;
    border-radius: 999px;
    border-color: var(--border);
    background: #fff;
    color: var(--accent);
    line-height: 1;
    flex: 0 0 auto;
}

.panel-toggle:hover,
.panel-toggle:focus {
    background: var(--accent-light);
    opacity: 1;
}

.panel-toggle .toggle-icon {
    display: inline-block;
    font-size: 1rem;
    transform-origin: center;
}

.collapsible-panel.is-collapsed .collapsible-content {
    display: none;
}

.collapsible-panel.is-collapsed .panel-toggle .toggle-icon {
    transform: rotate(-90deg);
}

.collapsible-content {
    margin-top: 0.75rem;
}

.document-intelligence-panel .collapsible-content > .help:first-child {
    margin-top: 0;
}

.word-text-panel .collapsible-content {
    margin-top: 0.55rem;
}

.word-paragraph {
    margin-top: 0.65rem;
    padding-top: 0.65rem;
}

.word-paragraph-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.85rem;
    align-items: baseline;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
}

.word-paragraph-meta strong {
    color: var(--text);
}

.word-paragraph-meta span {
    color: var(--muted);
}

.extract-page .word-paragraph-text {
    margin: 0;
    padding: 0.65rem 0.75rem;
    max-height: 14rem;
    font-size: 0.92rem;
    line-height: 1.38;
}

@media (max-width: 760px) {
    .collapsible-heading {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* Release 2.7.2: default-collapsed document-detail panels and denser Word table display. */
.word-tables-panel .collapsible-content {
    margin-top: 0.55rem;
}

.table-extract-panel {
    margin-top: 0.65rem;
    padding-top: 0.65rem;
}

.table-panel-heading,
.table-subpanel-heading {
    align-items: center;
}

.table-title-row h3,
.table-subpanel-heading h4 {
    margin: 0;
}

.table-heading-meta {
    color: var(--muted);
    font-size: 0.88rem;
}

.small-toggle {
    width: 1.45rem;
    height: 1.45rem;
}

.small-toggle .toggle-icon {
    font-size: 0.85rem;
}

.table-panel-content {
    margin-top: 0.45rem;
}

.table-meta-line {
    margin: 0 0 0.45rem;
}

.table-subpanel {
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-top: 0.5rem;
    padding: 0.55rem 0.65rem;
}

.table-subpanel-content {
    margin-top: 0.45rem;
}

.table-toolbar,
.table-summary-form {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.4rem 0.65rem;
    margin-bottom: 0.45rem;
}

.compact-table-toolbar .help {
    margin: 0;
}

.extracted-table-cells {
    font-size: 0.86rem;
}

.extracted-table-cells th,
.extracted-table-cells td {
    padding: 0.25rem 0.35rem;
}

.extracted-table-cells td:first-child,
.extracted-table-cells th:first-child {
    white-space: nowrap;
    width: 5.5rem;
}

.extracted-table-cells .citation {
    font-size: 0.82rem;
}

.table-summary-text {
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #f9fafb;
    padding: 0.55rem 0.65rem;
    margin-top: 0.45rem;
    font-size: 0.92rem;
    line-height: 1.4;
}

/* Release 2.7.5 inline table summary detail */
.summary-detail-subpanel {
    margin-top: 0.55rem;
}

.inline-summary-detail h5 {
    margin: 0.65rem 0 0.35rem;
    font-size: 0.9rem;
}

.inline-summary-detail h5:first-child {
    margin-top: 0;
}

.inline-summary-metadata {
    margin: 0 0 0.55rem;
    font-size: 0.86rem;
}

.inline-llm-claim {
    padding-top: 0.5rem;
    margin-top: 0.5rem;
}

.inline-llm-claim p {
    margin: 0.25rem 0;
}

.inline-evidence-list {
    margin-top: 0.35rem;
    padding-left: 1.25rem;
}

.inline-evidence-list p {
    margin: 0.2rem 0;
}

.inline-evidence-list blockquote {
    margin: 0.3rem 0 0.6rem;
    padding: 0.45rem 0.65rem;
    font-size: 0.86rem;
}

.compact-list {
    margin-top: 0.25rem;
    margin-bottom: 0.5rem;
}

/* Release 2.7.6: compact Search evidence layout and duplicate-copy path disclosure. */
.search-page-heading {
    margin-bottom: 0.8rem;
}

.choose-documents-panel.collapsible-panel .processing-summary-header{
    align-items: flex-start;
}

.choose-documents-panel.collapsible-panel h2,
.compact-search-heading h2,
.compact-results-heading h2 {
    margin: 0;
}

.choose-documents-panel.collapsible-panel .help,
.compact-search-heading .help,
.compact-results-heading .help,
.compact-help {
    margin: 0.2rem 0 0;
}

.compact-banner {
    margin-bottom: 0.65rem;
    padding: 0.65rem 0.8rem;
}

.compact-search-card {
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
}

.compact-search-heading {
    margin-bottom: 0.55rem;
}

.single-search-row {
    grid-template-columns: minmax(260px, 1fr) auto;
    gap: 0.55rem;
}

.compact-search-form input[type="search"] {
    padding: 0.42rem 0.5rem;
}

.search-actions-inline {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.compact-save-search-inline {
    margin: 0;
    gap: 0.4rem;
}

.compact-save-search-inline input[type="text"] {
    min-width: 220px;
    padding: 0.35rem 0.45rem;
}

.compact-document-search-result {
    margin-top: 0.65rem;
    padding-top: 0.65rem;
}

.compact-search-result-header {
    gap: 0.65rem;
}

.compact-search-result-header h3 {
    margin: 0;
    font-size: 1.02rem;
}

.compact-result-actions {
    justify-content: flex-end;
}

.search-duplicate-paths {
    margin-top: 0.35rem;
    font-size: 0.88rem;
}

.search-duplicate-paths summary {
    cursor: pointer;
    color: var(--accent);
    font-weight: 700;
}

.search-duplicate-paths ul {
    margin: 0.35rem 0 0;
    padding-left: 1.2rem;
}

.search-duplicate-paths li {
    margin: 0.2rem 0;
}

.search-duplicate-paths code {
    overflow-wrap: anywhere;
}

.search-duplicate-paths span {
    color: var(--muted);
    font-size: 0.84rem;
}

.compact-search-hit-list {
    padding: 0 0.7rem 0.55rem 1.7rem;
}

.compact-search-hit {
    padding: 0.5rem 0;
}

.compact-search-hit-main {
    gap: 0.45rem;
}

.compact-select-row {
    font-size: 0.84rem;
}

.compact-search-snippet {
    margin: 0.35rem 0;
    line-height: 1.35;
}

.search-hit-footer {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.search-hit-footer .citation {
    margin: 0;
}

.compact-copy-button {
    margin: 0;
}

@media (max-width: 760px) {
    .single-search-row {
        grid-template-columns: 1fr;
    }

    .compact-result-actions {
        justify-content: flex-start;
    }
}

.source-preview-panel {
    margin-bottom: 1rem;
}

.source-preview-panel h2,
.source-preview-panel h3,
.source-preview-panel h4 {
    margin-top: 0.6rem;
    margin-bottom: 0.4rem;
}

.compact-metadata dt,
.compact-metadata dd {
    padding-top: 0.15rem;
    padding-bottom: 0.15rem;
}

.source-preview-paragraph {
    border-bottom: 1px solid #e5e7eb;
    padding: 0.35rem 0;
}

.source-preview-paragraph:last-child {
    border-bottom: 0;
}

.source-preview-paragraph p {
    margin: 0.2rem 0;
}

.compact-table-scroll {
    margin-top: 0.35rem;
}

.compact-data-table th,
.compact-data-table td {
    padding: 0.25rem 0.4rem;
    vertical-align: top;
}

.source-spreadsheet-preview-table th[scope="row"] {
    white-space: nowrap;
    width: 1%;
}

.source-preview-text pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    margin: 0;
    max-height: 70vh;
    overflow: auto;
}

/* AI-assisted search toggle and interpretation line. */
.search-ai-toggle {
    margin: 0.4rem 0 0.2rem;
    font-size: 0.9rem;
}

.search-mode-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
}

.search-mode-label {
    font-weight: 600;
    color: var(--text);
}

.search-mode-row label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--text);
    cursor: pointer;
}

.search-mode-help {
    flex: 1 1 18rem;
    margin: 0;
}

.search-ai-toggle label {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--muted);
    cursor: pointer;
}

.search-ai-interpretation {
    margin-top: 0.25rem;
}

.search-ai-interpretation strong {
    color: var(--text);
}

.search-ai-answer {
    border-left: 3px solid var(--accent);
}

.search-hit-ai-reason {
    margin: 0.15rem 0 0;
    font-style: italic;
}

/* Release 2.7.13 Processing page and aggregate progress cleanup. */
.compact-global-progress-panel {
    max-height: 22vh;
    padding: 0.6rem 0.75rem;
}

.compact-progress-header {
    align-items: center;
    margin-bottom: 0.35rem;
}

.compact-progress-header > div:first-child {
    display: flex;
    gap: 0.6rem;
    align-items: baseline;
    flex-wrap: wrap;
}

.global-progress-actions {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.global-progress-counts {
    color: var(--muted);
    font-size: 0.92rem;
}

.global-progress-meter {
    width: 100%;
    height: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #f3f4f6;
    overflow: hidden;
}

.global-progress-meter-fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.4s ease;
}

.global-progress-details {
    margin-top: 0.35rem;
}

.global-progress-details > summary {
    cursor: pointer;
    color: var(--muted);
    font-size: 0.9rem;
}

.compact-global-progress-list {
    margin-top: 0.35rem;
}

.compact-global-progress-job {
    grid-template-columns: minmax(220px, 1fr) auto;
    padding: 0.35rem 0.45rem;
}

.compact-global-progress-job span {
    font-size: 0.9rem;
}

.processing-current-card.collapsible-panel .processing-summary-header {
    margin-bottom: 0;
}

@media (max-width: 900px) {
    .compact-progress-header,
    .global-progress-actions {
        align-items: flex-start;
        justify-content: flex-start;
    }

    .compact-global-progress-job {
        grid-template-columns: 1fr;
    }
}

/* Release 2.7.14: processing/search history split and compact history tables. */
.compact-table-heading,
.processing-history-table-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.compact-table-heading h2,
.processing-history-table-heading h2 {
    margin-bottom: 0.15rem;
}

.compact-pagination-controls {
    margin: 0;
    gap: 0.45rem;
}

.compact-history-table th,
.compact-history-table td {
    padding-top: 0.42rem;
    padding-bottom: 0.42rem;
    vertical-align: top;
}

.icon-button.open-document-button {
    min-width: 2rem;
    padding-left: 0.55rem;
    padding-right: 0.55rem;
    text-align: center;
    font-weight: 700;
}

.recent-searches-panel {
    margin-top: 1rem;
}

/* Intelligence review: highlight metrics and documents that need a human look. */
.metric-card-attention {
    border-color: var(--warning-border, #e0a93f);
    background: var(--warning-surface, #fdf6e7);
}

.intelligence-attention-banner {
    display: block;
    border-left: 3px solid var(--warning-border, #e0a93f);
}

.intelligence-missing-figure-list {
    margin: 0.4rem 0 0;
    padding-left: 1.1rem;
}

/* Sticky "gather then file" tray for adding selected search hits to a research
   pack. Pinned to the bottom of the viewport while the results scroll, so the
   action stays with the selection instead of a hidden panel at the top. */
.research-pack-tray {
    position: sticky;
    bottom: 0;
    z-index: 50;
    margin-top: 1.2rem;
    background: var(--surface, #ffffff);
    border: 1px solid var(--border-subtle, #d9d9e3);
    border-bottom: none;
    border-radius: 10px 10px 0 0;
    box-shadow: 0 -6px 18px rgba(20, 20, 40, 0.10);
    padding: 0.65rem 0.95rem;
}

.research-pack-tray-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem 1.1rem;
}

.research-pack-tray-status {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 12rem;
}

.research-pack-tray-actions,
.research-pack-tray-target-fields {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.research-pack-tray-target-fields select,
.research-pack-tray-target-fields input[type="text"] {
    max-width: 16rem;
}

.research-pack-tray .new-pack-title-fields[hidden] {
    display: none;
}

@media (max-width: 900px) {
    .research-pack-tray-inner {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Inline answer panel shown under each saved-search row, in place of the old
   "Open" button that navigated away to the research run detail page. */
.run-answer-row > td {
    padding-top: 0;
    padding-bottom: 0.6rem;
    border-top: none;
}

.run-answer-details {
    border: 1px solid var(--border-subtle, #d9d9e3);
    border-radius: 6px;
    background: var(--surface-muted, #f7f7fb);
    padding: 0.2rem 0.7rem;
}

.run-answer-details > summary {
    cursor: pointer;
    font-weight: 600;
    padding: 0.35rem 0;
    color: var(--accent, #3a3a8c);
}

.run-answer-details[open] > summary {
    margin-bottom: 0.4rem;
    border-bottom: 1px solid var(--border-subtle, #d9d9e3);
}

.run-answer-body h4 {
    margin: 0.7rem 0 0.3rem;
    font-size: 0.92rem;
}

.run-answer-body .run-answer-limitations {
    margin-top: 0;
}

.run-answer-fullpage {
    margin-top: 0.7rem;
    font-size: 0.88rem;
}

@media (max-width: 900px) {
    .compact-table-heading,
    .processing-history-table-heading {
        flex-direction: column;
    }
}

/* Navigation busy indicator: shown briefly while a page is loading. */
.page-loading-indicator {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.35);
    z-index: 10000;
    pointer-events: none;
}
.page-loading-indicator.active {
    display: flex;
}
.page-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 0, 0, 0.15);
    border-top-color: rgba(0, 0, 0, 0.55);
    border-radius: 50%;
    animation: page-loading-spin 0.7s linear infinite;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12);
}
@keyframes page-loading-spin {
    to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
    .page-loading-spinner { animation-duration: 1.6s; }
}

/* Processing pipeline: three numbered steps stacked in one panel. */
.processing-pipeline-card .processing-step {
    padding: 1rem 0;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}
.processing-pipeline-card .processing-step:first-of-type {
    border-top: none;
    padding-top: 0.5rem;
}
.processing-step-header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}
.processing-step-header h3 {
    margin: 0;
}
.processing-step-number {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.08);
    font-weight: 600;
    line-height: 1;
}
.processing-run-all {
    border: 1px solid var(--accent, #2f6f4f);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    background: rgba(47, 111, 79, 0.05);
    margin-bottom: 1rem;
}
.processing-run-all .processing-step-number {
    background: var(--accent, #2f6f4f);
    color: #fff;
}
.processing-history-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Reusable confirmation popup (progressive enhancement over a confirm page). */
.sl-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}
.sl-modal-overlay[hidden] {
    display: none;
}
.sl-modal-dialog {
    background: var(--surface, #ffffff);
    color: var(--text, #1a1a1a);
    border-radius: 8px;
    padding: 1.5rem;
    max-width: 32rem;
    width: 100%;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}
.sl-modal-dialog h2 {
    margin-top: 0;
}

/* Content-only view (a link opened in a new tab): a slim bar instead of the full app
   chrome, so the tab shows just the content and never looks like a second copy of the app. */
.content-view-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 1rem;
    background: var(--fixed-shell-bg);
    border-bottom: 1px solid var(--border);
}
.content-view-brand {
    font-weight: 600;
    color: var(--accent);
}
.content-view-main {
    padding-top: 1rem;
    padding-bottom: 2rem;
} .sv-children { list-style: none; margin: 0; padding-left: 1.25rem; }
.sv-node { margin: 0.15rem 0; }
.sv-node-head { display: flex; align-items: center; gap: 0.5rem; padding: 0.2rem 0.35rem; border-radius: 4px; }
.sv-node-head:hover { background: rgba(0,0,0,0.03); }
.sv-node-name { font-weight: 600; }
.sv-node-count { font-size: 0.8rem; color: #6b7280; background: #f1f5f9; border-radius: 999px; padding: 0 0.5rem; }
.sv-docs { list-style: none; margin: 0.1rem 0 0.3rem 1.25rem; padding: 0; }
.sv-doc { display: flex; align-items: center; gap: 0.5rem; padding: 0.1rem 0; font-size: 0.92rem; }
.sv-badge { font-size: 0.72rem; padding: 0.05rem 0.4rem; border-radius: 999px; white-space: nowrap; }
.sv-badge-hand { background: #fef3c7; color: #92400e; }
.sv-badge-overlap { background: #e0e7ff; color: #3730a3; }
.view-list { list-style: none; padding: 0; margin: 1rem 0; }
.view-list-item { display: flex; align-items: center; gap: 0.6rem; padding: 0.4rem 0; border-bottom: 1px solid #eef2f7; }
.create-view-form { display: flex; gap: 0.5rem; margin-top: 1rem; }
.create-view-form input[type=text] { flex: 1; max-width: 380px; }

/* Saved-view builder */
.sv-add { margin: 1rem 0; border: 1px solid #e5e7eb; border-radius: 6px; padding: 0.5rem 0.75rem; }
.sv-add summary { cursor: pointer; font-weight: 600; }
.sv-add-form { margin-top: 0.75rem; }
.sv-node-remove { margin-left: 0.5rem; font-size: 0.75rem; color: #b91c1c; opacity: 0; transition: opacity 0.1s; }
.sv-node-head:hover .sv-node-remove { opacity: 1; }

.sv-split-form { display: flex; align-items: center; gap: 0.6rem; margin: 0.25rem 0 1rem; flex-wrap: wrap; font-size: 0.9rem; }
.sv-preview { display: inline-block; margin-left: 0.4rem; font-size: 0.8rem; }

/* Split-pane document browser */
.browser { display: grid; grid-template-columns: 340px 1fr; height: calc(100vh - 180px); min-height: 420px; border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; }
.browser-tree { overflow-y: auto; border-right: 1px solid #e5e7eb; background: #fafafa; padding: 0.5rem 0.6rem; }
.browser-tree-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; padding: 0.25rem 0.35rem 0.5rem; border-bottom: 1px solid #eef2f7; margin-bottom: 0.4rem; }
.browser-list { list-style: none; margin: 0; padding: 0; }
.browser-list .browser-list { padding-left: 0.9rem; }
.browser-folder > details > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 0.35rem; padding: 0.2rem 0.35rem; border-radius: 4px; font-weight: 600; font-size: 0.9rem; }
.browser-folder > details > summary::-webkit-details-marker { display: none; }
.browser-folder > details > summary:hover { background: rgba(0,0,0,0.04); }
.browser-doc { display: flex; align-items: center; gap: 0.4rem; width: 100%; text-align: left; background: none; border: 0; padding: 0.25rem 0.4rem; border-radius: 4px; cursor: pointer; font-size: 0.88rem; color: #1f2937; }
.browser-doc:hover { background: rgba(37,99,235,0.08); }
.browser-doc.active { background: #2563eb; color: #fff; }
.browser-doc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.browser-empty { padding: 1rem 0.5rem; }
.browser-view { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.browser-view-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.5rem 0.75rem; border-bottom: 1px solid #e5e7eb; }
.browser-view-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.browser-view-body { position: relative; flex: 1; min-height: 0; }
.browser-view-frame { width: 100%; height: 100%; border: 0; }
.browser-view-placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #6b7280; padding: 2rem; text-align: center; }
.browser-view-panel { position: absolute; inset: 0; overflow-y: auto; padding: 1.25rem 1.5rem; color: #1f2937; }
.browser-view-selector { display: flex; align-items: center; gap: 0.4rem; }
.browser-view-selector-label { font-size: 0.8rem; color: #6b7280; font-weight: 600; }
.browser-view-selector select { font-size: 0.85rem; padding: 0.2rem 0.35rem; border: 1px solid #d1d5db; border-radius: 4px; background: #fff; max-width: 220px; }
/* The hidden attribute must win over the absolute-overlay display:flex, or the placeholder/message
   stays on top of the iframe and blocks scrolling and clicks. */
.browser-view-placeholder[hidden], .browser-view-panel[hidden] { display: none; }
.browser-tree-head { flex-direction: column; align-items: stretch; gap: 0.4rem; }
.browser-tree-head-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.detail-panel { max-width: 720px; }
.detail-panel-title { margin: 0 0 0.25rem; font-size: 1.15rem; }
.detail-panel-note { margin: 0 0 1rem; font-size: 0.85rem; }
.detail-panel-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem 1.5rem; margin: 0 0 1rem; }
.detail-panel-meta > div { display: flex; gap: 0.5rem; }
.detail-panel-meta dt { font-weight: 600; color: #6b7280; min-width: 4.5rem; }
.detail-panel-meta dd { margin: 0; }
.detail-panel-section { margin: 0 0 1rem; }
.detail-panel-section h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: #6b7280; margin: 0 0 0.35rem; }
.detail-panel-section ul { margin: 0; padding-left: 1.1rem; }
.detail-panel-preview { white-space: pre-wrap; font-size: 0.85rem; color: #374151; background: #f9fafb; border: 1px solid #eef2f7; border-radius: 6px; padding: 0.75rem; max-height: 260px; overflow-y: auto; }
.browser-edit-toggle { font-size: 0.8rem; font-weight: 600; color: #2563eb; white-space: nowrap; }
.sv-builder { max-width: 640px; }
.sv-builder-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.sv-builder-title { font-size: 1.05rem; margin: 0; }
.sv-builder form { background: #f9fafb; border: 1px solid #eef2f7; border-radius: 8px; padding: 0.85rem 1rem; margin-bottom: 1rem; }
.sv-builder form h3 { margin: 0 0 0.5rem; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; color: #6b7280; }
.sv-builder label { display: block; margin-bottom: 0.6rem; font-size: 0.85rem; font-weight: 600; }
.sv-builder input[type=text], .sv-builder select { width: 100%; padding: 0.3rem 0.4rem; border: 1px solid #d1d5db; border-radius: 4px; font-weight: 400; }
.sv-builder .sv-split-form label { font-weight: 400; }
.sv-builder-tree ul { list-style: none; margin: 0.25rem 0 0; padding-left: 0.9rem; }
.sv-builder-tree h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; color: #6b7280; }
.sv-builder-node-name { font-weight: 600; }
.sv-preview { font-size: 0.8rem; margin: 0 0 0.6rem; min-height: 1.1em; }
.browser-add-docs { display: block; text-align: center; margin-top: 0.4rem; font-size: 0.85rem; }
.browser-folder-summary { display: flex; align-items: center; gap: 0.35rem; }
.browser-folder-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.browser-folder-tag { flex: none; font-size: 0.7rem; padding: 0.1rem 0.4rem; border: 1px solid #d1d5db; border-radius: 4px; background: #fff; color: #2563eb; cursor: pointer; opacity: 0; transition: opacity 0.12s; }
.browser-folder-summary:hover .browser-folder-tag, .browser-folder-tag:focus { opacity: 1; }
.sv-split-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.4rem; }
.sv-split-hint { font-size: 0.78rem; margin: 0.4rem 0 0; }
.browser-review-link { display: block; text-align: center; margin-top: 0.4rem; font-size: 0.85rem; background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.browser-review-link { font-size: 0.8rem; font-weight: 600; color: #b45309; white-space: nowrap; }
.link-button.danger { color: #b91c1c; background: transparent; border: 0; }
.tag-mode-form { margin: 0.5rem 0 0.25rem; }
.tag-mode-form select { margin-left: 0.4rem; }
.classify-group { margin: 1.5rem 0 2rem; }
.classify-group > h2 { margin-bottom: 0.25rem; }
.classify-group-intro { margin-top: 0; max-width: 60rem; }
.classify-group-types .classify-block { border-left: 3px solid #2c5f6f; }
.trust-dial-form { margin: 0.5rem 0 0.25rem; }
.trust-dial-form select { margin-left: 0.4rem; }
.trust-dial-form .trust-threshold { width: 4.5rem; }
.classify-reset { margin-top: 1rem; }
.classify-block { border: 1px solid #eef2f7; border-radius: 10px; padding: 1rem 1.25rem; margin: 1rem 0; background: #fbfcfe; }
.classify-block h2 { margin-top: 0; font-size: 1.05rem; }
.classify-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.classify-actions form { margin: 0; }
.classify-note { margin-top: 1rem; }
.browser-tree-controls { display: flex; gap: 0.4rem; align-items: center; padding: 0.25rem 0.5rem 0; font-size: 0.85rem; }
.classify-state { margin: 0.25rem 0 0.5rem; }
.untag-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.untag-body { display: flex; gap: 1rem; height: 70vh; min-height: 420px; }
.untag-list { flex: 0 0 240px; overflow-y: auto; list-style: none; margin: 0; padding: 0; border: 1px solid #e5e7eb; border-radius: 8px; }
.untag-list li { border-bottom: 1px solid #f1f5f9; }
.untag-row { display: block; width: 100%; text-align: left; padding: 0.5rem 0.6rem; background: transparent; border: 0; cursor: pointer; font-size: 0.9rem; color: var(--text); }
.untag-row:hover { background: #f6faff; }
.untag-row.active { background: #e3f0ff; font-weight: 600; color: var(--text); }
.untag-row.done { color: #9ca3af; text-decoration: line-through; }
.untag-preview { flex: 1 1 auto; border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; display: flex; }
.untag-frame { width: 100%; height: 100%; border: 0; }
.untag-placeholder { margin: auto; color: #6b7280; padding: 1rem; }
.untag-picker { flex: 0 0 260px; overflow-y: auto; border: 1px solid #e5e7eb; border-radius: 8px; padding: 0.75rem; }
.untag-picker-title { font-weight: 600; margin: 0 0 0.5rem; }
.untag-option { display: block; padding: 0.15rem 0; font-size: 0.9rem; }
.untag-actions { display: flex; gap: 0.4rem; margin-top: 0.75rem; position: sticky; bottom: 0; background: #fff; padding-top: 0.5rem; }
.untag-remaining { margin-top: 0.75rem; }
.untag-group { font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: #6b7280; margin: 0.75rem 0 0.25rem; }
.untag-group:first-child { margin-top: 0; }
.browser-view-main { display: flex; flex: 1; min-height: 0; }
.browser-view-main .browser-view-body { flex: 1; }
.container.container-wide { width: calc(100% - 2rem); max-width: none; }

/* Browse as file manager (source structure, uploaders) */
.browser-folder-acts { display: inline-flex; margin-left: 0.5rem; gap: 0.35rem; opacity: 0.55; }
.browser-folder-summary:hover .browser-folder-acts,
.browser-folder-acts:focus-within { opacity: 1; }
.browser-folder-act { font-size: 0.75rem; padding: 0 0.35rem; border: 1px solid #d7dee8; border-radius: 4px; background: #fff; color: #3b4a5a; cursor: pointer; text-decoration: none; line-height: 1.4; }
.browser-folder-act:hover { background: #eef2f7; }
.browser-folder-act.danger { color: #b91c1c; border-color: #f1c8c8; }
.browser-manage-hint { font-size: 0.78rem; margin: 0.25rem 0 0.5rem; }
.browser-tree [data-folder-drop].drop-target, .browser-tree-head-meta.drop-target { outline: 2px dashed #4c7bd4; outline-offset: 1px; background: #eef4ff; }

/* Drag handle for hand-placing documents in a saved view. The row's button swallows drag
   initiation (form controls do), so dragging starts from this plain span instead. */
.browser-doc-row { display: flex; align-items: center; gap: 0.15rem; }
.browser-doc-drag { cursor: grab; opacity: 0.55; padding: 0 0.15rem; user-select: none; font-size: 0.85rem; color: #3b4a5a; }
.browser-doc-row:hover .browser-doc-drag { opacity: 1; }
.browser-doc-drag:active { cursor: grabbing; }

/* Hover document preview (review queues) */
.doc-preview-popup {
    position: absolute; z-index: 1200; background: #fff; border: 1px solid #c8d2d8;
    border-radius: 6px; box-shadow: 0 6px 24px rgba(20, 40, 50, 0.18); padding: 6px;
    max-width: 432px;
}
.doc-preview-popup img { display: block; max-width: 418px; max-height: 528px; }
.doc-preview-popup .doc-preview-caption { font-size: 0.78rem; color: #5a6a72; padding: 4px 2px 0; }
.preview-readonly-note { font-size: 0.8rem; margin: 0.2rem 0 0.3rem; }

.type-set-form { display: inline-flex; gap: 0.3rem; align-items: center; margin-left: 0.5rem; }
.type-set-form select { max-width: 13rem; }

.create-view-group { margin: 1.25rem 0 1.5rem; }
.create-view-group > h3 { margin-bottom: 0.15rem; }
.create-view-group > .muted { margin-top: 0; max-width: 58rem; }

.source-page-frame { width: 100%; height: 78vh; border: 1px solid #c8d2d8; border-radius: 6px; background: #fff; }
.source-page-heading .source-page-title { overflow-wrap: anywhere; }

/* Custom tagged view designer */
.designer-columns { display: flex; gap: 1.25rem; flex-wrap: wrap; align-items: flex-start; }
.designer-panel { flex: 1 1 30rem; min-width: 24rem; }
.designer-intro { max-width: 62rem; }
.designer-tree { list-style: none; margin: 0.4rem 0; padding-left: 0; }
.designer-subtree { padding-left: 1.4rem; border-left: 1px dashed #ccd6dc; }
.designer-folder-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.2rem 0.3rem; border-radius: 4px; }
.designer-folder-row.drop-hover { background: #e3eef3; outline: 2px dashed #2c5f6f; }
.designer-folder.dragging { opacity: 0.5; }
.designer-drag { cursor: grab; color: #7d8c94; }
.designer-name { font-weight: 600; }
.designer-other > .designer-folder-row .designer-name { color: #5a6a72; }
.designer-dropzone { border: 2px dashed #c8d2d8; border-radius: 6px; padding: 0.45rem 0.7rem; color: #7d8c94; margin: 0.4rem 0 0.9rem; font-size: 0.85rem; }
.designer-dropzone.drop-hover { background: #e3eef3; border-color: #2c5f6f; color: #2c5f6f; }
.designer-add-form { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.designer-add-form input[type=text] { flex: 1 1 12rem; }
.designer-apply-form { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; }
.designer-apply-form .fy-num { width: 4rem; }

/* Triage mode */
.triage-columns { display: flex; gap: 1.25rem; align-items: flex-start; flex-wrap: wrap; }
.triage-doc { flex: 1 1 34rem; min-width: 26rem; }
.triage-doc-title { margin: 0 0 0.2rem; overflow-wrap: anywhere; }
.triage-frame { height: 72vh; }
.triage-buckets { flex: 1 1 20rem; min-width: 18rem; max-width: 30rem; position: sticky; top: 0.75rem; }
.triage-tree { list-style: none; margin: 0.3rem 0; padding-left: 0; }
.triage-subtree { padding-left: 1.2rem; border-left: 1px dashed #ccd6dc; }
.triage-bucket { display: block; width: 100%; text-align: left; background: #f4f7f9; border: 1px solid #d5dee3;
    border-radius: 5px; padding: 0.35rem 0.6rem; margin: 0.15rem 0; cursor: pointer; font-weight: 600;
    color: #1c2b33; /* the global button rule paints #fff — white-on-white without this */ }
.triage-bucket .muted { color: #5a6a72; }
.triage-bucket:hover { background: #e6eef2; }
.triage-bucket.selected { background: #2c5f6f; border-color: #2c5f6f; color: #fff; position: relative; padding-right: 1.9rem; }
.triage-bucket.selected::after { content: "\2713"; position: absolute; right: 0.6rem; top: 50%; transform: translateY(-50%); font-weight: 700; }
.triage-bucket.busy { opacity: 0.55; }
.triage-bucket.selected .muted { color: #d6e4ea; }
.triage-bucket-other { font-weight: 500; }
.triage-scope-head { margin: 0.8rem 0 0.1rem; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: #5a6a72; }
.triage-new-form { display: flex; gap: 0.35rem; flex-wrap: wrap; margin: 0.35rem 0 0.6rem; }
.triage-new-form input[type=text] { flex: 1 1 11rem; }
.triage-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.9rem; border-top: 1px solid #e2e9ed; padding-top: 0.8rem; }
.triage-progress strong { font-size: 1.05rem; }
.triage-done { max-width: 46rem; }
kbd { background: #eef2f4; border: 1px solid #ccd6dc; border-bottom-width: 2px; border-radius: 3px; padding: 0 0.3rem; font-size: 0.85em; }

/* Triage drag-to-move (2.37.0) */
.triage-bucket-row { display: flex; align-items: center; gap: 0.35rem; }
.triage-bucket-row .triage-bucket { flex: 1 1 auto; }
.triage-bucket-row.drop-hover { background: #e3eef3; outline: 2px dashed #2c5f6f; border-radius: 5px; }
.triage-folder.dragging { opacity: 0.5; }

.triage-other .designer-drag, .designer-other .designer-drag { visibility: hidden; }

/* Folder context menu + scrollable triage trees (2.38.0) */
.folder-context-menu { position: absolute; z-index: 1300; background: #fff; border: 1px solid #c8d2d8;
    border-radius: 6px; box-shadow: 0 6px 24px rgba(20, 40, 50, 0.18); padding: 0.25rem; min-width: 11rem; }
.folder-context-menu button { display: block; width: 100%; text-align: left; background: none; border: none;
    color: #1c2b33; padding: 0.4rem 0.7rem; border-radius: 4px; cursor: pointer; font-weight: 500; }
.folder-context-menu button:hover { background: #e6eef2; }
.folder-context-menu button.danger { color: #9d2f2f; }
.triage-tree-scroll { max-height: 34vh; overflow-y: auto; padding-right: 0.3rem; border: 1px solid #e2e9ed;
    border-radius: 6px; padding: 0.25rem 0.4rem; }

/* Triage scale controls (2.39.0) */
.triage-tree-controls { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin: 0.4rem 0 0.6rem; }
.triage-tabs { display: inline-flex; border: 1px solid #c8d2d8; border-radius: 6px; overflow: hidden; }
.triage-tab { background: #f4f7f9; border: none; color: #1c2b33; padding: 0.35rem 0.8rem; cursor: pointer; font-weight: 600; }
.triage-tab + .triage-tab { border-left: 1px solid #c8d2d8; }
.triage-tab.active { background: #2c5f6f; color: #fff; }
.triage-filter { flex: 1 1 9rem; min-width: 8rem; padding: 0.35rem 0.5rem; border: 1px solid #c8d2d8; border-radius: 6px; }
.triage-caret { background: none; border: none; cursor: pointer; color: #7d8c94; width: 1.1rem; padding: 0; font-size: 0.8rem; }
.triage-caret-leaf { cursor: default; color: #c3ced4; }
.triage-folder.filter-hidden { display: none; }

/* Browse multi-select + clipboard (2.40.0) */
.browser-doc-row.multi-selected { background: #dcebf1; border-radius: 4px; }
.browser-doc-row.cut-pending { opacity: 0.5; }
.browser-folder-summary.paste-target { outline: 2px dashed #2c5f6f; outline-offset: -2px; border-radius: 4px; }

/* Sort page action rows (2.41.0) */
.triage-actions { flex-wrap: nowrap; }
.triage-actions .button { padding: 0.4rem 0.6rem; font-size: 0.9rem; white-space: nowrap; }
.triage-top-actions { display: flex; justify-content: flex-end; margin: 0.2rem 0 0.3rem; }
@media (max-width: 900px) { .triage-actions { flex-wrap: wrap; } }

/* Review & arrange (2.44.0) */
.arrange-columns { display: flex; gap: 1.25rem; align-items: flex-start; }
.arrange-tree-panel { flex: 1 1 34rem; min-width: 26rem; }
.arrange-preview { flex: 1 1 24rem; min-width: 20rem; position: sticky; top: 0.75rem; }
.arrange-frame { height: 72vh; width: 100%; }
.arrange-preview-title { font-size: 1rem; overflow-wrap: anywhere; }
.arrange-tree-scroll { max-height: 66vh; overflow-y: auto; border: 1px solid #e2e9ed; border-radius: 6px; padding: 0.25rem 0.4rem; }
.arrange-folder-row { justify-content: flex-start; }
.arrange-name { font-weight: 600; }
.arrange-count { margin-left: auto; background: #eef3f6; border: 1px solid #d5dee3; border-radius: 10px;
    color: #1c2b33; padding: 0.1rem 0.6rem; font-size: 0.82rem; cursor: pointer; white-space: nowrap; }
.arrange-suggested-count { color: #b8641b; font-weight: 700; }
.arrange-files { list-style: none; margin: 0.1rem 0 0.3rem; padding-left: 2rem; }
.arrange-file { display: flex; align-items: center; gap: 0.3rem; padding: 0.12rem 0.2rem; border-radius: 4px; }
.arrange-file:hover { background: #f2f6f8; }
.arrange-file.suggested { opacity: 0.62; }
.arrange-file.suggested .arrange-file-title { font-style: italic; }
.arrange-file-title { background: none; border: none; color: #1c2b33; text-align: left; cursor: pointer;
    padding: 0.1rem 0.2rem; flex: 1 1 auto; overflow-wrap: anywhere; font-weight: 400; }
.arrange-accept { background: #e5f2e8; border: 1px solid #9cc7a6; color: #1d6b34; border-radius: 4px;
    padding: 0 0.45rem; cursor: pointer; font-weight: 700; }
.arrange-remove { background: none; border: none; color: #9d2f2f; cursor: pointer; font-weight: 700; padding: 0 0.35rem; }
.arrange-why { position: relative; display: inline-block; width: 1.1rem; height: 1.1rem; line-height: 1.1rem;
    text-align: center; background: #fdf1e3; border: 1px solid #e0b075; border-radius: 50%; color: #8a5a13;
    font-weight: 700; font-size: 0.78rem; cursor: help; }
.arrange-why:hover::after, .arrange-why:focus::after { content: attr(data-evidence); position: absolute; z-index: 1400;
    right: 0; top: 1.5rem; width: 26rem; max-width: 70vw; background: #0f172a; color: #fff; padding: 0.55rem 0.7rem;
    border-radius: 6px; font-weight: 400; font-size: 0.85rem; line-height: 1.35; white-space: normal;
    box-shadow: 0 6px 24px rgba(20, 40, 50, 0.3); }
.arrange-accept-all-row { padding: 0.1rem 0.2rem 0.25rem; }
.arrange-demo-suggested { opacity: 0.62; font-style: italic; }
.arrange-intro { max-width: 70rem; }
@media (max-width: 1100px) { .arrange-columns { flex-wrap: wrap; } .arrange-preview { position: static; } }

.arrange-copies { background: #eef3f6; border: 1px solid #d5dee3; border-radius: 10px; color: #5a6a72;
    padding: 0 0.45rem; font-size: 0.78rem; white-space: nowrap; cursor: default; }

.arrange-copies { cursor: pointer; }
.arrange-elsewhere-head { padding: 0.3rem 0.7rem 0.15rem; font-size: 0.78rem; text-transform: uppercase;
    letter-spacing: 0.04em; color: #5a6a72; }
.arrange-reveal-flash { outline: 2px solid #b8641b; outline-offset: -2px; border-radius: 5px;
    background: #fdf1e3; transition: background 0.4s ease; }

.arrange-copy-line { padding: 0.15rem 0.7rem; color: #1c2b33; font-size: 0.88rem; overflow-wrap: anywhere; }

/* Frozen source paths in the designer (2.48.0) */
.designer-fy-template { border: 1px solid #dbe6ec; border-radius: 6px; padding: 0.5rem 0.7rem; margin: 0 0 0.7rem;
    background: #f7fafb; }
.designer-fy-template-form { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.fy-template-years, .fy-template-counts, .fy-template-conflicts { list-style: none; margin: 0.3rem 0 0.8rem; padding: 0; }
.fy-template-years li, .fy-template-counts li, .fy-template-conflicts li { padding: 0.12rem 0; }

.designer-frozen { border: 1px solid #dbe6ec; border-radius: 6px; padding: 0.5rem 0.7rem; margin: 0 0 0.7rem;
    background: #f7fafb; }
.designer-frozen-list { list-style: none; margin: 0.2rem 0; padding: 0; }
.designer-frozen-list li { display: flex; align-items: center; gap: 0.6rem; padding: 0.12rem 0; }
.designer-frozen-path { font-weight: 600; }
.designer-frozen-add { margin-top: 0.3rem; }


.browser-folder-frozen .browser-folder-name { color: #4a6a7a; }
.browser-frozen-badge { color: #4a6a7a; border: 1px solid #b9cfd9; border-radius: 9px; padding: 0 0.45rem;
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; cursor: default; }
.designer-frozen-release { font-weight: 400; white-space: nowrap; margin: 0 0.4rem; }

/* 2.61.0 arrange confidence chips: colour is never the only channel — the glyph and the
   percentage carry the same information for colourblind users. */
.arrange-conf { display: inline-block; margin: 0 0.35rem; padding: 0 0.45rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600; line-height: 1.4; white-space: nowrap; }
.arrange-conf-green { background: #e2f4e5; color: #1e6b34; border: 1px solid #b7e0c0; }
.arrange-conf-amber { background: #fdf3d7; color: #8a6100; border: 1px solid #edd79a; }
.arrange-conf-red { background: #fbe3e1; color: #a3271d; border: 1px solid #f0bab5; }

/* 2.62.0 Doubtful rail + spot-check */
.arrange-doubtful { margin-bottom: 1rem; }
.arrange-doubtful-head { display: flex; align-items: baseline; gap: 1rem; }
.arrange-doubtful-head h2 { margin: 0; font-size: 1.05rem; }
.arrange-doubtful-toggle { font-size: 0.85rem; color: #555; }
.arrange-doubtful-list { list-style: none; margin: 0.4rem 0 0; padding: 0; max-height: 16rem; overflow-y: auto; }
.arrange-doubtful-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.2rem 0.1rem; border-bottom: 1px solid #f0ede8; }
.arrange-doubtful-title { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arrange-doubtful-dest { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arrange-doubtful-acts { flex: 0 0 auto; }
.arrange-auto-chip { background: #ece7fb; color: #4b3a8f; border: 1px solid #d4c9f2; }
.arrange-demote { margin-left: 0.3rem; font-size: 0.78rem; padding: 0 0.4rem; border-radius: 4px; border: 1px solid #d4c9f2; background: #f7f4ff; color: #4b3a8f; cursor: pointer; }
.arrange-demote:hover { background: #ece7fb; }

/* 2.64.0 evidence popover */
.arrange-evidence-panel { margin: 0.25rem 0 0.35rem 1.6rem; padding: 0.4rem 0.6rem; background: #faf8f4; border: 1px solid #e8e2d8; border-radius: 6px; font-size: 0.85rem; }
.arrange-evidence-meta { font-weight: 600; color: #555; }
.arrange-evidence-cite { margin: 0.3rem 0; padding-left: 0.6rem; border-left: 3px solid #d8cfc0; font-style: italic; white-space: pre-wrap; }
.arrange-evidence-elsewhere { font-size: 0.8rem; }
.arrange-why { cursor: pointer; }
