:root {
    color-scheme: dark;
    --bg: #070a12;
    --panel: rgba(16, 22, 36, .78);
    --panel-solid: #111728;
    --line: rgba(255,255,255,.09);
    --text: #f5f7ff;
    --muted: #9aa5bb;
    --cyan: #64e8ff;
    --blue: #6f8cff;
    --violet: #aa75ff;
    --green: #62e6ad;
    --red: #ff748b;
    --amber: #ffc96b;
    --radius: 22px;
    --shadow: 0 24px 80px rgba(0,0,0,.38);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); background: radial-gradient(circle at 10% 0%, #111d3b 0, transparent 34%), radial-gradient(circle at 90% 10%, #241440 0, transparent 30%), var(--bg); line-height: 1.5; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
code { font-family: "SFMono-Regular", Consolas, monospace; }
.hidden { display: none !important; }

.ambient { position: fixed; width: 420px; height: 420px; border-radius: 50%; filter: blur(110px); opacity: .13; pointer-events: none; z-index: 0; }
.ambient-one { top: 10%; left: -260px; background: var(--blue); }
.ambient-two { right: -220px; bottom: 2%; background: var(--violet); }

.site-header, .site-footer, .shell { position: relative; z-index: 1; }
.site-header { width: min(1240px, calc(100% - 40px)); margin: 0 auto; height: 84px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 12px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; font-weight: 900; color: #07101c; background: linear-gradient(135deg, var(--cyan), var(--violet)); box-shadow: 0 10px 35px rgba(100,232,255,.22); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: .01em; }
.brand small { color: var(--muted); font-size: 11px; margin-top: 1px; }
.site-header nav { display: flex; align-items: center; gap: 8px; }
.site-header nav > a, .nav-button { color: var(--muted); padding: 9px 12px; border-radius: 10px; font-size: 14px; background: none; border: 0; }
.site-header nav > a:hover, .nav-button:hover { color: var(--text); background: rgba(255,255,255,.05); }
.site-header form { margin: 0; }
.shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; min-height: calc(100vh - 160px); }
.site-footer { width: min(1180px, calc(100% - 40px)); margin: 50px auto 0; min-height: 72px; padding: 22px 0; display: flex; justify-content: space-between; gap: 20px; color: #697389; font-size: 12px; border-top: 1px solid var(--line); }

.eyebrow { color: var(--cyan); font-size: 11px; font-weight: 800; letter-spacing: .18em; margin-bottom: 12px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(38px, 6vw, 68px); line-height: 1.02; letter-spacing: -.055em; margin-bottom: 20px; }
h2 { font-size: 22px; letter-spacing: -.025em; margin-bottom: 4px; }
h3 { font-size: 17px; margin: 0; }
p { color: var(--muted); }
.lead { font-size: 16px; }
.fine-print { margin: 20px 0 0; font-size: 12px; color: #748096; }

.glass-card { background: linear-gradient(145deg, rgba(22,29,47,.89), rgba(11,16,28,.86)); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.hero-grid { min-height: 360px; display: grid; grid-template-columns: minmax(0,1.4fr) minmax(240px,.6fr); align-items: center; gap: 50px; padding: 70px 24px 42px; }
.hero-copy { max-width: 760px; }
.hero-copy p { font-size: 18px; max-width: 680px; }
.trust-row { display: flex; flex-wrap: wrap; gap: 22px; color: #c0cadc; font-size: 13px; margin-top: 28px; }
.trust-row span::before { content: "✓"; margin-right: 7px; color: var(--green); }
.route-orbit { position: relative; width: 210px; height: 210px; margin: auto; border-radius: 50%; border: 1px solid rgba(100,232,255,.18); display: grid; place-items: center; box-shadow: inset 0 0 60px rgba(111,140,255,.08), 0 0 70px rgba(111,140,255,.08); }
.route-orbit::before { content: ""; position: absolute; inset: 25px; border: 1px dashed rgba(170,117,255,.28); border-radius: inherit; }
.orbit-core { width: 96px; height: 96px; border-radius: 30px; display: grid; place-items: center; font-weight: 900; letter-spacing: .08em; background: linear-gradient(145deg,#26345a,#151d34); border: 1px solid rgba(255,255,255,.13); box-shadow: 0 18px 40px rgba(0,0,0,.3); }
.route-orbit small { position: absolute; bottom: 13px; color: var(--cyan); }
.orbit-dot { width: 13px; height: 13px; position: absolute; top: 22px; right: 42px; border-radius: 50%; background: var(--green); box-shadow: 0 0 22px var(--green); }

.workspace-grid { display: grid; gap: 20px; }
.upload-card, .progress-card, .settings-card { padding: 28px; }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.card-heading > div { display: flex; align-items: center; gap: 13px; }
.card-heading p { margin: 0; font-size: 13px; }
.step-number { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 12px; color: var(--cyan); background: rgba(100,232,255,.08); border: 1px solid rgba(100,232,255,.17); font-size: 11px; font-weight: 800; }
.privacy-pill, .status-pill { display: inline-flex; align-items: center; padding: 7px 11px; border-radius: 999px; font-size: 11px; font-weight: 750; white-space: nowrap; }
.privacy-pill { color: var(--green); background: rgba(98,230,173,.09); border: 1px solid rgba(98,230,173,.18); }
.status-pill.waiting { color: var(--amber); background: rgba(255,201,107,.1); }
.status-pill.active { color: var(--cyan); background: rgba(100,232,255,.1); }
.status-pill.success { color: var(--green); background: rgba(98,230,173,.1); }
.status-pill.danger { color: var(--red); background: rgba(255,116,139,.1); }
.status-pill.muted { color: var(--muted); background: rgba(154,165,187,.1); }

.drop-zone { position: relative; min-height: 235px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 28px; text-align: center; border-radius: 18px; border: 1px dashed rgba(130,153,207,.38); background: rgba(7,11,20,.42); transition: .2s ease; }
.drop-zone:hover, .drop-zone:focus-within, .drop-zone.dragging { border-color: var(--cyan); background: rgba(100,232,255,.05); transform: translateY(-2px); }
.file-input { position: absolute !important; inset: 0 !important; width: 100% !important; height: 100% !important; padding: 0 !important; margin: 0 !important; opacity: 0 !important; cursor: pointer !important; z-index: 5; }
.drop-zone > *:not(.file-input) { pointer-events: none; }
.choose-files-visual { pointer-events: none; }
.drop-zone strong { font-size: 18px; }
.drop-zone small { color: var(--muted); margin-bottom: 8px; }
.upload-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 15px; font-size: 24px; color: var(--cyan); background: rgba(100,232,255,.08); margin-bottom: 6px; }
.upload-options { display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: end; margin: 22px 0; }
.option-note { padding: 12px 14px; border: 1px solid var(--line); border-radius: 13px; min-width: 185px; }
.option-note span, .option-note strong { display: block; }
.option-note span { color: var(--muted); font-size: 11px; }
.option-note strong { font-size: 13px; margin-top: 3px; }

label { color: #c6cede; font-size: 12px; font-weight: 650; display: block; }
input, select, textarea { width: 100%; margin-top: 7px; padding: 12px 13px; color: var(--text); background: rgba(4,8,16,.62); border: 1px solid rgba(255,255,255,.1); border-radius: 11px; outline: none; transition: border-color .2s, box-shadow .2s; }
input:focus, select:focus, textarea:focus { border-color: rgba(100,232,255,.75); box-shadow: 0 0 0 3px rgba(100,232,255,.08); }
textarea { resize: vertical; }
input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--blue); }
.stack-form { display: grid; gap: 16px; margin-top: 26px; }
.form-row { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.form-row.three { grid-template-columns: repeat(3,minmax(0,1fr)); }
.check-row { display: flex; flex-wrap: wrap; gap: 18px; margin: 17px 0; }
.check-row label { display: flex; align-items: center; gap: 7px; }

.primary-button, .secondary-button, .danger-button { display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; border: 0; font-weight: 750; transition: transform .18s, opacity .18s, border-color .18s; }
.primary-button { min-height: 44px; padding: 11px 18px; color: #07101c; background: linear-gradient(135deg, var(--cyan), #8c93ff); box-shadow: 0 12px 35px rgba(100,232,255,.17); }
.primary-button.large { width: 100%; min-height: 52px; font-size: 15px; }
.primary-button.compact { min-height: 40px; }
.secondary-button { min-height: 38px; padding: 8px 14px; color: var(--text); background: rgba(255,255,255,.055); border: 1px solid var(--line); }
.danger-button { min-height: 35px; padding: 7px 12px; color: var(--red); background: rgba(255,116,139,.08); border: 1px solid rgba(255,116,139,.16); }
.primary-button:hover, .secondary-button:hover, .danger-button:hover { transform: translateY(-1px); }
.primary-button:disabled { opacity: .38; cursor: not-allowed; transform: none; }

.notice { margin: 18px 0; padding: 13px 15px; border-radius: 12px; font-size: 13px; }
.notice.danger { color: #ffc0ca; background: rgba(255,116,139,.09); border: 1px solid rgba(255,116,139,.18); }
.notice.success { color: #b9f6da; background: rgba(98,230,173,.09); border: 1px solid rgba(98,230,173,.18); }

.progress-summary { display: grid; grid-template-columns: 126px 1fr; gap: 28px; align-items: center; }
.progress-ring { width: 126px; height: 126px; position: relative; display: grid; place-items: center; border-radius: 50%; background: rgba(255,255,255,.025); }
.progress-ring svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.progress-ring circle { fill: none; stroke-width: 9; }
.progress-ring .ring-track { stroke: rgba(255,255,255,.07); }
.progress-ring .ring-value { stroke: var(--cyan); stroke-linecap: round; stroke-dasharray: 339.292; stroke-dashoffset: 339.292; transition: stroke-dashoffset .35s ease; }
.progress-ring strong { position: relative; font-size: 26px; }
.progress-copy h3 { font-size: 19px; margin-bottom: 8px; }
.progress-copy p { margin-bottom: 14px; }
.page-chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 118px; overflow: auto; }
.page-chip { min-width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; color: var(--muted); background: rgba(255,255,255,.04); font-size: 10px; }
.page-chip.completed { color: #08150f; background: var(--green); }
.page-chip.running { color: #061116; background: var(--cyan); }
.page-chip.failed { color: white; background: var(--red); }
.progress-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.artifact-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; }
.artifact-card { padding: 16px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,255,.035); }
.artifact-card strong, .artifact-card span { display: block; }
.artifact-card span { color: var(--muted); font-size: 11px; margin: 5px 0 13px; }

.auth-wrap { min-height: calc(100vh - 190px); display: grid; place-items: center; padding: 60px 0; }
.auth-card { width: min(460px,100%); padding: 34px; }
.auth-card.wide-auth { width: min(650px,100%); }
.auth-card h1 { font-size: 38px; }
.hash-result { margin-top: 22px; padding: 15px; border-radius: 13px; background: #060a12; border: 1px solid var(--line); }
.hash-result span, .hash-result code { display: block; }
.hash-result span { color: var(--muted); font-size: 11px; margin-bottom: 8px; }
.hash-result code, .secret-reveal code { color: var(--green); overflow-wrap: anywhere; user-select: all; }
.security-note { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.security-note p { margin: 4px 0 0; font-size: 12px; }

.admin-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; padding: 58px 0 30px; }
.admin-hero h1 { font-size: clamp(34px,5vw,52px); margin-bottom: 12px; }
.admin-hero p { margin-bottom: 0; }
.section-tabs { display: flex; gap: 5px; overflow-x: auto; margin: 0 0 28px; padding: 5px; border: 1px solid var(--line); border-radius: 14px; background: rgba(7,11,20,.55); }
.section-tabs a { padding: 9px 14px; border-radius: 10px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.section-tabs a.active { color: var(--text); background: rgba(255,255,255,.075); box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.metric-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 14px; }
.metric-card { min-height: 150px; padding: 19px; border: 1px solid var(--line); border-radius: 17px; background: rgba(16,22,36,.64); }
.metric-card.glow { background: linear-gradient(145deg,rgba(54,75,126,.6),rgba(16,22,36,.72)); }
.metric-card span, .metric-card small, .metric-card strong { display: block; }
.metric-card span, .metric-card small { color: var(--muted); font-size: 11px; }
.metric-card strong { font-size: 42px; letter-spacing: -.05em; margin: 16px 0 2px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin: 34px 0 16px; }
.section-heading p { margin: 0; font-size: 13px; }
.section-heading a { color: var(--cyan); font-size: 12px; }
.job-list { display: grid; gap: 9px; }
.job-card { display: grid; grid-template-columns: minmax(260px,1.3fr) minmax(180px,.6fr) auto auto; align-items: center; gap: 20px; padding: 16px; border-radius: 16px; border: 1px solid var(--line); background: rgba(16,22,36,.6); }
.job-main { display: flex; align-items: center; gap: 13px; min-width: 0; }
.job-main > div:last-child { min-width: 0; }
.job-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-main p { margin: 3px 0 0; font-size: 11px; }
.file-icon { width: 42px; height: 42px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 12px; color: var(--cyan); background: rgba(100,232,255,.08); font-size: 10px; font-weight: 800; }
.job-progress > div { display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; margin-bottom: 6px; }
.job-progress progress { width: 100%; height: 5px; border: 0; border-radius: 8px; overflow: hidden; display: block; }
.job-progress progress::-webkit-progress-bar { background: rgba(255,255,255,.07); }
.job-progress progress::-webkit-progress-value { background: linear-gradient(90deg,var(--blue),var(--cyan)); }
.job-progress progress::-moz-progress-bar { background: linear-gradient(90deg,var(--blue),var(--cyan)); }
.profile-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.profile-card { padding: 21px; display: grid; gap: 14px; }
.profile-card .card-heading { margin-bottom: 3px; }
details { border: 1px solid var(--line); border-radius: 12px; padding: 11px; }
summary { cursor: pointer; color: var(--muted); font-size: 12px; }
details[open] summary { margin-bottom: 12px; }
.inline-create { display: grid; grid-template-columns: 1fr 1fr 160px auto; align-items: end; gap: 12px; padding: 18px; }
.client-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 13px; margin-top: 18px; }
.client-card { padding: 18px; }
.client-card > div { display: flex; align-items: center; gap: 8px; }
.client-card p, .client-card small { display: block; margin: 9px 0; color: var(--muted); font-size: 11px; }
.client-card form { margin-top: 15px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #536078; }
.status-dot.online { background: var(--green); box-shadow: 0 0 12px rgba(98,230,173,.6); }
.secret-reveal { margin: 20px 0; padding: 18px; border-radius: 15px; border: 1px solid rgba(98,230,173,.25); background: rgba(98,230,173,.075); }
.secret-reveal strong, .secret-reveal code { display: block; }
.secret-reveal code { margin: 12px 0; padding: 11px; border-radius: 9px; background: #070b11; }
.secret-reveal p { margin: 0; font-size: 11px; }
.maintenance-card { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-top: 18px; padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,255,.025); }
.maintenance-card p { margin: 3px 0 0; font-size: 12px; }
.empty-state { padding: 35px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 16px; }

@media (max-width: 900px) {
    .hero-grid { grid-template-columns: 1fr; min-height: 0; padding-top: 55px; }
    .route-orbit { display: none; }
    .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .job-card { grid-template-columns: 1fr auto; }
    .job-progress { grid-column: 1 / -1; }
    .profile-grid { grid-template-columns: 1fr; }
    .inline-create { grid-template-columns: 1fr 1fr; }
    .client-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .artifact-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 620px) {
    .site-header, .shell, .site-footer { width: min(100% - 24px,1180px); }
    .site-header { height: 70px; }
    .site-header nav > a { display: none; }
    .hero-grid { padding: 45px 4px 30px; }
    h1 { font-size: 42px; }
    .hero-copy p { font-size: 15px; }
    .trust-row { gap: 10px; display: grid; }
    .upload-card, .progress-card, .settings-card, .auth-card { padding: 19px; }
    .card-heading { align-items: flex-start; }
    .privacy-pill { display: none; }
    .upload-options, .progress-summary, .form-row, .form-row.three, .inline-create { grid-template-columns: 1fr; }
    .progress-ring { width: 110px; height: 110px; }
    .metric-grid, .client-grid, .artifact-grid { grid-template-columns: 1fr; }
    .job-card { grid-template-columns: 1fr; }
    .job-card > .status-pill { justify-self: start; }
    .admin-hero { align-items: flex-start; flex-direction: column; padding-top: 40px; }
    .maintenance-card, .site-footer { align-items: flex-start; flex-direction: column; }
}


/* Admin diagnostic details */
.diagnostic-row{margin-top:10px;line-height:1.55;overflow-wrap:anywhere}
.diagnostic-link{display:inline-block;margin-top:8px;margin-right:12px;font-weight:700}

.notice.info {
    color: #c9efff;
    background: rgba(103, 216, 255, .08);
    border: 1px solid rgba(103, 216, 255, .18);
}


/* Extracted OCR text preview */
.ocr-text-preview {
    margin-bottom: 20px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(7,11,20,.48);
}
.ocr-preview-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 14px;
}
.ocr-preview-top h3 {
    margin: 0 0 4px;
    font-size: 18px;
}
.ocr-preview-top p {
    margin: 0;
    font-size: 12px;
    color: var(--muted);
}
.ocr-preview-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 7px;
}
.ocr-preview-mode {
    min-height: 38px;
    padding: 8px 13px;
    color: var(--muted);
    background: rgba(255,255,255,.035);
    border: 1px solid var(--line);
    border-radius: 10px;
    cursor: pointer;
}
.ocr-preview-mode.active {
    color: var(--text);
    border-color: rgba(100,232,255,.35);
    background: rgba(100,232,255,.09);
}
.ocr-page-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 3px 0 12px;
}
.ocr-page-tab {
    flex: 0 0 auto;
    min-height: 34px;
    padding: 7px 11px;
    color: var(--muted);
    background: rgba(255,255,255,.035);
    border: 1px solid var(--line);
    border-radius: 9px;
    cursor: pointer;
}
.ocr-page-tab.active {
    color: #071016;
    background: var(--cyan);
    border-color: transparent;
}
.ocr-preview-body {
    min-height: 180px;
    max-height: 680px;
    overflow: auto;
    padding: 24px;
    border: 1px solid rgba(255,255,255,.075);
    border-radius: 13px;
    background: #090d16;
}
.ocr-preview-empty {
    margin: 0;
    color: var(--muted);
}
.ocr-raw-text {
    margin: 0;
    padding: 0;
    max-height: none;
    overflow: visible;
    border: 0;
    background: transparent;
    color: #e8ecf8;
    font: 13px/1.65 ui-monospace,SFMono-Regular,Consolas,monospace;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.ocr-formatted-text {
    color: #edf1fb;
    font-size: 15px;
    line-height: 1.72;
}
.ocr-formatted-text > :first-child { margin-top: 0; }
.ocr-formatted-text > :last-child { margin-bottom: 0; }
.ocr-formatted-text p { margin: 0 0 15px; }
.ocr-formatted-text h2,
.ocr-formatted-text h3,
.ocr-formatted-text h4,
.ocr-formatted-text h5,
.ocr-formatted-text h6 {
    margin: 24px 0 10px;
    color: #fff;
    line-height: 1.3;
}
.ocr-formatted-text h2 { font-size: 24px; }
.ocr-formatted-text h3 { font-size: 20px; }
.ocr-formatted-text h4 { font-size: 17px; }
.ocr-formatted-text h5,
.ocr-formatted-text h6 { font-size: 15px; }
.ocr-formatted-text ul,
.ocr-formatted-text ol {
    margin: 0 0 16px;
    padding-left: 26px;
}
.ocr-formatted-text li { margin: 5px 0; }
.ocr-formatted-text blockquote {
    margin: 16px 0;
    padding: 10px 14px;
    border-left: 3px solid var(--cyan);
    color: #cad4e9;
    background: rgba(100,232,255,.045);
}
.ocr-formatted-text code {
    color: #bcefff;
    background: rgba(100,232,255,.08);
}
.ocr-formatted-text pre {
    max-height: none;
    margin: 16px 0;
    background: #050810;
}
.ocr-formatted-text hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 22px 0;
}
.ocr-table-wrap {
    width: 100%;
    overflow-x: auto;
    margin: 16px 0;
    border: 1px solid var(--line);
    border-radius: 11px;
}
.ocr-table-wrap table {
    width: 100%;
    border-collapse: collapse;
    min-width: 520px;
}
.ocr-table-wrap th,
.ocr-table-wrap td {
    padding: 10px 12px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--line);
    border-right: 1px solid var(--line);
}
.ocr-table-wrap th {
    color: #fff;
    background: rgba(255,255,255,.05);
}
.ocr-table-wrap tr:last-child td { border-bottom: 0; }
.ocr-table-wrap th:last-child,
.ocr-table-wrap td:last-child { border-right: 0; }

@media (max-width: 700px) {
    .ocr-preview-top {
        flex-direction: column;
    }
    .ocr-preview-actions {
        justify-content: flex-start;
    }
    .ocr-preview-body {
        padding: 17px;
        max-height: 600px;
    }
}


/* ================================================================
   Document + Pages OCR workspace
   ================================================================ */

body.document-active .shell {
    width: min(1500px, calc(100% - 32px));
}
body.document-active .site-footer {
    width: min(1500px, calc(100% - 32px));
}

.document-workspace {
    padding: 20px;
    overflow: hidden;
}

.document-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 2px 2px 16px;
}
.document-title {
    display: flex;
    align-items: center;
    gap: 13px;
    min-width: 0;
}
.document-title > div {
    min-width: 0;
}
.document-title h2 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.document-title p {
    margin: 2px 0 0;
    font-size: 12px;
}
.dot-separator {
    margin: 0 7px;
    color: #58647d;
}
.document-toolbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.document-progress {
    margin-bottom: 14px;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: rgba(5,9,17,.46);
}
.document-progress-track {
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255,255,255,.07);
}
.document-progress-track > span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg,var(--blue),var(--cyan),var(--green));
    transition: width .35s ease;
}
.document-progress-meta {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin-top: 7px;
    color: var(--muted);
    font-size: 11px;
}
.document-progress-meta strong {
    color: var(--text);
}

.viewer-mode-bar {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
}
.viewer-mode,
.page-filter,
.viewer-tools button,
.viewer-tool-link {
    min-height: 32px;
    padding: 6px 10px;
    border-radius: 9px;
    border: 1px solid var(--line);
    color: var(--muted);
    background: rgba(255,255,255,.035);
    font-size: 11px;
    font-weight: 700;
}
.viewer-mode.active,
.page-filter.active,
.viewer-tools button.active {
    color: var(--text);
    border-color: rgba(100,232,255,.35);
    background: rgba(100,232,255,.09);
}

.document-viewer {
    display: grid;
    grid-template-columns: 210px minmax(0,1fr) minmax(0,1fr);
    min-height: 650px;
    max-height: calc(100vh - 255px);
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 17px;
    background: rgba(5,8,15,.48);
}
.document-viewer[data-view-mode="image"] {
    grid-template-columns: 210px minmax(0,1fr);
}
.document-viewer[data-view-mode="image"] .text-panel {
    display: none;
}
.document-viewer[data-view-mode="text"] {
    grid-template-columns: 210px minmax(0,1fr);
}
.document-viewer[data-view-mode="text"] .source-panel {
    display: none;
}

.page-rail {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--line);
    background: rgba(10,14,24,.78);
}
.page-rail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 58px;
    padding: 12px;
    border-bottom: 1px solid var(--line);
}
.page-rail-head strong,
.page-rail-head small {
    display: block;
}
.page-rail-head small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 10px;
}

.page-filters {
    display: flex;
    gap: 4px;
    padding: 8px;
    overflow-x: auto;
    border-bottom: 1px solid var(--line);
}
.page-filter {
    flex: 0 0 auto;
    padding: 5px 8px;
}

.page-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding: 8px;
}
.page-item {
    width: 100%;
    display: grid;
    grid-template-columns: 54px minmax(0,1fr);
    align-items: center;
    gap: 9px;
    padding: 7px;
    margin-bottom: 6px;
    text-align: left;
    color: var(--text);
    border: 1px solid transparent;
    border-radius: 11px;
    background: transparent;
}
.page-item:hover {
    background: rgba(255,255,255,.045);
}
.page-item.active {
    border-color: rgba(100,232,255,.34);
    background: rgba(100,232,255,.07);
}
.page-item.failed {
    border-color: rgba(255,116,139,.14);
}
.page-thumb {
    width: 54px;
    height: 68px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border-radius: 7px;
    border: 1px solid rgba(255,255,255,.08);
    background: #f3f3f3;
}
.page-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.page-thumb-empty {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    color: #748096;
    background: #111827;
    font-size: 11px;
}
.page-item-info {
    min-width: 0;
}
.page-item-title,
.page-item-status {
    display: block;
}
.page-item-title {
    font-size: 12px;
    font-weight: 760;
}
.page-item-status {
    margin-top: 4px;
    color: var(--muted);
    font-size: 10px;
}
.page-item.completed .page-item-status { color: var(--green); }
.page-item.running .page-item-status,
.page-item.processing .page-item-status { color: var(--cyan); }
.page-item.failed .page-item-status { color: var(--red); }
.page-item.queued .page-item-status { color: var(--amber); }

.viewer-panel {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.source-panel {
    border-right: 1px solid var(--line);
}
.viewer-panel-head {
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    background: rgba(13,18,30,.72);
}
.viewer-panel-head strong,
.viewer-panel-head small {
    display: block;
}
.viewer-panel-head small {
    color: var(--muted);
    margin-top: 2px;
    font-size: 10px;
}
.viewer-tools {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px;
}
.viewer-tools button,
.viewer-tool-link {
    min-height: 29px;
    padding: 5px 8px;
}

.source-stage,
.text-stage {
    flex: 1;
    min-height: 0;
    overflow: auto;
    position: relative;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    background: #080b12;
}
.source-stage {
    display: grid;
    align-items: start;
    justify-items: center;
    padding: 18px;
    background:
        linear-gradient(45deg, rgba(255,255,255,.018) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(255,255,255,.018) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(255,255,255,.018) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.018) 75%),
        #080b12;
    background-size: 24px 24px;
    background-position: 0 0,0 12px,12px -12px,-12px 0;
}
.source-image {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    margin: 0 auto;
    transform-origin: top center;
    transition: transform .16s ease;
    border-radius: 4px;
    box-shadow: 0 18px 55px rgba(0,0,0,.48);
    background: #fff;
}
.source-image.fit-page {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
}
.source-image.fit-width {
    width: 100%;
    height: auto;
    max-width: none;
    max-height: none;
}
.source-stage > .viewer-placeholder {
    align-self: center;
    justify-self: center;
}

.text-stage {
    padding: 22px;
}
.viewer-placeholder {
    align-self: center;
    justify-self: center;
    max-width: 340px;
    text-align: center;
    color: var(--muted);
}
.viewer-placeholder strong,
.viewer-placeholder span {
    display: block;
}
.viewer-placeholder strong {
    color: #dce4f6;
    margin-bottom: 6px;
}
.viewer-placeholder span {
    font-size: 12px;
}

.ocr-formatted-text {
    color: #edf1fb;
    font-size: 14px;
    line-height: 1.72;
}
.ocr-formatted-text > :first-child { margin-top: 0; }
.ocr-formatted-text > :last-child { margin-bottom: 0; }
.ocr-formatted-text p { margin: 0 0 15px; }
.ocr-formatted-text h2,
.ocr-formatted-text h3,
.ocr-formatted-text h4,
.ocr-formatted-text h5,
.ocr-formatted-text h6 {
    margin: 24px 0 10px;
    color: #fff;
    line-height: 1.3;
}
.ocr-formatted-text h2 { font-size: 23px; }
.ocr-formatted-text h3 { font-size: 19px; }
.ocr-formatted-text h4 { font-size: 16px; }
.ocr-formatted-text h5,
.ocr-formatted-text h6 { font-size: 14px; }
.ocr-formatted-text ul,
.ocr-formatted-text ol {
    margin: 0 0 16px;
    padding-left: 25px;
}
.ocr-formatted-text li {
    margin: 5px 0;
}
.ocr-formatted-text blockquote {
    margin: 16px 0;
    padding: 10px 14px;
    border-left: 3px solid var(--cyan);
    color: #cad4e9;
    background: rgba(100,232,255,.045);
}
.ocr-formatted-text code {
    color: #bcefff;
    background: rgba(100,232,255,.08);
}
.ocr-formatted-text pre {
    max-height: none;
    margin: 16px 0;
    background: #050810;
}
.ocr-formatted-text hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 22px 0;
}
.ocr-raw-text {
    margin: 0;
    padding: 0;
    max-height: none;
    overflow: visible;
    color: #e8ecf8;
    background: transparent;
    border: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font: 13px/1.65 ui-monospace,SFMono-Regular,Consolas,monospace;
}
.ocr-table-wrap {
    width: 100%;
    overflow-x: auto;
    margin: 16px 0;
    border: 1px solid var(--line);
    border-radius: 11px;
}
.ocr-table-wrap table {
    width: 100%;
    min-width: 520px;
    border-collapse: collapse;
}
.ocr-table-wrap th,
.ocr-table-wrap td {
    padding: 10px 12px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--line);
    border-right: 1px solid var(--line);
}
.ocr-table-wrap th {
    background: rgba(255,255,255,.05);
}
.ocr-table-wrap tr:last-child td { border-bottom: 0; }
.ocr-table-wrap th:last-child,
.ocr-table-wrap td:last-child { border-right: 0; }

.diagnostic-panel {
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 0;
    overflow: hidden;
    background: rgba(7,11,20,.48);
}
.diagnostic-panel summary {
    padding: 11px 13px;
    margin: 0;
    color: #bec9dc;
    background: rgba(255,255,255,.025);
}
.diagnostic-panel[open] summary {
    margin-bottom: 0;
    border-bottom: 1px solid var(--line);
}
.diagnostic-panel .notice {
    margin: 10px;
}
.diagnostic-row {
    margin-top: 7px;
    line-height: 1.55;
    overflow-wrap: anywhere;
}
.diagnostic-link {
    display: inline-block;
    margin-top: 8px;
    color: var(--cyan);
    font-weight: 700;
}

.downloads-panel {
    margin-top: 14px;
    padding-top: 4px;
}
.compact-heading {
    margin-top: 14px;
}
.notice.info {
    color: #c9efff;
    background: rgba(103,216,255,.08);
    border: 1px solid rgba(103,216,255,.18);
}

@media (max-width: 1150px) {
    .document-viewer {
        grid-template-columns: 180px minmax(0,1fr) minmax(0,1fr);
    }
    .page-thumb {
        width: 46px;
        height: 60px;
    }
    .page-item {
        grid-template-columns: 46px minmax(0,1fr);
    }
}

@media (max-width: 900px) {
    body.document-active .shell,
    body.document-active .site-footer {
        width: min(100% - 20px, 1500px);
    }

    .document-workspace {
        padding: 12px;
    }

    .document-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .document-toolbar-actions {
        justify-content: flex-start;
    }

    .document-viewer,
    .document-viewer[data-view-mode="image"],
    .document-viewer[data-view-mode="text"] {
        display: grid;
        grid-template-columns: 1fr;
        max-height: none;
    }

    .page-rail {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .page-list {
        display: flex;
        gap: 7px;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 8px;
    }

    .page-item {
        flex: 0 0 124px;
        grid-template-columns: 42px minmax(0,1fr);
        margin: 0;
    }

    .page-thumb {
        width: 42px;
        height: 55px;
    }

    .source-panel {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .document-viewer[data-view-mode="image"] .text-panel {
        display: none;
    }

    .document-viewer[data-view-mode="text"] .source-panel {
        display: none;
    }

    .source-stage {
        min-height: 520px;
    }

    .text-stage {
        min-height: 460px;
    }
}

@media (max-width: 620px) {
    .document-toolbar-actions {
        width: 100%;
    }

    .viewer-panel-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .viewer-tools {
        justify-content: flex-start;
    }

    .source-stage {
        min-height: 430px;
        padding: 10px;
    }

    .text-stage {
        min-height: 400px;
        padding: 16px;
    }

    .document-progress-meta {
        align-items: flex-start;
        flex-direction: column;
        gap: 2px;
    }
}


/* Progressive browser PDF pipeline */
.page-item.rendering .page-item-status {
    color: #c6a7ff;
}
.page-item.uploading .page-item-status {
    color: #7fdfff;
}
.page-item.rendering .page-thumb-empty,
.page-item.uploading .page-thumb-empty {
    font-size: 20px;
    color: #dce8ff;
}
.page-item.rendering .page-thumb-empty {
    animation: ocr-pulse 1.1s ease-in-out infinite;
}
@keyframes ocr-pulse {
    0%,100% { opacity: .45; transform: scale(.92); }
    50% { opacity: 1; transform: scale(1.08); }
}


/* ================================================================
   OCR input optimization
   ================================================================ */

.optimization-summary small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 10px;
}

.ocr-input-tuning {
    margin: -4px 0 22px;
    padding: 17px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(7,11,20,.42);
}

.tuning-heading,
.scope-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.tuning-heading strong,
.tuning-heading small,
.scope-heading strong,
.scope-heading small {
    display: block;
}

.tuning-heading small,
.scope-heading small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 11px;
}

.default-pill {
    flex: 0 0 auto;
    padding: 5px 9px;
    border-radius: 999px;
    color: var(--green);
    border: 1px solid rgba(98,230,173,.22);
    background: rgba(98,230,173,.07);
    font-size: 10px;
    font-weight: 800;
}

.detail-presets {
    display: grid;
    grid-template-columns: repeat(6,minmax(0,1fr));
    gap: 8px;
    margin-top: 13px;
}

.detail-preset,
.scope-option {
    position: relative;
    cursor: pointer;
}

.detail-preset input,
.scope-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.detail-preset > span {
    min-height: 68px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255,255,255,.025);
    transition: .16s ease;
}

.detail-preset > span strong,
.detail-preset > span small {
    display: block;
}

.detail-preset > span strong {
    color: var(--text);
    font-size: 12px;
}

.detail-preset > span small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 10px;
}

.detail-preset:hover > span,
.scope-option:hover > span {
    border-color: rgba(100,232,255,.24);
    background: rgba(100,232,255,.035);
}

.detail-preset.selected > span,
.detail-preset input:checked + span {
    border-color: rgba(100,232,255,.46);
    background: rgba(100,232,255,.09);
    box-shadow: inset 0 0 0 1px rgba(100,232,255,.07);
}

.detail-preset.selected > span strong,
.detail-preset input:checked + span strong {
    color: var(--cyan);
}

.custom-detail-row {
    display: flex;
    align-items: end;
    gap: 18px;
    margin-top: 12px;
    padding: 12px;
    border: 1px solid rgba(100,232,255,.14);
    border-radius: 12px;
    background: rgba(100,232,255,.035);
}

.custom-detail-row label {
    min-width: 230px;
}

.custom-detail-row > small {
    padding-bottom: 9px;
    color: var(--muted);
    font-size: 10px;
}

.number-with-unit {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    margin-top: 6px;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    background: #0a0e18;
}

.number-with-unit input {
    width: 100%;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.number-with-unit > span {
    padding: 0 11px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
}

.scope-heading {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.scope-options {
    display: grid;
    grid-template-columns: repeat(2,minmax(0,1fr));
    gap: 9px;
    margin-top: 11px;
}

.scope-option > span {
    min-height: 82px;
    display: block;
    padding: 12px 13px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255,255,255,.025);
    transition: .16s ease;
}

.scope-option > span strong,
.scope-option > span small {
    display: block;
}

.scope-option > span strong {
    color: var(--text);
    font-size: 12px;
}

.scope-option > span small {
    margin-top: 5px;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.5;
}

.scope-option.selected > span,
.scope-option input:checked + span {
    border-color: rgba(100,232,255,.40);
    background: rgba(100,232,255,.075);
}

.scope-option.selected > span strong,
.scope-option input:checked + span strong {
    color: var(--cyan);
}

@media (max-width: 900px) {
    .detail-presets {
        grid-template-columns: repeat(3,minmax(0,1fr));
    }
}

@media (max-width: 620px) {
    .detail-presets,
    .scope-options {
        grid-template-columns: 1fr 1fr;
    }

    .custom-detail-row {
        align-items: stretch;
        flex-direction: column;
        gap: 6px;
    }

    .custom-detail-row label {
        min-width: 0;
    }

    .custom-detail-row > small {
        padding-bottom: 0;
    }
}


/* ================================================================
   v11 reliable inspection workspace
   ================================================================ */
.document-viewer {
    height: clamp(620px, 72vh, 860px);
    min-height: 0;
    max-height: none;
}
.page-list,
.source-stage,
.text-stage {
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}
.page-list { overflow-x: hidden; overflow-y: auto; }
.source-stage { align-content: start; align-items: start; justify-items: center; }
.text-stage { overflow-x: hidden; overflow-y: auto; }
.ocr-clean-text,
.ocr-raw-text {
    margin: 0;
    padding: 0;
    max-height: none;
    overflow: visible;
    border: 0;
    background: transparent;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: normal;
    tab-size: 4;
}
.ocr-clean-text {
    color: #e8edf8;
    font: 14px/1.72 Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
}
.ocr-raw-text {
    color: #dce3f1;
    font: 13px/1.62 ui-monospace,SFMono-Regular,Consolas,"Liberation Mono",monospace;
}
.text-warning {
    margin: 0 0 14px;
    padding: 10px 12px;
    border: 1px solid rgba(255,196,92,.25);
    border-radius: 10px;
    color: #ffe1a0;
    background: rgba(255,196,92,.08);
    font-size: 11px;
    line-height: 1.45;
}
.page-item.warning {
    border-color: rgba(255,196,92,.28);
    background: rgba(255,196,92,.055);
}
.page-item.warning .page-item-status { color: var(--amber); }
.ingestion-notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin: -3px 0 12px;
    padding: 11px 13px;
    border: 1px solid rgba(255,196,92,.22);
    border-radius: 12px;
    background: rgba(255,196,92,.07);
}
.ingestion-notice > div { min-width: 0; }
.ingestion-notice strong,
.ingestion-notice span { display: block; }
.ingestion-notice strong { color: #ffe2a5; font-size: 12px; }
.ingestion-notice span { margin-top: 2px; color: #c8b990; font-size: 11px; }
.ingestion-notice .secondary-button { flex: 0 0 auto; }
@media (max-width: 900px) {
    .document-viewer,
    .document-viewer[data-view-mode="image"],
    .document-viewer[data-view-mode="text"] { height: auto; max-height: none; }
    .page-list { overflow-x: auto; overflow-y: hidden; }
    .ingestion-notice { align-items: flex-start; flex-direction: column; }
}
