/* BB Invoice Verification 22.9.7
 * Consolidated stylesheet: same UI/structure, fewer repeated declarations.
 * PDF.js canvas viewer with Elementor-resistant controls and light/dark theme support.
 */

.bbiv-shell,
.bbiv-shell *,
.bbiv-shell *::before,
.bbiv-shell *::after {
    box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   Design tokens
   -------------------------------------------------------------------------- */
.bbiv-shell,
.theme-light .bbiv-shell,
.bbiv-shell.theme-light {
    --bbiv-bg: #eef1f5;
    --bbiv-panel: rgba(255,255,255,.96);
    --bbiv-panel-solid: #ffffff;
    --bbiv-panel-2: #f7f8fa;
    --bbiv-panel-hover: #eef1f5;
    --bbiv-stage: #e7ebf0;
    --bbiv-border: rgba(15,23,42,.11);
    --bbiv-border-strong: rgba(15,23,42,.18);
    --bbiv-text: #151922;
    --bbiv-muted: #6d7480;
    --bbiv-subtle: #8f96a2;
    --bbiv-accent: #0070ee;
    --bbiv-accent-hover: #0099ff;
    --bbiv-success: #00bb00;
    --bbiv-danger: #c43f4a;
    --bbiv-danger-bg: rgba(196,63,74,.08);
    --bbiv-loader-bg: rgba(255,255,255,.86);
    --bbiv-grid-minor: rgba(15,23,42,.035);
    --bbiv-grid-major: rgba(15,23,42,.060);
    --bbiv-paper-shadow: 0 1px 2px rgba(15,23,42,.10), 0 7px 20px rgba(15,23,42,.11);
}

.theme-dark .bbiv-shell,
.bbiv-shell.theme-dark {
    --bbiv-bg: #12151a;
    --bbiv-panel: rgba(25,29,35,.96);
    --bbiv-panel-solid: #191d23;
    --bbiv-panel-2: #22272f;
    --bbiv-panel-hover: #2a3039;
    --bbiv-stage: #101318;
    --bbiv-border: rgba(255,255,255,.10);
    --bbiv-border-strong: rgba(255,255,255,.18);
    --bbiv-text: #f3f5f7;
    --bbiv-muted: #a5adb9;
    --bbiv-subtle: #7f8895;
    --bbiv-accent: #0099ff;
    --bbiv-accent-hover: #0070ee;
    --bbiv-success: #00bb00;
    --bbiv-danger: #ef6a74;
    --bbiv-danger-bg: rgba(239,106,116,.10);
    --bbiv-loader-bg: rgba(25,29,35,.88);
    --bbiv-grid-minor: rgba(255,255,255,.030);
    --bbiv-grid-major: rgba(255,255,255,.055);
    --bbiv-paper-shadow: 0 1px 2px rgba(0,0,0,.32), 0 8px 22px rgba(0,0,0,.26);
}

.bbiv-shell {
    /* Typography lives here once and is inherited by child contexts. */
    --bbiv-font-text: "BB Text";
    --bbiv-font-display: "BB Display";

    --bbiv-size-12: 12px;
    --bbiv-line-12: 1.333334;
    --bbiv-track-12: -0.01em;

    --bbiv-size-14: 14px;
    --bbiv-line-14: 1.428572;
    --bbiv-track-14: -0.016em;

    --bbiv-size-17: 17px;
    --bbiv-line-17: 1.1764706;
    --bbiv-track-17: -0.022em;

    --bbiv-size-24: 24px;
    --bbiv-line-24: 1.166667;
    --bbiv-track-display: 0.01em;

    --bbiv-control-h: 30px;
    --bbiv-mobile-control-h: 24px;
    --bbiv-lookup-control-h: 36px;

    position: relative;
    left: auto;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: min(980px, calc(100vw - 48px));
    max-width: 980px;
    min-width: 0;
    height: calc(100vh - 48px);
    min-height: 560px;
    margin: 24px auto;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--bbiv-border);
    border-radius: 14px;
    background: var(--bbiv-bg);
    color: var(--bbiv-text);
    box-shadow: none;
    font-family: var(--bbiv-font-text);
    font-size: var(--bbiv-size-14);
    font-weight: 400;
    line-height: var(--bbiv-line-14);
    letter-spacing: var(--bbiv-track-14);
    text-align: left;
    isolation: isolate;
    contain: layout paint style;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

@supports not (width: min(980px, 100%)) {
    .bbiv-shell {
        width: calc(100vw - 48px);
        max-width: 980px;
    }
}

.bbiv-shell:fullscreen {
    left: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
}

/* --------------------------------------------------------------------------
   Elementor/theme isolation via scoped element selectors
   -------------------------------------------------------------------------- */
.bbiv-shell button.bbiv-btn,
.bbiv-shell a.bbiv-btn,
.bbiv-shell input.bbiv-search-input {
    all: unset;
    box-sizing: border-box;
    font: inherit;
    -webkit-font-smoothing: antialiased;
}

.bbiv-shell button.bbiv-btn,
.bbiv-shell a.bbiv-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    min-width: var(--bbiv-control-h);
    height: var(--bbiv-control-h);
    margin: 0;
    padding: 0 9px;
    border: 1px solid var(--bbiv-border);
    border-radius: 7px;
    background: var(--bbiv-panel-2);
    color: var(--bbiv-text);
    box-shadow: none;
    text-decoration: none;
    text-transform: none;
    text-shadow: none;
    letter-spacing: inherit;
    font-weight: 400;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: background-color .14s ease, border-color .14s ease, color .14s ease, transform .08s ease;
}

.bbiv-shell button.bbiv-btn:hover,
.bbiv-shell a.bbiv-btn:hover {
    border-color: var(--bbiv-border-strong);
    background: var(--bbiv-panel-hover);
    color: var(--bbiv-text);
}

.bbiv-shell button.bbiv-btn:active,
.bbiv-shell a.bbiv-btn:active {
    transform: translateY(1px);
}

.bbiv-shell button.bbiv-btn:focus-visible,
.bbiv-shell a.bbiv-btn:focus-visible,
.bbiv-shell input.bbiv-search-input:focus-visible {
    outline: 2px solid var(--bbiv-accent);
    outline-offset: 2px;
    border-color: var(--bbiv-accent);
    box-shadow: none;
}

.bbiv-shell button.bbiv-btn:disabled {
    opacity: .34;
    cursor: default;
}

.bbiv-shell .bbiv-btn.bbiv-btn-icon {
    width: var(--bbiv-control-h);
    min-width: var(--bbiv-control-h);
    padding: 0;
}

.bbiv-shell .bbiv-btn.bbiv-btn-icon.download-pdf {
    color: #fff;
    background: var(--bbiv-accent);
    border-color: var(--bbiv-accent);
}

.bbiv-shell .bbiv-btn.bbiv-btn-icon.download-pdf:hover {
    background: var(--bbiv-accent-hover);
    border-color: var(--bbiv-accent-hover);
}


.bbiv-shell .bbiv-btn.bbiv-btn-icon.open-original-pdf {
    color: var(--bbiv-accent);
    border-color: var(--bbiv-accent);
}

.bbiv-icon {
    display: block;
    width: 16px;
    height: 16px;
    margin: 0;
    padding: 0;
    overflow: visible;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.85;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
    pointer-events: none;
}

.bbiv-shell .bbiv-btn.bbiv-btn-primary {
    gap: 6px;
    min-width: 70px;
    border-color: var(--bbiv-accent);
    background: var(--bbiv-accent);
    color: #fff;
}

.bbiv-shell .bbiv-btn.bbiv-btn-primary:hover {
    border-color: var(--bbiv-accent-hover);
    background: var(--bbiv-accent-hover);
    color: #fff;
}

.bbiv-shell .bbiv-btn.bbiv-zoom-label {
    min-width: 54px;
    padding: 0 7px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}


/* --------------------------------------------------------------------------
   Verified viewer toolbar
   -------------------------------------------------------------------------- */
.bbiv-toolbar {
    position: relative;
    z-index: 20;
    flex: 0 0 auto;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-bottom: 1px solid var(--bbiv-border);
    background: var(--bbiv-panel);
    box-shadow: none;
    font-family: var(--bbiv-font-text);
    font-size: var(--bbiv-size-12);
    font-weight: 400;
    line-height: var(--bbiv-line-12);
    letter-spacing: var(--bbiv-track-12);
    -webkit-backdrop-filter: blur(16px) saturate(1.15);
    backdrop-filter: blur(16px) saturate(1.15);
    transform: translateZ(0);
}

.bbiv-toolbar::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, var(--bbiv-accent) 46%, transparent 100%);
    opacity: 0;
    transform: translateX(-58%) scaleX(.32);
    pointer-events: none;
}

.bbiv-shell.bbiv-is-rendering .bbiv-toolbar::after {
    opacity: .72;
    animation: bbiv-progress 1.2s cubic-bezier(.4,0,.2,1) infinite;
}

.bbiv-toolbar-row {
    display: flex;
    align-items: center;
    width: 100%;
    min-width: 0;
    margin: 0;
}

.bbiv-toolbar-main {
    min-height: 46px;
    gap: 8px;
    padding: 7px 9px;
}

.bbiv-tools-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    max-width: 100%;
    gap: 4px;
    margin: 0;
    padding: 0 1px 2px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--bbiv-muted) 45%, transparent) transparent;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-inline: contain;
    scroll-behavior: smooth;
    touch-action: pan-x pan-y pinch-zoom;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.bbiv-tools-row.bbiv-is-tool-dragging {
    cursor: grabbing;
    scroll-behavior: auto;
}

.bbiv-tools-row::-webkit-scrollbar {
    height: 4px;
}

.bbiv-tools-row::-webkit-scrollbar-track {
    background: transparent;
}

.bbiv-tools-row::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: color-mix(in srgb, var(--bbiv-muted) 38%, transparent);
}

.bbiv-tools-row:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--bbiv-accent) 65%, transparent);
    outline-offset: 2px;
}

.bbiv-actions-separator {
    display: block;
}

.bbiv-status-block {
    display: flex;
    align-items: center;
    gap: 7px;
    flex: 0 1 190px;
    min-width: 150px;
    margin: 0;
}

.bbiv-verified-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 24px;
    width: 24px;
    height: 24px;
    margin: 0;
    padding: 0;
    border: 0;
    outline: 0;
    border-radius: 50%;
    background: #00bb00;
    color: #fff;
    box-shadow: none;
}

.bbiv-verified-dot .bbiv-icon {
    width: 14px;
    height: 14px;
    stroke-width: 2.3;
}

.bbiv-status-text {
    min-width: 0;
}

.bbiv-status-text strong,
.bbiv-status-text span {
    display: block;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
}

.bbiv-status-text strong {
    font-weight: 600;
    letter-spacing: inherit;
}

.bbiv-status-text span {
    margin-top: 3px;
    overflow: hidden;
    color: var(--bbiv-muted);
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bbiv-toolbar-center {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex: 0 0 auto;
    width: max-content;
    min-width: max-content;
    gap: 5px;
}

.bbiv-toolbar-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    flex: 0 0 auto;
    gap: 3px;
    margin: 0;
    padding: 0;
}

.bbiv-separator {
    display: block;
    flex: 0 0 1px;
    width: 1px;
    height: 18px;
    margin: 0 2px;
    background: var(--bbiv-border);
}

/* --------------------------------------------------------------------------
   Search forms
   -------------------------------------------------------------------------- */
.bbiv-shell form.bbiv-search-form {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
}

.bbiv-shell form.bbiv-search-form-toolbar {
    flex: 0 1 280px;
    width: min(280px, 24vw);
    min-width: 180px;
    max-width: 300px;
}

.bbiv-shell form.bbiv-search-form-lookup {
    width: 100%;
    max-width: 510px;
}

.bbiv-shell input.bbiv-search-input {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    height: var(--bbiv-control-h);
    margin: 0;
    padding: 0 9px;
    border: 1px solid var(--bbiv-border);
    border-radius: 7px;
    background: var(--bbiv-panel-solid);
    color: var(--bbiv-text);
    box-shadow: none;
    font-weight: 400;
    text-transform: none;
    letter-spacing: inherit;
}

.bbiv-shell input.bbiv-search-input::placeholder {
    color: var(--bbiv-subtle);
    opacity: 1;
}

/* --------------------------------------------------------------------------
   PDF stage and canvas
   -------------------------------------------------------------------------- */
.bbiv-stage {
    position: relative;
    z-index: 1;
    display: block;
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    outline: 0;
    background: var(--bbiv-stage);
    cursor: grab;
    touch-action: none;
    overscroll-behavior: none;
    user-select: none;
    -webkit-user-select: none;
    transform: translateZ(0);
    contain: layout paint style;
}

.bbiv-stage::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    background-image:
        linear-gradient(to right, var(--bbiv-grid-minor) 1px, transparent 1px),
        linear-gradient(to bottom, var(--bbiv-grid-minor) 1px, transparent 1px),
        linear-gradient(to right, var(--bbiv-grid-major) 1px, transparent 1px),
        linear-gradient(to bottom, var(--bbiv-grid-major) 1px, transparent 1px),
        radial-gradient(circle at 50% 34%, color-mix(in srgb, var(--bbiv-text) 4%, transparent), transparent 38%);
    background-size: 24px 24px, 24px 24px, 120px 120px, 120px 120px, 100% 100%;
    background-position: center center;
    pointer-events: none;
}

.bbiv-stage.bbiv-is-panning {
    cursor: grabbing;
}

.bbiv-canvas {
    position: absolute;
    top: 21px;
    left: 0;
    z-index: 1;
    display: block;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: #fff;
    box-shadow: none;
    opacity: 0;
    visibility: hidden;
    transform-origin: 0 0;
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    image-rendering: auto;
    color-scheme: only light;
    forced-color-adjust: none;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
    pointer-events: none;
    transition: none;
}

.bbiv-canvas.bbiv-canvas-visible {
    z-index: 2;
    opacity: 1;
    visibility: visible;
    box-shadow: var(--bbiv-paper-shadow);
}

.bbiv-canvas.bbiv-canvas-front {
    z-index: 3;
}

.bbiv-shell.bbiv-is-zooming .bbiv-canvas-visible {
    transition: none;
    filter: none;
}

/* --------------------------------------------------------------------------
   Loading and errors
   -------------------------------------------------------------------------- */
.bbiv-loading,
.bbiv-viewer-error {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 8;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: min(300px, calc(100% - 40px));
    margin: 0;
    padding: 15px 17px;
    border: 1px solid var(--bbiv-border);
    border-radius: 11px;
    background: var(--bbiv-loader-bg);
    color: var(--bbiv-text);
    box-shadow: none;
    font-family: var(--bbiv-font-text);
    font-size: var(--bbiv-size-12);
    font-weight: 400;
    line-height: var(--bbiv-line-12);
    letter-spacing: var(--bbiv-track-12);
    -webkit-backdrop-filter: blur(14px) saturate(1.1);
    backdrop-filter: blur(14px) saturate(1.1);
    text-align: center;
    transform: translate3d(-50%, -50%, 0) scale(.99);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .16s ease, transform .16s ease, visibility 0s linear .16s;
}

.bbiv-shell.bbiv-is-initializing .bbiv-loading,
.bbiv-shell.bbiv-is-rendering .bbiv-loading {
    opacity: 1;
    visibility: visible;
    transform: translate3d(-50%, -50%, 0) scale(1);
    transition-delay: 0s;
}

.bbiv-shell.bbiv-is-zooming .bbiv-loading {
    opacity: 0;
    visibility: hidden;
}

.bbiv-shell.bbiv-has-rendered-page.bbiv-is-rendering .bbiv-loading {
    top: auto;
    left: auto;
    right: 12px;
    bottom: 12px;
    width: auto;
    min-width: 112px;
    flex-direction: row;
    gap: 7px;
    padding: 7px 9px;
    border-radius: 999px;
    transform: translate3d(0,0,0);
}

.bbiv-shell.bbiv-has-rendered-page.bbiv-is-rendering .bbiv-loading .bbiv-spinner {
    width: 13px;
    height: 13px;
    border-width: 1.5px;
}

.bbiv-viewer-error {
    opacity: 1;
    visibility: visible;
    transform: translate3d(-50%, -50%, 0) scale(1);
}

.bbiv-viewer-error[hidden] {
    display: none;
}

.bbiv-viewer-error span {
    color: var(--bbiv-muted);
}

.bbiv-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    border: 2px solid color-mix(in srgb, var(--bbiv-text) 14%, transparent);
    border-top-color: var(--bbiv-text);
    border-radius: 50%;
    animation-name: bbiv-spin;
    animation-duration: .78s;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
    animation-play-state: running;
    transform: translateZ(0) rotate(0deg);
    transform-origin: 50% 50%;
    will-change: transform;
}

.bbiv-loading strong {
    margin: 0;
    color: var(--bbiv-text);
    font-weight: 600;
}

/* --------------------------------------------------------------------------
   Lookup / not-found view
   -------------------------------------------------------------------------- */
.bbiv-lookup-screen {
    display: grid;
    place-items: center;
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    margin: 0;
    padding: 24px;
    overflow: auto;
    background: var(--bbiv-stage);
}

.bbiv-lookup-card {
    width: min(560px, 100%);
    margin: 0;
    padding: 28px;
    border: 1px solid var(--bbiv-border);
    border-radius: 15px;
    background: var(--bbiv-panel-solid);
    box-shadow: none;
    font-family: var(--bbiv-font-text);
    font-size: var(--bbiv-size-14);
    font-weight: 400;
    line-height: var(--bbiv-line-14);
    letter-spacing: var(--bbiv-track-14);
}

.bbiv-lookup-title {
    all: unset;
    display: block;
    margin: 0 0 8px;
    color: var(--bbiv-text);
    font-family: var(--bbiv-font-display);
    font-size: var(--bbiv-size-24);
    font-weight: 600;
    line-height: var(--bbiv-line-24);
    letter-spacing: var(--bbiv-track-display);
}

.bbiv-lookup-copy {
    margin: 0 0 18px;
    padding: 0;
    color: var(--bbiv-muted);
    letter-spacing: inherit;
}

.bbiv-alert {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0 0 16px;
    padding: 10px 12px;
    border-radius: 8px;
    letter-spacing: inherit;
}

.bbiv-alert-error {
    border: 1px solid color-mix(in srgb, var(--bbiv-danger) 38%, transparent);
    background: var(--bbiv-danger-bg);
    color: var(--bbiv-danger);
}

.bbiv-alert strong {
    color: inherit;
    font-weight: 600;
}

.bbiv-alert span {
    font-weight: 400;
}

.bbiv-lookup-card label {
    letter-spacing: inherit;
}

.bbiv-folder-note {
    margin: 12px 0 0;
    padding: 0;
    color: var(--bbiv-muted);
    font-family: var(--bbiv-font-text);
    font-size: var(--bbiv-size-12);
    font-weight: 400;
    line-height: var(--bbiv-line-12);
    letter-spacing: var(--bbiv-track-12);
}

.bbiv-folder-note code {
    display: inline-block;
    margin-left: 4px;
    padding: 3px 5px;
    border: 1px solid var(--bbiv-border);
    border-radius: 5px;
    background: var(--bbiv-panel-2);
    color: var(--bbiv-text);
    font: inherit;
    font-weight: 400;
}

.bbiv-shell .bbiv-lookup-card input.bbiv-search-input,
.bbiv-shell .bbiv-lookup-card button.bbiv-btn,
.bbiv-shell .bbiv-lookup-card a.bbiv-btn {
    height: var(--bbiv-lookup-control-h);
    min-height: var(--bbiv-lookup-control-h);
    border-radius: 8px;
    letter-spacing: inherit;
}

.bbiv-shell .bbiv-lookup-card input.bbiv-search-input {
    padding: 0 10px;
    border: 1px solid var(--bbiv-border);
    background: var(--bbiv-panel-solid);
    color: var(--bbiv-text);
    font-weight: 400;
    caret-color: var(--bbiv-accent);
    transition: border-color .14s ease, background-color .14s ease, color .14s ease, outline-color .14s ease;
}

.bbiv-shell .bbiv-lookup-card input.bbiv-search-input:hover:not(:disabled) {
    border-color: var(--bbiv-border-strong);
    background: var(--bbiv-panel-solid);
}

.bbiv-shell .bbiv-lookup-card input.bbiv-search-input:focus,
.bbiv-shell .bbiv-lookup-card input.bbiv-search-input:focus-visible {
    border-color: var(--bbiv-accent);
    outline: 2px solid var(--bbiv-accent);
    outline-offset: 2px;
    box-shadow: none;
}

.bbiv-shell .bbiv-lookup-card input.bbiv-search-input::selection {
    background: color-mix(in srgb, var(--bbiv-accent) 22%, transparent);
    color: var(--bbiv-text);
}

.bbiv-shell .bbiv-lookup-card button.bbiv-btn.bbiv-btn-primary {
    min-width: 88px;
    padding: 0 12px;
    border: 1px solid var(--bbiv-accent);
    background: var(--bbiv-accent);
    color: #fff;
    font-weight: 600;
    box-shadow: none;
    transform: none;
    transition: background-color .14s ease, border-color .14s ease, color .14s ease, transform .08s ease, outline-color .14s ease;
}

.bbiv-shell .bbiv-lookup-card button.bbiv-btn.bbiv-btn-primary:hover:not(:disabled) {
    border-color: var(--bbiv-accent-hover);
    background: var(--bbiv-accent-hover);
    color: #fff;
}

.bbiv-shell .bbiv-lookup-card button.bbiv-btn.bbiv-btn-primary:focus,
.bbiv-shell .bbiv-lookup-card button.bbiv-btn.bbiv-btn-primary:focus-visible {
    border-color: var(--bbiv-accent);
    outline: 2px solid var(--bbiv-accent);
    outline-offset: 2px;
    box-shadow: none;
}

.bbiv-shell .bbiv-lookup-card button.bbiv-btn.bbiv-btn-primary:active:not(:disabled) {
    background: var(--bbiv-accent-hover);
    border-color: var(--bbiv-accent-hover);
    transform: translateY(1px);
}

.bbiv-shell .bbiv-lookup-card button.bbiv-btn:disabled,
.bbiv-shell .bbiv-lookup-card input.bbiv-search-input:disabled {
    opacity: .48;
    cursor: not-allowed;
}

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

/* --------------------------------------------------------------------------
   Responsive toolbar
   -------------------------------------------------------------------------- */
@media (max-width: 940px) {
    .bbiv-toolbar-main {
        display: grid;
        grid-template-columns: minmax(108px,.72fr) minmax(0,1.72fr);
        grid-template-areas:
            "status search"
            "tools tools";
        align-items: center;
        gap: 4px 6px;
        min-height: 0;
        padding: 5px 6px;
        overflow: hidden;
    }

    .bbiv-status-block {
        grid-area: status;
        flex: none;
        width: 100%;
        min-width: 0;
        max-width: none;
        gap: 5px;
        white-space: nowrap;
    }

    .bbiv-verified-dot {
        flex-basis: 20px;
        width: 20px;
        height: 20px;
    }

    .bbiv-verified-dot .bbiv-icon {
        width: 12px;
        height: 12px;
    }

    .bbiv-status-text {
        display: flex;
        align-items: center;
        min-width: 0;
        gap: 5px;
        overflow: hidden;
    }

    .bbiv-status-text strong,
    .bbiv-status-text span {
        display: inline-block;
        min-width: 0;
        margin: 0;
        white-space: nowrap;
    }

    .bbiv-status-text strong {
        flex: 0 0 auto;
    }

    .bbiv-status-text span {
        flex: 1 1 auto;
        max-width: none;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .bbiv-shell form.bbiv-search-form-toolbar {
        grid-area: search;
        display: flex;
        flex: none;
        width: 100%;
        min-width: 0;
        max-width: none;
        gap: 4px;
    }

    .bbiv-shell form.bbiv-search-form-toolbar input.bbiv-search-input {
        min-width: 0;
    }

    .bbiv-search-form-toolbar .bbiv-btn-primary {
        flex: 0 0 auto;
        min-width: 54px;
        padding-inline: 7px;
    }

    .bbiv-tools-row {
        grid-area: tools;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        width: 100%;
        min-width: 0;
        gap: 4px;
        margin: 0;
        padding: 0 0 1px;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        scrollbar-width: thin;
        -ms-overflow-style: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-inline: contain;
        scroll-snap-type: none;
        touch-action: pan-x pan-y pinch-zoom;
    }

    .bbiv-tools-row::-webkit-scrollbar {
        display: block;
        height: 3px;
    }

    .bbiv-toolbar-center,
    .bbiv-toolbar-actions {
        display: inline-flex;
        align-items: center;
        flex: 0 0 auto;
        width: auto;
        min-width: max-content;
        max-width: none;
        margin: 0;
        padding: 0;
        overflow: visible;
        gap: 3px;
        justify-content: flex-start;
    }

    .bbiv-toolbar-center { scroll-snap-align: start; }
    .bbiv-toolbar-actions { scroll-snap-align: end; }

    .bbiv-actions-separator,
    .bbiv-fit-separator {
        display: block;
        flex: 0 0 1px;
    }
}

@media (max-width: 760px) {
    .bbiv-shell {
        min-height: 420px;
    }

    .bbiv-toolbar-main {
        grid-template-columns: minmax(126px,.95fr) minmax(0,1.05fr);
        gap: 3px 4px;
        padding: 3px 4px;
    }

    .bbiv-status-block,
    .bbiv-search-form-toolbar,
    .bbiv-tools-row,
    .bbiv-toolbar-center,
    .bbiv-toolbar-actions {
        min-height: var(--bbiv-mobile-control-h);
    }

    .bbiv-status-block {
        gap: 4px;
    }

    .bbiv-shell .bbiv-verified-dot {
        flex: 0 0 16px;
        width: 16px;
        min-width: 16px;
        max-width: 16px;
        height: 16px;
        min-height: 16px;
        max-height: 16px;
        border: 0;
        outline: 0;
        background: #00bb00;
        box-shadow: none;
    }

    .bbiv-shell .bbiv-verified-dot .bbiv-icon {
        width: 12px;
        height: 12px;
    }

    .bbiv-status-text {
        gap: 3px;
    }

    .bbiv-shell button.bbiv-btn,
    .bbiv-shell a.bbiv-btn {
        min-width: var(--bbiv-mobile-control-h);
        height: var(--bbiv-mobile-control-h);
        padding: 0 6px;
        border-radius: 6px;
    }

    .bbiv-shell .bbiv-btn.bbiv-btn-icon {
        width: var(--bbiv-mobile-control-h);
        min-width: var(--bbiv-mobile-control-h);
        max-width: var(--bbiv-mobile-control-h);
        padding: 0;
    }

    .bbiv-shell .bbiv-btn.bbiv-btn-primary {
        gap: 6px;
        min-width: 30px;
        height: var(--bbiv-mobile-control-h);
        padding: 0 6px;
    }

    .bbiv-shell form.bbiv-search-form-toolbar button.bbiv-search-button {
        flex: 0 0 30px;
        width: 30px;
        min-width: 30px;
        max-width: 30px;
        height: var(--bbiv-mobile-control-h);
        padding: 0;
        border-radius: 6px;
        aspect-ratio: auto;
    }

    .bbiv-shell form.bbiv-search-form-toolbar button.bbiv-search-button > span {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0,0,0,0);
        white-space: nowrap;
        border: 0;
    }

    .bbiv-shell input.bbiv-search-input {
        height: var(--bbiv-mobile-control-h);
        min-height: var(--bbiv-mobile-control-h);
        padding: 0 6px;
    }

    .bbiv-shell .bbiv-btn.bbiv-zoom-label {
        min-width: 44px;
        height: var(--bbiv-mobile-control-h);
        padding: 0 5px;
    }


    .bbiv-icon {
        width: 14px;
        height: 14px;
    }

    .bbiv-toolbar-center,
    .bbiv-toolbar-actions {
        height: var(--bbiv-mobile-control-h);
        gap: 2px;
    }

    .bbiv-tools-row {
        gap: 2px;
        padding-bottom: 0;
    }

    .bbiv-separator {
        height: 14px;
        margin: 0 1px;
    }
}

@media (max-width: 520px) {
    .bbiv-shell {
        width: calc(100vw - 32px);
        max-width: calc(100vw - 32px);
        margin: 16px auto;
        min-height: 380px;
    }

    .bbiv-toolbar-main {
        gap: 3px;
        padding: 3px;
    }

    .bbiv-status-text strong {
        display: inline-block;
        position: static;
        width: auto;
        height: auto;
        margin: 0;
        overflow: visible;
        clip: auto;
        white-space: nowrap;
    }

    .bbiv-status-text span {
        font-weight: 600;
    }

    .bbiv-shell form.bbiv-search-form-toolbar {
        gap: 3px;
    }

    .bbiv-shell form.bbiv-search-form-toolbar input.bbiv-search-input {
        padding-inline: 5px;
    }

    .bbiv-shell form.bbiv-search-form-lookup {
        flex-direction: column;
        align-items: stretch;
    }

    .bbiv-shell form.bbiv-search-form-lookup button.bbiv-btn {
        width: 100%;
    }

    .bbiv-lookup-card {
        padding: 22px 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bbiv-shell *,
    .bbiv-shell *::before,
    .bbiv-shell *::after {
        scroll-behavior: auto;
        animation-duration: .001ms;
        animation-iteration-count: 1;
        transition-duration: .001ms;
    }

    /* Keep the functional loading indicator visibly active. */
    .bbiv-shell .bbiv-spinner {
        animation-name: bbiv-spin;
        animation-duration: .78s;
        animation-timing-function: linear;
        animation-iteration-count: infinite;
        animation-play-state: running;
    }
}

@keyframes bbiv-spin {
    from { transform: translateZ(0) rotate(0deg); }
    to { transform: translateZ(0) rotate(360deg); }
}

@keyframes bbiv-progress {
    0% { transform: translateX(-65%) scaleX(.25); }
    50% { transform: translateX(8%) scaleX(.58); }
    100% { transform: translateX(72%) scaleX(.25); }
}
/* Validation state added by the production verifier. */
.bbiv-shell input.bbiv-search-input[aria-invalid="true"] {
    border-color: var(--bbiv-danger);
    outline-color: var(--bbiv-danger);
}


/* --------------------------------------------------------------------------
   v22.3.0 - Compact unified verified/search control
   -------------------------------------------------------------------------- */
.bbiv-shell form.bbiv-search-form-toolbar {
    flex: 0 1 330px;
    width: min(330px, 34vw);
    min-width: 230px;
    max-width: 360px;
    height: var(--bbiv-control-h);
    gap: 3px;
    padding: 2px;
    overflow: hidden;
    border: 1px solid rgba(0,187,0,.24);
    border-radius: 8px;
    background: var(--bbiv-panel-solid);
    box-shadow: none;
    transition: border-color .14s ease, box-shadow .14s ease, background-color .14s ease;
}

.bbiv-shell form.bbiv-search-form-toolbar:hover {
    border-color: rgba(0,187,0,.42);
}

.bbiv-shell form.bbiv-search-form-toolbar:focus-within {
    border-color: var(--bbiv-accent);
    box-shadow: 0 0 0 2px rgba(0,112,238,.12);
}

.bbiv-verified-inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    height: 24px;
    min-width: 0;
    gap: 4px;
    margin: 0;
    padding: 0 7px 0 4px;
    border: 0;
    border-radius: 6px;
    background: rgba(0,187,0,.09);
    color: var(--bbiv-success);
    font-size: var(--bbiv-size-12);
    font-weight: 650;
    line-height: 1;
    letter-spacing: var(--bbiv-track-12);
    white-space: nowrap;
}

.bbiv-verified-inline-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 17px;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: var(--bbiv-success);
    color: #fff;
}

.bbiv-verified-inline-icon .bbiv-icon {
    width: 11px;
    height: 11px;
    stroke-width: 2.35;
}

.bbiv-shell form.bbiv-search-form-toolbar input.bbiv-search-input {
    flex: 1 1 auto;
    width: 0;
    min-width: 0;
    height: 24px;
    min-height: 24px;
    margin: 0;
    padding: 0 5px;
    border: 0;
    border-radius: 0;
    outline: 0;
    background: transparent;
    color: var(--bbiv-text);
    box-shadow: none;
    font-weight: 600;
    text-transform: none;
    font-variant-numeric: tabular-nums;
}

.bbiv-shell form.bbiv-search-form-toolbar input.bbiv-search-input:focus,
.bbiv-shell form.bbiv-search-form-toolbar input.bbiv-search-input:focus-visible {
    border: 0;
    outline: 0;
    box-shadow: none;
}

.bbiv-shell form.bbiv-search-form-toolbar button.bbiv-search-button {
    position: relative;
    flex: 0 0 24px;
    width: 24px;
    min-width: 24px;
    max-width: 24px;
    height: 24px;
    min-height: 24px;
    padding: 0;
    border-width: 0;
    border-radius: 6px;
}

.bbiv-shell form.bbiv-search-form-toolbar button.bbiv-search-button > span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 940px) {
    .bbiv-toolbar-main {
        grid-template-columns: minmax(0,1fr);
        grid-template-areas:
            "search"
            "tools";
        gap: 4px;
    }

    .bbiv-shell form.bbiv-search-form-toolbar {
        grid-area: search;
        justify-self: start;
        width: min(420px, 100%);
        min-width: 0;
        max-width: 420px;
    }
}

@media (max-width: 760px) {
    .bbiv-shell form.bbiv-search-form-toolbar {
        min-height: var(--bbiv-mobile-control-h);
        height: 28px;
        width: min(390px, 100%);
        max-width: 390px;
        padding: 2px;
    }

    .bbiv-verified-inline {
        height: 22px;
        padding-inline: 3px 6px;
    }

    .bbiv-shell form.bbiv-search-form-toolbar input.bbiv-search-input {
        height: 22px;
        min-height: 22px;
        padding-inline: 5px;
    }

    .bbiv-shell form.bbiv-search-form-toolbar button.bbiv-search-button {
        flex-basis: 22px;
        width: 22px;
        min-width: 22px;
        max-width: 22px;
        height: 22px;
        min-height: 22px;
    }
}

@media (max-width: 520px) {
    .bbiv-shell form.bbiv-search-form-toolbar {
        width: 100%;
        max-width: none;
    }

    .bbiv-verified-inline {
        width: 22px;
        min-width: 22px;
        max-width: 22px;
        padding: 0;
        background: transparent;
    }

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

    .bbiv-verified-inline-icon {
        flex-basis: 18px;
        width: 18px;
        height: 18px;
    }
}

.bbiv-shell form.bbiv-search-form-toolbar:has(input.bbiv-search-input[aria-invalid="true"]) {
    border-color: var(--bbiv-danger);
    box-shadow: 0 0 0 2px var(--bbiv-danger-bg);
}

/* --------------------------------------------------------------------------
   v22.8.0 - Ultra-compact sticky single-row viewer toolbar
   -------------------------------------------------------------------------- */
.bbiv-shell header.bbiv-toolbar {
    position: sticky;
    top: 0;
    z-index: 60;
    flex: 0 0 auto;
    width: 100%;
    background: color-mix(in srgb, var(--bbiv-panel-solid) 94%, transparent);
    border-bottom: 1px solid var(--bbiv-border);
    box-shadow: 0 1px 0 color-mix(in srgb, var(--bbiv-border) 68%, transparent), 0 5px 14px color-mix(in srgb, #000 6%, transparent);
    -webkit-backdrop-filter: blur(14px) saturate(1.12);
    backdrop-filter: blur(14px) saturate(1.12);
}

.bbiv-shell header.bbiv-toolbar > .bbiv-toolbar-row.bbiv-toolbar-main {
    display: flex;
    grid-template-columns: none;
    grid-template-areas: none;
    align-items: center;
    flex-wrap: nowrap;
    width: 100%;
    min-width: 0;
    min-height: 0;
    gap: 5px;
    padding: 4px 5px;
    overflow: hidden;
}

.bbiv-shell header.bbiv-toolbar form.bbiv-search-form.bbiv-search-form-toolbar {
    display: flex;
    grid-area: auto;
    justify-self: auto;
    flex: 0 1 268px;
    width: clamp(180px, 27vw, 268px);
    min-width: 160px;
    max-width: 268px;
    height: 32px;
    min-height: 32px;
    gap: 2px;
    padding: 2px;
    border-radius: 7px;
}

.bbiv-shell header.bbiv-toolbar .bbiv-verified-inline {
    height: 26px;
    gap: 3px;
    padding: 0 5px 0 3px;
    border-radius: 5px;
    font-size: 12px;
}

.bbiv-shell header.bbiv-toolbar .bbiv-verified-inline-icon {
    flex-basis: 16px;
    width: 16px;
    height: 16px;
}

.bbiv-shell header.bbiv-toolbar .bbiv-verified-inline-icon .bbiv-icon {
    width: 10px;
    height: 10px;
}

.bbiv-shell header.bbiv-toolbar form.bbiv-search-form-toolbar input.bbiv-search-input {
    flex: 1 1 auto;
    width: 0;
    min-width: 0;
    height: 22px;
    min-height: 22px;
    padding: 0 4px;
    font-size: 12px;
    line-height: 1.2;
}

.bbiv-shell header.bbiv-toolbar form.bbiv-search-form-toolbar button.bbiv-search-button {
    flex: 0 0 26px;
    width: 26px;
    min-width: 26px;
    max-width: 26px;
    height: 26px;
    min-height: 26px;
    padding: 0;
    border-radius: 5px;
}

.bbiv-shell header.bbiv-toolbar form.bbiv-search-form-toolbar button.bbiv-search-button .bbiv-icon {
    width: 13px;
    height: 13px;
}

.bbiv-shell header.bbiv-toolbar .bbiv-tools-row {
    grid-area: auto;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex: 1 1 0;
    width: 0;
    min-width: 0;
    max-width: none;
    min-height: 28px;
    gap: 2px;
    margin: 0;
    padding: 0 1px 1px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scrollbar-width: thin;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y pinch-zoom;
}

.bbiv-shell header.bbiv-toolbar .bbiv-tools-row::-webkit-scrollbar {
    display: block;
    height: 2px;
}

.bbiv-shell header.bbiv-toolbar .bbiv-toolbar-center,
.bbiv-shell header.bbiv-toolbar .bbiv-toolbar-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    flex: 0 0 auto;
    width: max-content;
    min-width: max-content;
    height: 28px;
    min-height: 28px;
    gap: 2px;
    margin: 0;
    padding: 0;
    overflow: visible;
}

.bbiv-shell header.bbiv-toolbar button.bbiv-btn,
.bbiv-shell header.bbiv-toolbar a.bbiv-btn {
    min-width: 28px;
    height: 28px;
    min-height: 28px;
    padding: 0 6px;
    border-radius: 6px;
}

.bbiv-shell header.bbiv-toolbar .bbiv-btn.bbiv-btn-icon {
    width: 28px;
    min-width: 28px;
    max-width: 28px;
    padding: 0;
}

.bbiv-shell header.bbiv-toolbar .bbiv-btn.bbiv-zoom-label {
    min-width: 45px;
    height: 28px;
    padding: 0 5px;
    font-size: 11px;
}


.bbiv-shell header.bbiv-toolbar .bbiv-toolbar-center .bbiv-icon,
.bbiv-shell header.bbiv-toolbar .bbiv-toolbar-actions .bbiv-icon {
    width: 14px;
    height: 14px;
}

.bbiv-shell header.bbiv-toolbar .bbiv-separator {
    flex: 0 0 1px;
    width: 1px;
    height: 15px;
    margin: 0 1px;
}

@media (max-width: 760px) {
    .bbiv-shell header.bbiv-toolbar > .bbiv-toolbar-row.bbiv-toolbar-main {
        display: flex;
        grid-template-columns: none;
        grid-template-areas: none;
        gap: 3px;
        padding: 3px;
    }

    .bbiv-shell header.bbiv-toolbar form.bbiv-search-form.bbiv-search-form-toolbar {
        flex: 0 1 210px;
        width: min(46vw, 210px);
        min-width: 132px;
        max-width: 210px;
        height: 26px;
        min-height: 26px;
        padding: 2px;
    }

    .bbiv-shell header.bbiv-toolbar .bbiv-verified-inline {
        height: 20px;
        padding: 0 4px 0 2px;
    }

    .bbiv-shell header.bbiv-toolbar form.bbiv-search-form-toolbar input.bbiv-search-input {
        height: 20px;
        min-height: 20px;
        padding: 0 3px;
        font-size: 11px;
    }

    .bbiv-shell header.bbiv-toolbar form.bbiv-search-form-toolbar button.bbiv-search-button {
        flex-basis: 20px;
        width: 20px;
        min-width: 20px;
        max-width: 20px;
        height: 20px;
        min-height: 20px;
    }

    .bbiv-shell header.bbiv-toolbar .bbiv-tools-row,
    .bbiv-shell header.bbiv-toolbar .bbiv-toolbar-center,
    .bbiv-shell header.bbiv-toolbar .bbiv-toolbar-actions {
        min-height: 26px;
        height: 26px;
    }

    .bbiv-shell header.bbiv-toolbar button.bbiv-btn,
    .bbiv-shell header.bbiv-toolbar a.bbiv-btn {
        min-width: 26px;
        height: 26px;
        min-height: 26px;
        padding: 0 5px;
        border-radius: 5px;
    }

    .bbiv-shell header.bbiv-toolbar .bbiv-btn.bbiv-btn-icon {
        width: 26px;
        min-width: 26px;
        max-width: 26px;
        padding: 0;
    }

    .bbiv-shell header.bbiv-toolbar .bbiv-btn.bbiv-zoom-label {
        min-width: 42px;
        height: 26px;
        padding: 0 4px;
    }


    .bbiv-shell header.bbiv-toolbar .bbiv-toolbar-center .bbiv-icon,
    .bbiv-shell header.bbiv-toolbar .bbiv-toolbar-actions .bbiv-icon {
        width: 13px;
        height: 13px;
    }
}

@media (max-width: 680px) {
    .bbiv-shell header.bbiv-toolbar .bbiv-verified-inline {
        flex: 0 0 20px;
        width: 20px;
        min-width: 20px;
        max-width: 20px;
        padding: 0;
        background: transparent;
    }

    .bbiv-shell header.bbiv-toolbar .bbiv-verified-inline-label {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0,0,0,0);
        white-space: nowrap;
        border: 0;
    }
}

@media (max-width: 520px) {
    .bbiv-shell header.bbiv-toolbar form.bbiv-search-form.bbiv-search-form-toolbar {
        flex: 0 1 172px;
        width: min(44vw, 172px);
        min-width: 118px;
        max-width: 172px;
    }

}

/* --------------------------------------------------------------------------
   v22.9.2 - First-paint-stable adaptive toolbar + shell-bounded sticky behavior

   IMPORTANT: these rules intentionally key off `.bbiv-has-pdf`, which is
   emitted by PHP in the initial HTML. Do not key toolbar geometry off
   `.bbiv-has-rendered-page`; that class is added only after PDF.js completes
   its first canvas render and would cause a visible one-row -> two-row reflow.
   -------------------------------------------------------------------------- */
.bbiv-shell.bbiv-has-pdf {
    /* `clip` keeps the rounded viewer boundary without creating a scroll
       container, allowing the toolbar to stick to the viewport while still
       being constrained by the complete BBIV shell. */
    overflow: clip;
    isolation: isolate;
}

.bbiv-shell.bbiv-has-pdf > header.bbiv-toolbar {
    position: sticky;
    top: var(--bbiv-sticky-top, 0px);
    z-index: 80;
    align-self: stretch;
    width: 100%;
}

/* Respect the WordPress admin bar when the viewer is inspected while logged in. */
body.admin-bar .bbiv-shell.bbiv-has-pdf > header.bbiv-toolbar {
    --bbiv-sticky-top: 32px;
}

.bbiv-shell.bbiv-has-pdf > header.bbiv-toolbar > .bbiv-toolbar-row.bbiv-toolbar-main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    align-content: center;
    gap: 4px 5px;
    width: 100%;
    min-width: 0;
    padding: 4px 5px;
    overflow: visible;
}

/* First row item. It stays compact but can contract before wrapping tools. */
.bbiv-shell.bbiv-has-pdf > header.bbiv-toolbar form.bbiv-search-form.bbiv-search-form-toolbar {
    flex: 0 1 268px;
    width: clamp(180px, 27vw, 268px);
    min-width: 160px;
    max-width: 268px;
}

/* The tools require a useful amount of horizontal room. When that room is not
   available beside the search form, flexbox naturally moves the whole tools
   strip to line two instead of crushing it into a tiny sliver. */
.bbiv-shell.bbiv-has-pdf > header.bbiv-toolbar .bbiv-tools-row {
    flex: 1 1 390px;
    width: auto;
    min-width: min(390px, 100%);
    max-width: 100%;
}

/* Once wrapped, the tools strip should use the complete second line and retain
   its mouse/touch horizontal scrolling rather than wrapping individual tools. */
@media (max-width: 700px) {
    .bbiv-shell.bbiv-has-pdf > header.bbiv-toolbar > .bbiv-toolbar-row.bbiv-toolbar-main {
        gap: 3px;
        padding: 3px;
    }

    .bbiv-shell.bbiv-has-pdf > header.bbiv-toolbar form.bbiv-search-form.bbiv-search-form-toolbar {
        flex: 1 1 auto;
        width: 100%;
        min-width: 0;
        max-width: none;
    }

    .bbiv-shell.bbiv-has-pdf > header.bbiv-toolbar .bbiv-tools-row {
        flex: 1 0 100%;
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }
}

@media (max-width: 782px) {
    body.admin-bar .bbiv-shell.bbiv-has-pdf > header.bbiv-toolbar {
        --bbiv-sticky-top: 46px;
    }
}

.bbiv-shell:fullscreen.bbiv-has-pdf > header.bbiv-toolbar {
    --bbiv-sticky-top: 0px;
}

/* Older engines without overflow: clip still get shell-bounded sticky behavior.
   Stage overflow continues to contain the rendered PDF itself. */
@supports not (overflow: clip) {
    .bbiv-shell.bbiv-has-pdf {
        overflow: visible;
    }
}

/* --------------------------------------------------------------------------
   v22.9.2 - Invisible horizontal scrollbar
   The tools strip remains scrollable/draggable; only the scrollbar chrome is
   hidden across Firefox, legacy Edge/IE, Chromium, Safari, iOS and Android.
   -------------------------------------------------------------------------- */
.bbiv-shell header.bbiv-toolbar .bbiv-tools-row,
.bbiv-shell.bbiv-has-pdf > header.bbiv-toolbar .bbiv-tools-row {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.bbiv-shell header.bbiv-toolbar .bbiv-tools-row::-webkit-scrollbar,
.bbiv-shell.bbiv-has-pdf > header.bbiv-toolbar .bbiv-tools-row::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

/* --------------------------------------------------------------------------
   v22.9.4 - Keep terminal toolbar actions pinned to the far inline end
   Uses normal flex auto-margin behavior; when the strip overflows the actions
   remain the final content group and are reachable by horizontal drag/scroll.
   -------------------------------------------------------------------------- */
.bbiv-shell header.bbiv-toolbar .bbiv-tools-row > .bbiv-toolbar-actions,
.bbiv-shell.bbiv-has-pdf > header.bbiv-toolbar .bbiv-tools-row > .bbiv-toolbar-actions {
    margin-inline-start: auto;
    margin-inline-end: 0;
}


/* --------------------------------------------------------------------------
   v22.9.5 - Direction-aware toolbar scroll arrows
   Overlay controls stay outside the scrolling content, so they never consume
   tool-row width or disturb native touch/mouse drag scrolling.
   -------------------------------------------------------------------------- */
.bbiv-shell header.bbiv-toolbar .bbiv-tools-scroll-shell {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1 1 0;
    width: 0;
    min-width: 0;
    max-width: none;
    margin: 0;
    padding: 0;
}

.bbiv-shell header.bbiv-toolbar .bbiv-tools-scroll-shell > .bbiv-tools-row {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    max-width: 100%;
}

.bbiv-shell.bbiv-has-pdf > header.bbiv-toolbar .bbiv-tools-scroll-shell {
    flex: 1 1 390px;
    width: auto;
    min-width: min(390px, 100%);
    max-width: 100%;
}

.bbiv-shell.bbiv-has-pdf > header.bbiv-toolbar .bbiv-tools-scroll-shell > .bbiv-tools-row {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    max-width: 100%;
}

.bbiv-shell header.bbiv-toolbar .bbiv-toolbar-scroll-arrow {
    position: absolute;
    top: 50%;
    z-index: 8;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    min-width: 24px;
    max-width: 24px;
    height: 24px;
    min-height: 24px;
    padding: 0;
    margin: 0;
    border: 1px solid color-mix(in srgb, var(--bbiv-accent) 52%, var(--bbiv-border-strong));
    border-radius: 999px;
    background: color-mix(in srgb, var(--bbiv-panel-solid) 88%, var(--bbiv-accent) 12%);
    color: var(--bbiv-accent);
    box-shadow: 0 2px 8px color-mix(in srgb, #000 18%, transparent);
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) scale(1);
    transition: opacity .16s ease, visibility .16s ease, transform .16s ease, background-color .16s ease, border-color .16s ease;
    cursor: pointer;
    pointer-events: auto;
}

.bbiv-shell header.bbiv-toolbar .bbiv-toolbar-scroll-left {
    left: 0;
}

.bbiv-shell header.bbiv-toolbar .bbiv-toolbar-scroll-right {
    right: 0;
}

.bbiv-shell header.bbiv-toolbar .bbiv-toolbar-scroll-arrow .bbiv-icon {
    width: 14px;
    height: 14px;
    stroke-width: 2.2;
}

.bbiv-shell header.bbiv-toolbar .bbiv-toolbar-scroll-arrow:hover,
.bbiv-shell header.bbiv-toolbar .bbiv-toolbar-scroll-arrow:focus-visible {
    border-color: var(--bbiv-accent);
    background: color-mix(in srgb, var(--bbiv-panel-solid) 76%, var(--bbiv-accent) 24%);
    color: var(--bbiv-accent-hover);
}

.bbiv-shell header.bbiv-toolbar .bbiv-toolbar-scroll-arrow.is-hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-50%) scale(.86);
    pointer-events: none;
}

.theme-dark .bbiv-shell header.bbiv-toolbar .bbiv-toolbar-scroll-arrow,
.bbiv-shell.theme-dark header.bbiv-toolbar .bbiv-toolbar-scroll-arrow {
    border-color: color-mix(in srgb, var(--bbiv-accent) 68%, rgba(255,255,255,.20));
    background: color-mix(in srgb, var(--bbiv-panel-solid) 76%, var(--bbiv-accent) 24%);
    color: #66c2ff;
    box-shadow: 0 2px 9px rgba(0,0,0,.34);
}

@media (max-width: 700px) {
    .bbiv-shell.bbiv-has-pdf > header.bbiv-toolbar .bbiv-tools-scroll-shell {
        flex: 1 0 100%;
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }
}


/* --------------------------------------------------------------------------
   v22.9.6 - Toolbar icon control sizing
   Match the invoice toolbar hit targets: 32px desktop, 24px compact/mobile.
   -------------------------------------------------------------------------- */
.bbiv-shell header.bbiv-toolbar .bbiv-toolbar-center,
.bbiv-shell header.bbiv-toolbar .bbiv-toolbar-actions {
    height: 32px;
    min-height: 32px;
}

.bbiv-shell header.bbiv-toolbar .bbiv-btn.bbiv-btn-icon,
.bbiv-shell header.bbiv-toolbar .bbiv-toolbar-scroll-arrow {
    width: 32px;
    min-width: 32px;
    max-width: 32px;
    height: 32px;
    min-height: 32px;
    max-height: 32px;
    padding: 0;
}

@media (max-width: 760px) {
    .bbiv-shell header.bbiv-toolbar .bbiv-toolbar-center,
    .bbiv-shell header.bbiv-toolbar .bbiv-toolbar-actions {
        height: 24px;
        min-height: 24px;
    }

    .bbiv-shell header.bbiv-toolbar .bbiv-btn.bbiv-btn-icon,
    .bbiv-shell header.bbiv-toolbar .bbiv-toolbar-scroll-arrow {
        width: 24px;
        min-width: 24px;
        max-width: 24px;
        height: 24px;
        min-height: 24px;
        max-height: 24px;
        padding: 0;
    }
}

/* --------------------------------------------------------------------------
   v22.9.7 - Sticky toolbar overlaid on the PDF stage
   The toolbar and stage share the same shell grid cell, so the stage begins
   behind the toolbar instead of below it. The translucent toolbar background
   allows backdrop-filter to blur the PDF/stage content underneath.
   -------------------------------------------------------------------------- */
.bbiv-shell.bbiv-has-pdf {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
}

.bbiv-shell.bbiv-has-pdf > header.bbiv-toolbar,
.bbiv-shell.bbiv-has-pdf > main.bbiv-stage {
    grid-column: 1;
    grid-row: 1;
}

.bbiv-shell.bbiv-has-pdf > header.bbiv-toolbar {
    position: sticky;
    top: var(--bbiv-sticky-top, 0px);
    z-index: 80;
    align-self: start;
    width: 100%;
    background: color-mix(in srgb, var(--bbiv-panel-solid) 72%, transparent);
    -webkit-backdrop-filter: blur(16px) saturate(1.18);
    backdrop-filter: blur(16px) saturate(1.18);
}

.bbiv-shell.bbiv-has-pdf > main.bbiv-stage {
    z-index: 1;
    align-self: stretch;
    width: 100%;
    height: 100%;
    min-height: 0;
}
