/* Shared interaction layer: sheets, clear choices, and touch-first document actions. */
:root { --keyboard-inset: 0px; --workspace-top-gap: 32px; }
.topbar { height: calc(var(--topbar-height) + env(safe-area-inset-top, 0px)); padding-top: env(safe-area-inset-top, 0px); }
.app-main { padding-top: calc(var(--topbar-height) + env(safe-area-inset-top, 0px) + var(--workspace-top-gap)); }
.account-button { border: 1px solid var(--line); cursor: pointer; width: 44px; height: 44px; transition: background .15s, transform .15s; }
.account-button:hover { background: rgba(var(--bs-primary-rgb),.15); }
.account-button:active { transform: scale(.96); }
.navigation-progress { display: none; position: fixed; inset: env(safe-area-inset-top, 0px) auto auto 0; width: 60%; height: 3px; z-index: 1100; background: var(--green); }
.navigating .navigation-progress { display: block; animation: navigation-progress 1s ease-in-out infinite; }
@keyframes navigation-progress { from { transform: translateX(-100%); } to { transform: translateX(180%); } }
.connection-banner { position: sticky; top: calc(var(--topbar-height) + env(safe-area-inset-top,0px)); z-index: 1021; padding: 10px 20px; background: #fff1c9; color: #664d03; text-align: center; font-size: .8rem; }
body.sheet-open { overflow: hidden; }
.app-sheet { width: min(560px, calc(100% - 40px)); max-width: none; max-height: calc(100dvh - 40px - var(--keyboard-inset)); padding: 0; margin: auto; border: 1px solid var(--line); border-radius: 24px; color: var(--text); background: var(--panel); box-shadow: 0 24px 100px rgba(0,0,0,.25); overflow: hidden; }
.app-sheet[open] { display: flex; flex-direction: column; animation: sheet-appear .18s ease-out; }
.app-sheet::backdrop { background: rgba(8,23,44,.45); backdrop-filter: blur(5px); }
@keyframes sheet-appear { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.sheet-header { display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; gap: 16px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.sheet-header h2 { margin: 0; font-size: 1.16rem; font-weight: 700; letter-spacing: -.02em; }
.sheet-close { display: grid; place-items: center; min-width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--bs-tertiary-bg); color: var(--text); }
.sheet-body { padding: 20px 24px 24px; overflow: auto; overscroll-behavior: contain; min-height: 0; }
.sheet-handle { display: none; }
.sheet-document-title { color: var(--muted); overflow-wrap: anywhere; font-size: .86rem; margin-bottom: 18px; }
.sheet-option { display: flex; align-items: center; gap: 15px; text-align: left; width: 100%; min-height: 60px; padding: 14px 12px; color: var(--text); background: transparent; border: 0; border-radius: 12px; font-size: .95rem; }
.sheet-option:hover { background: var(--bs-tertiary-bg); }
.sheet-option > i:first-child { display: grid; place-items: center; width: 34px; font-size: 1.3rem; color: var(--blue); }
.sheet-option.text-danger > i:first-child { color: inherit; }
.sheet-option .option-chevron { margin-left: auto; font-size: .8rem; color: var(--muted); }
.sheet-confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 24px; }
.confirmation-message { line-height: 1.65; margin: 0; }
.sheet-loading, .sheet-empty { padding: 36px 12px; text-align: center; color: var(--muted); }
.sheet-loading { display: flex; gap: 12px; justify-content: center; align-items: center; }
.sheet-empty > i, .sheet-empty > strong { display: block; margin-bottom: 10px; }
.sheet-empty > i { font-size: 1.8rem; }
.people-sheet { height: min(740px, 88dvh); }
.people-sheet .sheet-body, .editor-sheet .sheet-body { padding: 0; }
.sheet-document { display: flex; gap: 12px; padding: 18px 24px 0; align-items: center; }
.sheet-document > i { font-size: 1.5rem; color: var(--blue); }
.sheet-document > div { min-width: 0; }
.sheet-document strong, .sheet-document small { display: block; overflow-wrap: anywhere; }
.sheet-document small { color: var(--muted); margin-top: 4px; }
.people-search { padding: 18px 24px; position: sticky; top: 0; z-index: 2; background: var(--panel); }
.search-field { position: relative; }
.search-field > i { position: absolute; top: 50%; transform: translateY(-50%); left: 14px; color: var(--muted); pointer-events: none; }
.search-field input { padding-left: 40px; }
.people-results { padding: 0 12px; }
.person-option { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 76px; padding: 12px; border: 1px solid transparent; border-radius: 14px; text-align: left; color: var(--text); background: var(--panel); }
.person-option:hover { background: var(--bs-tertiary-bg); }
.person-option > span:nth-child(2) { flex: 1; min-width: 0; }
.person-option strong, .person-option small { display: block; overflow-wrap: anywhere; }
.person-option strong { font-size: .9rem; font-weight: 600; }
.person-option small { font-size: .76rem; color: var(--muted); margin-top: 3px; }
.person-avatar { display: grid; place-items: center; width: 42px; height: 42px; flex-shrink: 0; border-radius: 50%; color: var(--blue); background: rgba(var(--bs-primary-rgb),.08); font-size: 1.3rem; }
.person-check { opacity: 0; color: var(--blue); }
.person-option.selected { border-color: var(--blue); background: rgba(var(--bs-primary-rgb),.07); }
.person-option.selected .person-check { opacity: 1; }
.people-pagination { display: flex; gap: 8px; align-items: center; padding: 16px 12px; }
.people-pagination > span { margin-right: auto; }
.sheet-action-form { position: sticky; bottom: 0; padding: 16px 24px max(20px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--panel); z-index: 3; }
.sheet-action-form > p { font-size: .76rem; margin-bottom: 12px; }
.editor-sheet { width: min(840px, calc(100% - 40px)); }
.editor-sheet .editor-card { border: 0; border-radius: 0; box-shadow: none; }
.editor-sheet .card-header { border-radius: 0; }
.editor-sheet .app-action-bar { position: sticky; bottom: 0; background: var(--panel); z-index: 2; }
.copies-stepper { display: flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--panel); }
.copies-stepper .btn { border: 0; min-width: 48px; border-radius: 0; color: var(--blue); }
.copies-stepper input { min-width: 0; text-align: center; font-size: 1.05rem; font-weight: 650; border: 0; border-radius: 0; appearance: textfield; }
.copies-stepper input::-webkit-inner-spin-button { appearance: none; }
.segmented-control { display: flex; flex-wrap: wrap; padding: 4px; gap: 4px; border: 1px solid var(--line); border-radius: 13px; background: var(--bs-tertiary-bg); }
.segment-option { flex: 1 1 100px; border: 0; border-radius: 9px; min-height: 42px; padding: 9px 10px; font-size: .78rem; font-weight: 600; color: var(--muted); background: transparent; }
.segment-option[aria-pressed="true"] { color: var(--blue); background: var(--panel); box-shadow: 0 1px 6px rgba(0,0,0,.08); }
.segment-option:disabled { opacity: .4; }
.finishing-toggle { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; min-height: 44px; padding-left: 0; }
.finishing-toggle .form-check-input { float: none; margin: 0; }
.finishing-toggle small { flex-basis: 100%; }
.filter-count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 50%; color: white; background: var(--blue); font-size: .7rem; }
.filter-count[hidden] { display: none; }
.app-notifications { position: fixed; z-index: 1200; right: 24px; top: calc(var(--topbar-height) + env(safe-area-inset-top,0px) + 16px); width: min(420px, calc(100% - 32px)); display: grid; gap: 10px; pointer-events: none; }
.app-toast { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-radius: 16px; border: 1px solid var(--line); background: var(--panel); color: var(--text); box-shadow: 0 8px 32px rgba(0,0,0,.13); font-size: .86rem; pointer-events: auto; animation: sheet-appear .18s ease-out; }
.app-toast > i { color: var(--green); font-size: 1.25rem; }
.app-toast-error > i { color: var(--bs-danger); }
.app-toast > span { flex: 1; overflow-wrap: anywhere; }
.app-toast .btn-close { flex-shrink: 0; min-width: 24px; min-height: 24px; font-size: .65rem; }
.release-receipt { overflow: hidden; text-align: center; }
.receipt-symbol { display: grid; place-items: center; width: 86px; height: 86px; margin: 36px auto 20px; border-radius: 28px; color: var(--blue); background: rgba(var(--bs-primary-rgb),.09); font-size: 2.5rem; }
.receipt-content { padding: 0 24px 28px; }
.receipt-content h2 { font-size: clamp(1.5rem,3vw,2rem); font-weight: 700; margin: 14px 0; }
.receipt-document { overflow-wrap: anywhere; font-weight: 600; }
.receipt-timeline { display: flex; justify-content: center; gap: 12px; margin: 28px 0 0; }
.receipt-timeline > span { flex: 1; padding: 18px 12px; border: 1px solid var(--line); border-radius: 15px; color: var(--muted); }
.receipt-timeline i { display: block; font-size: 1.5rem; margin-bottom: 8px; }
.receipt-timeline .done { border-color: var(--green); color: var(--green); background: rgba(var(--bs-success-rgb),.04); }
.release-receipt[data-state="completed"] .receipt-symbol { color: var(--green); background: rgba(var(--bs-success-rgb),.09); }
.release-receipt[data-state="failed"] .receipt-symbol, .release-receipt[data-state="outcome_unknown"] .receipt-symbol { color: var(--bs-danger); background: rgba(var(--bs-danger-rgb),.08); }
.release-receipt[data-state="submitting"] .receipt-symbol { animation: gentle-pulse 1.8s ease-in-out infinite; }
@keyframes gentle-pulse { 50% { opacity: .5; } }
.jobs-table .job-actions { min-width: 180px; }
.jobs-table .job-more { min-width: 75px; }
.job-actions .btn { transition: background .15s, transform .15s; }
.job-actions .btn:active { transform: scale(.97); }
@media (max-width: 991.98px) {
  :root { --workspace-top-gap: 26px; }
  .app-notifications { top: auto; bottom: calc(100px + env(safe-area-inset-bottom,0px)); right: 16px; }
  .app-action-bar { position: sticky; bottom: calc(88px + env(safe-area-inset-bottom,0px)); z-index: 20; background: var(--panel); }
  .editor-sheet .app-action-bar { bottom: 0; }
  .keyboard-open .mobile-navigation { visibility: hidden; }
}
@media (max-width: 767.98px) {
  .client-workspace .topbar-context small { display: none; }
  .client-workspace .topbar-context strong { font-size: 1.05rem; }
  .client-workspace .dashboard-stats { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 8px; margin-inline: 0; }
  .client-workspace .dashboard-stats > div { width: auto; padding: 0; margin: 0; }
  .client-workspace .dashboard-stats .card-body { padding: 12px 8px; }
  .client-workspace .dashboard-stats .stat-label { min-height: 2.5em; padding-right: 0; font-size: .63rem; }
  .client-workspace .dashboard-stats .stat-value { font-size: 1.6rem; margin: 6px 0 0; }
  .client-workspace .dashboard-stats small, .client-workspace .dashboard-stats .stat-icon { display: none; }
  .app-sheet { position: fixed; top: auto; left: 0; right: 0; bottom: var(--keyboard-inset); width: 100%; max-height: calc(100dvh - env(safe-area-inset-top,0px) - var(--keyboard-inset) - 12px); margin: 0; border-radius: 25px 25px 0 0; border-bottom: 0; }
  .sheet-handle { display: block; flex-shrink: 0; width: 38px; height: 5px; border-radius: 4px; margin: 10px auto 0; background: var(--line); }
  .sheet-header { padding: 14px 20px; }
  .sheet-body { padding: 16px 20px max(24px,env(safe-area-inset-bottom,0px)); }
  .people-sheet { height: 88dvh; }
  .people-sheet .sheet-body, .editor-sheet .sheet-body { padding: 0; }
  .sheet-document { padding-inline: 20px; }
  .people-search { padding: 14px 20px; }
  .sheet-action-form { padding-inline: 20px; }
  .editor-sheet .card-header, .editor-sheet .card-body, .editor-sheet .card-footer { padding: 18px 20px; }
  .editor-sheet .app-action-bar { flex-wrap: wrap; }
  .editor-sheet .app-action-bar > * { flex: 1; white-space: nowrap; }
  .editor-sheet .app-action-bar > button { flex-basis: 100%; }
  .editor-sheet .row > [class*="col-"] { width: 100%; }
  .jobs-table tr { border-radius: 18px; box-shadow: 0 2px 8px rgba(18,42,72,.035); }
  .jobs-table .job-actions .job-action-release { flex: 2; min-height: 44px; font-size: .86rem; }
  .jobs-table .job-actions .job-more { flex: 1; font-size: .86rem; }
  .jobs-table .job-document { grid-column: 1/-1; }
  .jobs-table .job-status { grid-column: 1/-1; grid-row: auto; text-align: left; }
  .jobs-table .job-settings { grid-row: 2; }
  .receipt-timeline { gap: 7px; }
  .receipt-timeline > span { padding: 12px 4px; font-size: .74rem; }
  .release-receipt .card-footer > .btn-primary { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .app-sheet[open], .app-toast, .release-receipt .receipt-symbol, .navigation-progress { animation: none !important; }
  .account-button, .job-actions .btn { transition: none; }
}
@media print { .app-sheet, .app-notifications, .connection-banner, .navigation-progress { display: none !important; } .app-action-bar { position: static; } }

/* Keep the recipient decision at the bottom without covering the people list. */
.people-sheet .sheet-body { display: flex; flex-direction: column; flex: 1; }
.people-sheet .sheet-document, .people-sheet .people-search, .people-sheet .sheet-action-form { flex-shrink: 0; }
.people-sheet .people-results { flex: 1 0 auto; }
.app-sheet .btn-sm { min-height: 44px; }
.release-receipt .app-action-bar { position: static; }
@media (max-width:767.98px) {
  .receipt-symbol { width: 72px; height: 72px; margin-top: 24px; font-size: 2.1rem; }
  .receipt-content { padding-bottom: 20px; }
  .receipt-content > [data-release-reason] { font-size: .88rem; }
  .receipt-timeline { margin-top: 20px; }
  .receipt-timeline > span { padding-block: 10px; }
}

/* Bounded lookup menus remain usable on phones and with long directory names. */
.report-picker-control { position: relative; }
.report-picker-popup { position: absolute; top: calc(100% + 4px); inset-inline: 0; z-index: 1010; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: 0 12px 32px rgba(0,0,0,.2); overflow: hidden; }
.report-picker-popup.opens-up { top: auto; bottom: calc(100% + 4px); }
[data-report-picker] [role=listbox] { max-height: var(--picker-height,17rem); overflow-y: auto; overscroll-behavior: contain; }
.report-picker-popup [data-picker-message] { border-top: 1px solid var(--line); }
[data-report-picker] [role=option] { min-height: 44px; }
.app-sheet .release-steps { padding: 16px 20px 0; }
.app-sheet .release-receipt { margin: 0; border: 0; box-shadow: none; }
.preview-sheet { width:min(980px,calc(100% - 40px)); height:min(920px,calc(100dvh - 40px)); }
.preview-sheet .sheet-body { padding:0; overflow:hidden; display:flex; flex-direction:column; min-height:0; flex:1; }
.preview-content { display:flex; flex-direction:column; min-height:0; height:min(820px,78dvh); }
.preview-sheet .preview-content { flex:1; height:auto; overflow:hidden; }
.preview-heading { padding:12px 20px; flex-shrink:0; }
.preview-heading strong { display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.preview-heading small { display:block; color:var(--bs-secondary-color); font-size:.78rem; margin-top:3px; }
.preview-content .document-preview { display:flex; flex-direction:column; flex:1; height:auto; min-height:0; position:relative; }
.pdf-stage { flex:1; min-height:0; overflow:auto; overscroll-behavior:contain; padding:12px; display:flex; background:var(--bs-tertiary-bg); }
.pdf-stage canvas { flex:none; margin:auto; box-shadow:0 2px 12px #0002; background:white; }
.preview-content .pdf-message { position:absolute; inset:0 0 64px; display:grid; place-items:center; pointer-events:none; }
.preview-content .pdf-message[hidden] { display:none; }
.preview-content .pdf-toolbar { flex-shrink:0; justify-content:space-between; flex-wrap:wrap; gap:8px; padding:8px 16px; background:var(--panel); border-top:1px solid var(--line); border-bottom:0; }
.pdf-controls { display:flex; align-items:center; gap:6px; }
.pdf-controls .btn { min-height:44px; min-width:44px; padding:6px 10px; }
.pdf-controls [data-pdf-count] { min-width:88px; text-align:center; font-size:.82rem; font-variant-numeric:tabular-nums; }
.preview-actions { display:flex; justify-content:flex-end; gap:10px; padding:12px 20px; border-top:1px solid var(--line); flex-shrink:0; }
.preview-actions:empty { display:none; }
.sides-choices { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; }
.sides-choice { cursor:pointer; position:relative; margin:0; }
.sides-choice input { position:absolute; top:16px; right:12px; accent-color:var(--bs-primary); width:17px; height:17px; z-index:1; }
.sides-choice span { display:flex; flex-direction:column; height:100%; padding:14px; border:1px solid var(--line); border-radius:14px; background:var(--panel); }
.sides-choice i { font-size:1.3rem; color:var(--bs-primary); margin-bottom:8px; }
.sides-choice strong { font-size:.9rem; }
.sides-choice small { color:var(--bs-secondary-color); margin-top:4px; line-height:1.4; }
.sides-choice input:checked + span { border-color:var(--bs-primary); background:var(--bs-primary-bg-subtle); box-shadow:inset 0 0 0 1px var(--bs-primary); }
.sides-choice input:focus-visible + span { outline:3px solid var(--bs-primary); outline-offset:3px; }
.sides-choice input:disabled + span { opacity:.5; cursor:not-allowed; }
@media (max-width:575.98px) {
.preview-sheet { width:100%; height:calc(100dvh - env(safe-area-inset-top,0px) - 12px); }
.preview-heading { padding:10px 16px; }
.preview-content .pdf-toolbar { padding:8px; gap:4px; }
.pdf-controls { gap:2px; }
.pdf-controls .btn { padding:6px; min-width:40px; }
.pdf-controls [data-pdf-count] { min-width:80px; }
.preview-actions { padding:10px 16px max(10px,env(safe-area-inset-bottom)); }
.preview-actions > * { flex:1; }
.sides-choices { grid-template-columns:1fr; }
.sides-choice span { padding:12px 40px 12px 48px; position:relative; }
.sides-choice i { position:absolute; left:15px; top:17px; margin:0; }
.sides-choice small { margin-top:2px; }
}

.job-settings-link { display:block; color:inherit; text-decoration:none; border-radius:8px; padding:4px; margin:-4px; }
.job-settings-link:hover, .job-settings-link:focus-visible { color:var(--bs-primary); background:var(--bs-primary-bg-subtle); }
.jobs-upload { display:grid; grid-template-columns:minmax(190px,1fr) minmax(0,3fr); align-items:center; }
.jobs-upload .card-header { border-bottom:0; background:none; }
.jobs-upload .card-header > i { display:none; }
.jobs-upload .card-body { padding:16px 20px; }
@media(max-width:767.98px) { .jobs-upload { grid-template-columns:1fr; } .jobs-upload .card-header { padding-bottom:0; } .jobs-upload .card-body form > button { width:100%; } }

/* Let the camera use the space left after the release controls. */
.app-sheet:has(.scanner-card) { height: min(820px, calc(100dvh - 40px - var(--keyboard-inset))); }
.app-sheet:has(.scanner-card) .sheet-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.app-sheet:has(.scanner-card) [data-sheet-content] { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.app-sheet:has(.scanner-card) .release-steps { flex-shrink: 0; margin-bottom: 12px; }
.app-sheet .scanner-card { display: flex; flex-direction: column; flex: 1; min-height: 0; margin: 0; }
.app-sheet .scanner-card .card-header, .app-sheet .scanner-card .card-footer { flex-shrink: 0; padding: 12px 20px; }
.app-sheet .scanner-card .card-header h2 { display: none; }
.app-sheet .scanner-card .card-header p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-sheet .scanner-card .card-body { display: flex; flex-direction: column; flex: 1; min-height: 140px; padding: 12px 20px; }
.app-sheet .scanner-frame { flex: 1; min-height: 72px; max-height: none; aspect-ratio: auto; }
.app-sheet .scanner-placeholder { padding: 8px; }
.app-sheet .scanner-placeholder > i { padding: 10px; font-size: 1.8rem; margin-bottom: 6px; border-radius: 14px; }
.app-sheet .scanner-placeholder p { margin: 0; font-size: .8rem; }
.app-sheet .camera-controls, .app-sheet #scanner-message { flex-shrink: 0; }
.app-sheet .scanner-exit { display: none; }
@media (max-width: 575.98px) {
  .app-sheet:has(.scanner-card) { height: calc(100dvh - env(safe-area-inset-top, 0px) - var(--keyboard-inset) - 12px); }
}
@media (max-height: 650px) {
  .app-sheet:has(.scanner-card) .release-steps { display: none; }
  .app-sheet .scanner-card .card-header { padding-top: 6px; padding-bottom: 6px; }
  .app-sheet .scanner-card .camera-controls { margin-top: 8px !important; }
  .app-sheet .scanner-card #scanner-message { margin-top: 6px !important; font-size: .75rem; }
  .app-sheet .scanner-card .camera-controls .form-label { display: none; }
  .app-sheet .scanner-placeholder > i { padding: 4px; font-size: 1.3rem; }
}

/* Keep the mobile document list ahead of secondary submission controls. */
@media (max-width:767.98px) {
  .jobs-workspace { display:flex; flex-direction:column; gap:16px; }
  .jobs-workspace > .queue-views { display:none; }
  .jobs-workspace > .jobs-directory { order:0; min-width:0; }
  .jobs-workspace > .jobs-upload { order:1; margin-bottom:0 !important; }
  .jobs-directory > .card-header { padding:12px 16px; }
  .jobs-directory > .card-header p { display:none; }
  .jobs-directory .job-filters { padding:12px 16px; display:block; }
  .jobs-directory .filter-search > label { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
  .jobs-directory .job-filter-options { margin-top:10px; }
  .jobs-directory .job-filter-options > .row { display:grid; grid-template-columns:minmax(0,1.3fr) minmax(0,1fr) minmax(65px,.6fr); gap:8px; margin:0; }
  .jobs-directory .job-filter-options > .row > div { width:auto; min-width:0; padding:0; margin:0; }
  .jobs-directory .job-filter-options .form-label { font-size:.75rem; margin-bottom:4px; }
  .jobs-directory .job-filter-options .form-select { min-height:44px; padding-left:8px; padding-right:24px; font-size:.8rem; background-position:right 6px center; }
}
