/* Tajawal fonts: place the TTF files in assets/fonts/. */
@font-face {
    font-family: "Tajawal";
    src: url("./fonts/Tajawal-ExtraLight.ttf") format("truetype");
    font-weight: 200;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Tajawal";
    src: url("./fonts/Tajawal-Light.ttf") format("truetype");
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Tajawal";
    src: url("./fonts/Tajawal-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Tajawal";
    src: url("./fonts/Tajawal-Medium.ttf") format("truetype");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Tajawal";
    src: url("./fonts/Tajawal-Bold.ttf") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Tajawal";
    src: url("./fonts/Tajawal-ExtraBold.ttf") format("truetype");
    font-weight: 800;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Tajawal";
    src: url("./fonts/Tajawal-Black.ttf") format("truetype");
    font-weight: 900;
    font-style: normal;
    font-display: swap;
}

:root {
    font-family: "Tajawal", Tahoma, Arial, sans-serif;
    color: #17212b;
    background: #f4f7f9;
    font-synthesis: none;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    background: #f4f7f9;
}

button, input, textarea, select {
    font: inherit;
}

button {
    cursor: pointer;
}

    button:disabled {
        cursor: not-allowed;
    }

.hidden {
    display: none !important;
}

.muted {
    color: #657381;
}

.small {
    font-size: .82rem;
}

.eyebrow {
    margin: 0 0 .35rem;
    color: #4e6475;
    font-size: .76rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.center-stage {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.25rem;
}

.panel {
    width: min(100%, 32rem);
    background: #fff;
    border: 1px solid #dce4ea;
    border-radius: 1.2rem;
    box-shadow: 0 1.25rem 3.5rem rgba(31, 49, 64, .11);
}

.compact-panel {
    padding: 2rem;
    text-align: center;
}

.login-panel {
    padding: clamp(1.25rem, 4vw, 2rem);
}

.brand-mark {
    width: 4rem;
    height: 4rem;
    margin: 0 auto 1rem;
    display: grid;
    place-items: center;
    border-radius: 1rem;
    background: #173f5f;
    color: #fff;
    font-weight: 800;
    font-size: 1.25rem;
}

.logo-frame {
    min-height: 9rem;
    margin-bottom: 1.4rem;
    display: grid;
    place-items: center;
    border: 1px solid #dbe4ea;
    border-radius: .9rem;
    background: #fafcfd;
    overflow: hidden;
    padding: .75rem;
}

.header-logo-frame {
    width: 5.5rem;
    height: 3.5rem;
    display: grid;
    place-items: center;
    border-radius: .55rem;
    background: #f3f6f8;
    overflow: hidden;
    padding: .15rem;
}

.client-logo {
    width: 85%;
    max-width: 24rem;
    max-height: 8rem;
    object-fit: contain;
    display: none;
}

    .client-logo.loaded {
        display: block;
    }

.logo-placeholder.logo-loaded {
    display: none;
}

.header-logo-frame .client-logo {
    width: 100%;
    max-width: 5.25rem;
    max-height: 3.25rem;
}

.logo-placeholder {
    color: #82909c;
    font-weight: 650;
}

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

h1, h2 {
    margin: 0;
    color: #102a3d;
}

h1 {
    font-size: clamp(1.5rem, 4vw, 2rem);
}

.secure-badge {
    padding: .32rem .55rem;
    border-radius: 999px;
    background: #eaf6ee;
    color: #1f6a3f;
    font-size: .72rem;
    font-weight: 800;
}

.site-card {
    display: grid;
    gap: .15rem;
    padding: .85rem 1rem;
    margin: 1rem 0 1.2rem;
    border-left: .25rem solid #2c6f94;
    border-radius: .6rem;
    background: #f3f8fb;
}

.site-label {
    color: #547084;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .05em;
}

label {
    display: grid;
    gap: .38rem;
    margin: .85rem 0;
    color: #304757;
    font-size: .9rem;
    font-weight: 600;
}

input, textarea {
    width: 100%;
    padding: .72rem .8rem;
    border: 1px solid #cbd7df;
    border-radius: .62rem;
    background: #fff;
    color: #162936;
    outline: none;
}

    input:focus, textarea:focus {
        border-color: #2c6f94;
        box-shadow: 0 0 0 .2rem rgba(44, 111, 148, .12);
    }

textarea {
    resize: vertical;
}

.primary-button, .secondary-button, .icon-button {
    border: 0;
    border-radius: .65rem;
    font-weight: 700;
}

.primary-button {
    width: 100%;
    margin-top: .6rem;
    padding: .8rem 1rem;
    background: #173f5f;
    color: #fff;
}

    .primary-button:hover {
        background: #102f48;
    }

    .primary-button:disabled {
        opacity: .6;
    }

.secondary-button {
    padding: .6rem .8rem;
    background: #eef3f6;
    color: #20394a;
}

    .secondary-button:hover {
        background: #e3ebf0;
    }

.icon-button {
    width: 2.3rem;
    height: 2.3rem;
    background: #eef3f6;
    color: #334b5a;
    font-size: 1.4rem;
}

.message {
    min-height: 1.3rem;
    margin: .65rem 0 0;
    color: #a82f2f;
    font-size: .85rem;
}

    .message.success {
        color: #23633c;
    }

.portal {
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: 4.6rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .7rem clamp(.85rem, 3vw, 2rem);
    background: rgba(255, 255, 255, .96);
    border-bottom: 1px solid #dce5eb;
}

.topbar-brand, .topbar-actions, .user-chip {
    display: flex;
    align-items: center;
    gap: .8rem;
}

    .topbar-brand > div:last-child, .user-chip {
        display: grid;
        gap: .08rem;
    }

.user-chip {
    padding: .45rem .7rem;
    border-radius: .65rem;
    background: #f3f6f8;
}

.portal-content {
    width: min(100%, 92rem);
    margin: 0 auto;
    padding: clamp(1rem, 3vw, 2rem);
}

.welcome-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    margin: 1rem 0 1.4rem;
}

    .welcome-row p {
        margin: .4rem 0 0;
    }

.status-pill {
    padding: .55rem .75rem;
    border-radius: 999px;
    background: #edf3f6;
    color: #3b5668;
    font-size: .82rem;
    white-space: nowrap;
}

.module-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}

.module-card {
    min-height: 13rem;
    display: grid;
    align-content: start;
    gap: .65rem;
    padding: 1.1rem;
    text-align: left;
    border: 1px solid #d9e3e9;
    border-radius: 1rem;
    background: #fff;
    color: #1f3442;
    box-shadow: 0 .5rem 1.5rem rgba(32, 52, 65, .05);
}

    .module-card:not(:disabled):hover {
        transform: translateY(-1px);
        border-color: #9cb8ca;
    }

    .module-card:disabled {
        opacity: .7;
    }

.module-icon {
    width: 2.25rem;
    height: 2.25rem;
    display: grid;
    place-items: center;
    border-radius: .7rem;
    background: #edf4f8;
    color: #285b7b;
    font-weight: 800;
}

.module-card strong {
    font-size: 1rem;
}

.module-card span:not(.module-icon) {
    line-height: 1.45;
    color: #5e7180;
}

.module-card small {
    margin-top: auto;
    color: #7b8993;
}

.info-strip {
    margin-top: 1rem;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border: 1px solid #dce5ea;
    border-radius: .9rem;
    overflow: hidden;
    background: #fff;
}

    .info-strip > div {
        display: grid;
        gap: .2rem;
        padding: .85rem 1rem;
        border-right: 1px solid #e2e9ed;
    }

        .info-strip > div:last-child {
            border-right: 0;
        }

    .info-strip span {
        color: #71808b;
        font-size: .75rem;
    }

    .info-strip strong {
        font-size: .9rem;
    }

.site-dialog {
    width: min(94vw, 58rem);
    max-height: 86vh;
    padding: 0;
    border: 1px solid #d2dee5;
    border-radius: 1rem;
    box-shadow: 0 2rem 5rem rgba(0,0,0,.2);
}

    .site-dialog::backdrop {
        background: rgba(13, 27, 38, .45);
    }

.dialog-header {
    position: sticky;
    top: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.2rem;
    background: #fff;
    border-bottom: 1px solid #dce5ea;
}

.dialog-body {
    padding: 1rem 1.2rem 1.4rem;
}

.site-list {
    display: grid;
    gap: .65rem;
    margin: 1rem 0;
}

.site-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: .8rem;
    align-items: center;
    padding: .8rem;
    border: 1px solid #dde6eb;
    border-radius: .75rem;
}

.site-row-main {
    display: grid;
    gap: .18rem;
    min-width: 0;
}

.site-row-title {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}

.site-meta {
    overflow-wrap: anywhere;
    color: #71808b;
    font-size: .78rem;
}

.site-actions {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

    .site-actions button {
        width: auto;
        margin: 0;
        padding: .5rem .65rem;
    }

.site-state {
    padding: .2rem .45rem;
    border-radius: 999px;
    background: #eef3f6;
    color: #566b79;
    font-size: .7rem;
    font-weight: 700;
}

    .site-state.good {
        background: #eaf6ee;
        color: #23633c;
    }

    .site-state.bad {
        background: #fbeaea;
        color: #943434;
    }

.add-site {
    margin-top: 1rem;
    border-top: 1px solid #e0e7eb;
    padding-top: 1rem;
}

    .add-site summary {
        cursor: pointer;
        font-weight: 750;
        color: #24475e;
    }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 1rem;
}

.inline-options {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

    .inline-options label {
        display: flex;
        align-items: center;
        gap: .4rem;
        margin: .3rem 0;
    }

    .inline-options input {
        width: auto;
    }

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

    .info-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

        .info-strip > div:nth-child(2) {
            border-right: 0;
        }

        .info-strip > div:nth-child(-n+2) {
            border-bottom: 1px solid #e2e9ed;
        }
}

@media (max-width: 640px) {
    .topbar {
        align-items: flex-start;
    }

    .topbar-actions {
        justify-content: flex-end;
        flex-wrap: wrap;
    }

    .user-chip {
        order: 3;
        width: 100%;
    }

    .welcome-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .module-grid, .info-strip, .form-grid {
        grid-template-columns: 1fr;
    }

        .info-strip > div {
            border-right: 0;
            border-bottom: 1px solid #e2e9ed;
        }

            .info-strip > div:last-child {
                border-bottom: 0;
            }

    .site-row {
        grid-template-columns: 1fr;
    }

    .site-actions {
        justify-content: flex-start;
    }
}

/* Phase 1 archive entry workspace */
.archive-workspace {
    height: calc(100vh - 4.6rem);
    display: flex;
    flex-direction: column;
    min-height: 34rem;
    background: #e8f0f5;
}

.archive-commandbar {
    min-height: 3.25rem;
    display: flex;
    align-items: center;
    gap: .35rem;
    padding: .4rem .65rem;
    overflow-x: auto;
    background: #fff;
    border-bottom: 1px solid #cfdbe3;
}

/* Two-row toolbar is used ONLY by the scanning/archive workspace */
.archive-workspace .archive-commandbar {
    flex-direction: column;
    align-items: stretch;
    overflow-x: hidden;
}

.archive-command-row {
    display: flex;
    align-items: center;
    gap: .35rem;
    min-width: 0;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.command-button {
    flex: 0 0 auto;
    padding: .52rem .7rem;
    border: 1px solid transparent;
    border-radius: .55rem;
    background: #f2f6f8;
    color: #17384e;
    font-weight: 700;
}

    .command-button:hover:not(:disabled) {
        background: #e6eff4;
        border-color: #cbdbe5;
    }

    .command-button:disabled {
        opacity: .48;
    }

.command-divider {
    width: 1px;
    align-self: stretch;
    margin: .18rem .18rem;
    background: #d8e2e8;
}

.archive-command-message {
    margin-left: auto;
    min-width: 0;
    flex: 1 1 12rem;
    padding: 0 .5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: right;
    color: #9a3535;
    font-size: .82rem;
}

    .archive-command-message.success {
        color: #246340;
    }

.archive-grid {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(15rem, 19rem) minmax(21rem, 29rem) minmax(25rem, 1fr);
    gap: .55rem;
    padding: .55rem;
}

.archive-pane {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid #cbd8e1;
    border-radius: .7rem;
    background: #fff;
    box-shadow: 0 .25rem .8rem rgba(30, 54, 70, .04);
}

.archive-navigation-pane {
    display: grid;
    grid-template-rows: minmax(12rem, 1fr) minmax(12rem, 1fr);
    gap: .5rem;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.archive-pane-section {
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid #cbd8e1;
    border-radius: .7rem;
    background: #fff;
}

.pane-heading {
    flex: 0 0 auto;
    min-height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    padding: .55rem .75rem;
    border-bottom: 1px solid #dce5eb;
    background: #f8fbfc;
    color: #16446a;
}

    .pane-heading > div {
        min-width: 0;
        display: grid;
        gap: .05rem;
    }

.pane-count {
    min-width: 2rem;
    padding: .16rem .45rem;
    text-align: center;
    border-radius: 999px;
    background: #e7f0f6;
    color: #275c7d;
    font-size: .75rem;
    font-weight: 800;
}

.cabinet-tree, .basket-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: .55rem;
}

.tree-root, .tree-root ul {
    margin: 0;
    padding-left: 1.05rem;
    list-style: none;
}

.tree-root {
    padding-left: 0;
}

    .tree-root details > summary {
        padding: .32rem .3rem;
        cursor: pointer;
        color: #334e60;
        font-weight: 700;
    }

.cabinet-button {
    width: 100%;
    margin: .08rem 0;
    padding: .48rem .55rem;
    text-align: start;
    border: 0;
    border-radius: .45rem;
    background: transparent;
    color: #1e3443;
}

    .cabinet-button::before {
        content: "▣";
        margin-inline-end: .45rem;
        color: #4c7086;
    }

    .cabinet-button:hover {
        background: #edf4f8;
    }

    .cabinet-button.selected {
        background: #dcecf6;
        color: #123f5d;
        font-weight: 800;
    }

.basket-record {
    margin-bottom: .45rem;
    overflow: hidden;
    border: 1px solid #e0e7ec;
    border-radius: .55rem;
}

    .basket-record.selected {
        border-color: #7fa9c3;
        box-shadow: 0 0 0 1px rgba(75, 126, 157, .1);
    }

.basket-record-button {
    width: 100%;
    padding: .52rem .65rem;
    text-align: start;
    border: 0;
    background: #f7fafb;
    color: #213c4e;
    font-weight: 800;
}

.basket-record.selected > .basket-record-button {
    background: #e5f0f6;
}

.basket-files {
    display: grid;
    gap: 1px;
    border-top: 1px solid #e1e8ed;
}

.basket-file-button {
    width: 100%;
    padding: .42rem .65rem .42rem 1.15rem;
    overflow: hidden;
    text-align: start;
    text-overflow: ellipsis;
    white-space: nowrap;
    border: 0;
    background: #fff;
    color: #4c5f6c;
    font-size: .78rem;
}

    .basket-file-button:hover, .basket-file-button.selected {
        background: #edf5f9;
        color: #173e57;
    }

.archive-fields-pane {
    overflow: hidden;
}

.dynamic-fields {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: .65rem;
    background: #fbfcf4;
}

.field-group {
    min-width: 0;
    margin: 0 0 .7rem;
    padding: .75rem;
    border: 1px solid #d8d9bb;
    border-radius: .55rem;
    background: #fffef0;
}

    .field-group legend {
        padding: 0 .35rem;
        color: #69673f;
        font-size: .82rem;
        font-weight: 800;
    }

.field-group-plain {
    border-color: transparent;
    background: transparent;
    padding: 0;
}

.field-group-body {
    display: grid;
    gap: .7rem;
}

.dynamic-field {
    display: grid;
    grid-template-columns: minmax(8.5rem, 37%) minmax(0, 1fr);
    gap: .6rem;
    align-items: center;
}

.dynamic-field-label {
    display: grid;
    gap: .1rem;
    margin: 0;
    text-align: end;
    color: #283d48;
    font-size: .82rem;
    font-weight: 700;
}

.field-secondary-label {
    color: #73808a;
    font-size: .7rem;
    font-weight: 500;
}

.dynamic-field input:not([type="checkbox"]):not([type="radio"]), .dynamic-field textarea, .dynamic-field select {
    width: 100%;
    min-width: 0;
    padding: .55rem .6rem;
    border: 1px solid #bdcad3;
    border-radius: .42rem;
    background: #fff;
    color: #172c39;
    font: inherit;
}

.dynamic-field textarea {
    resize: vertical;
}

.dynamic-field select[multiple] {
    min-height: 7rem;
}

.dynamic-field input:focus, .dynamic-field textarea:focus, .dynamic-field select:focus {
    outline: none;
    border-color: #397a9f;
    box-shadow: 0 0 0 .17rem rgba(57,122,159,.12);
}

.dynamic-field input[readonly], .dynamic-field input:disabled, .dynamic-field textarea[readonly], .dynamic-field select:disabled {
    background: #edf1f3;
    color: #5f6a70;
}

.dynamic-field.invalid input, .dynamic-field.invalid textarea, .dynamic-field.invalid select, .dynamic-field.invalid .radio-options {
    border-color: #be5151;
}

.field-error {
    grid-column: 2;
    color: #a43a3a;
    font-size: .73rem;
}

.radio-options {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem .9rem;
    padding: .5rem .6rem;
    border: 1px solid #c5d0d7;
    border-radius: .42rem;
    background: #fff;
}

    .radio-options label {
        display: inline-flex;
        align-items: center;
        gap: .3rem;
        margin: 0;
        font-size: .8rem;
        font-weight: 500;
    }

    .radio-options input {
        width: auto;
    }

.viewer-heading {
    min-height: 3.15rem;
}

.secondary-link {
    padding: .42rem .65rem;
    border-radius: .5rem;
    background: #eaf1f5;
    color: #244c64;
    font-size: .8rem;
    font-weight: 700;
    text-decoration: none;
}

.document-viewer {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    display: grid;
    place-items: stretch;
    background: #eef2f4;
}

.viewer-placeholder {
    min-height: 16rem;
    display: grid;
    place-content: center;
    gap: .45rem;
    padding: 1.2rem;
    text-align: center;
    color: #697982;
}

    .viewer-placeholder strong {
        color: #354e5e;
    }

.viewer-frame {
    width: 100%;
    height: 100%;
    min-height: 30rem;
    border: 0;
    background: #fff;
}

.viewer-image {
    max-width: 100%;
    height: auto;
    margin: auto;
    object-fit: contain;
    background: #fff;
}

.archive-mobile-tabs {
    display: none;
}

@media (max-width: 1180px) {
    .archive-grid {
        grid-template-columns: minmax(14rem, 18rem) minmax(20rem, 26rem) minmax(22rem, 1fr);
    }
}

@media (max-width: 900px) {
    .archive-grid {
        grid-template-columns: minmax(14rem, 18rem) minmax(0, 1fr);
    }

    .archive-viewer-pane {
        grid-column: 1 / -1;
        min-height: 24rem;
    }

    .archive-workspace {
        height: auto;
        min-height: calc(100vh - 4.6rem);
    }

    .archive-grid {
        flex: none;
        min-height: 60rem;
    }
}

@media (max-width: 640px) {
    .archive-workspace {
        min-height: calc(100vh - 4.6rem);
        height: calc(100vh - 4.6rem);
    }

    .archive-commandbar {
        min-height: 3rem;
    }

    .archive-command-message {
        display: none;
    }

    .archive-mobile-tabs {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        border-bottom: 1px solid #cbd8e1;
        background: #fff;
    }

    .archive-tab {
        padding: .6rem .35rem;
        border: 0;
        border-bottom: .18rem solid transparent;
        background: transparent;
        color: #506674;
        font-weight: 700;
    }

        .archive-tab.active {
            border-bottom-color: #2d6d92;
            color: #164663;
        }

    .archive-grid {
        flex: 1 1 auto;
        min-height: 0;
        display: block;
        padding: .45rem;
    }

    .archive-pane, .archive-navigation-pane {
        display: none;
        height: 100%;
        min-height: 0;
    }

        .archive-pane.active {
            display: flex;
        }

        .archive-navigation-pane.active {
            display: grid;
        }

    .archive-viewer-pane {
        min-height: 0;
    }

    .dynamic-field {
        grid-template-columns: 1fr;
        gap: .3rem;
    }

    .dynamic-field-label {
        text-align: start;
    }

    .field-error {
        grid-column: 1;
    }

    .viewer-frame {
        min-height: 100%;
    }
}

/* Scan Bridge + inline PDF preview */
.scan-dialog {
    width: min(94vw, 42rem);
    padding: 0;
    border: 1px solid #d2dee5;
    border-radius: 1rem;
    box-shadow: 0 2rem 5rem rgba(0,0,0,.2);
}

    .scan-dialog::backdrop {
        background: rgba(13, 27, 38, .45);
    }

.scan-dialog-body {
    display: grid;
    gap: .85rem;
}

.scan-mode-grid {
    display: grid;
    gap: .65rem;
}

.scan-mode-button {
    display: grid;
    gap: .25rem;
    padding: .85rem 1rem;
    text-align: start;
    border: 1px solid #d5e1e8;
    border-radius: .72rem;
    background: #f8fbfc;
    color: #1d3b4d;
}

    .scan-mode-button:hover:not(:disabled) {
        background: #edf5f9;
        border-color: #9bb9ca;
    }

    .scan-mode-button:disabled {
        opacity: .48;
    }

    .scan-mode-button span {
        color: #637683;
        font-size: .82rem;
        line-height: 1.4;
    }

.scan-bridge-note {
    margin: .2rem 0 0;
    padding: .75rem .85rem;
    border-radius: .62rem;
    background: #fff8e6;
    color: #66562d;
    font-size: .78rem;
    line-height: 1.45;
}

    .scan-bridge-note code {
        font-family: "Tajawal", Tahoma, Arial, sans-serif;
    }

.pdf-blob-frame {
    width: 100%;
    height: 100%;
    min-height: 30rem;
    border: 0;
    background: #fff;
}

.pdf-preview-loading {
    min-height: 16rem;
    display: grid;
    place-content: center;
    gap: .4rem;
    text-align: center;
    color: #657581;
}

@media (max-width: 640px) {
    .pdf-blob-frame {
        min-height: 100%;
    }
}

/* Folder import, split/merge and TIFF preview */
.split-merge-dialog {
    width: min(96vw, 64rem);
}

.split-merge-body {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .85rem;
}

.split-merge-section {
    min-width: 0;
    padding: .9rem;
    border: 1px solid #d9e3e9;
    border-radius: .75rem;
    background: #f9fbfc;
}

    .split-merge-section h3 {
        margin: 0 0 .45rem;
        color: #173d56;
        font-size: 1rem;
    }

    .split-merge-section p {
        margin: 0 0 .65rem;
        line-height: 1.45;
    }

    .split-merge-section .secondary-button {
        width: 100%;
        margin-top: .45rem;
    }

.compact-check {
    display: flex;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: .45rem;
    margin: .5rem 0;
    font-size: .82rem;
}

    .compact-check input {
        width: auto;
        margin: 0;
    }

.split-merge-section select {
    width: 100%;
    padding: .62rem .7rem;
    border: 1px solid #cbd7df;
    border-radius: .55rem;
    background: #fff;
    color: #162936;
}

.tiff-viewer {
    width: 100%;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    background: #dfe5e8;
}

.tiff-toolbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .55rem;
    padding: .45rem .6rem;
    border-bottom: 1px solid #c5d0d6;
    background: #f8fafb;
}

    .tiff-toolbar button {
        padding: .38rem .65rem;
        border: 1px solid #ccd8df;
        border-radius: .45rem;
        background: #fff;
        color: #24475e;
        font-weight: 700;
    }

        .tiff-toolbar button:disabled {
            opacity: .45;
        }

.tiff-page-label {
    min-width: 7rem;
    text-align: center;
    color: #506775;
    font-size: .8rem;
    font-weight: 700;
}

.tiff-image-wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    display: grid;
    place-items: start center;
    padding: .6rem;
}

.tiff-image {
    max-width: 100%;
    height: auto;
    background: #fff;
    box-shadow: 0 .25rem 1rem rgba(0,0,0,.08);
}

.folder-import-progress {
    min-width: 18rem;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
    .split-merge-body {
        grid-template-columns: 1fr;
    }

    .tiff-toolbar {
        position: sticky;
        top: 0;
        z-index: 2;
    }
}

/* Phase 1 archive search workspace */
.search-workspace {
    height: calc(100vh - 4.6rem);
    display: flex;
    flex-direction: column;
    min-height: 34rem;
    background: #e8f0f5;
}

.search-toolbar-option {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    color: #4d6574;
    font-size: .76rem;
    font-weight: 700;
}

    .search-toolbar-option select {
        min-width: 4.8rem;
        padding: .38rem .45rem;
        border: 1px solid #cad7df;
        border-radius: .45rem;
        background: #fff;
        color: #213d4e;
        font: inherit;
    }

.search-grid {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(20rem, 25rem) minmax(30rem, 1.15fr) minmax(25rem, 1fr);
    gap: .55rem;
    padding: .55rem;
}

.search-pane {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid #cbd8e1;
    border-radius: .7rem;
    background: #fff;
    box-shadow: 0 .25rem .8rem rgba(30, 54, 70, .04);
}

.search-criteria-pane {
    display: grid;
    grid-template-rows: minmax(11rem, .75fr) minmax(19rem, 1.5fr);
    gap: .5rem;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.search-cabinet-section, .search-fields-section {
    min-height: 0;
}

.search-dynamic-fields {
    padding: .55rem;
}

    .search-dynamic-fields .field-group {
        margin-bottom: .5rem;
        padding: .6rem;
    }

    .search-dynamic-fields .field-group-body {
        gap: .55rem;
    }

    .search-dynamic-fields .dynamic-field {
        grid-template-columns: minmax(7rem, 34%) minmax(0, 1fr);
        gap: .45rem;
    }

.search-results-pane {
    background: #fff;
}

.search-results-heading {
    min-height: 3.15rem;
}

.search-pager {
    display: flex;
    align-items: center;
    gap: .45rem;
    flex: 0 0 auto;
}

.search-table-wrap {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    background: #fff;
}

.search-results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .79rem;
}

    .search-results-table th, .search-results-table td {
        padding: .48rem .55rem;
        border-bottom: 1px solid #e2e8ec;
        border-right: 1px solid #edf1f3;
        text-align: start;
        vertical-align: top;
        white-space: nowrap;
    }

    .search-results-table th {
        position: sticky;
        top: 0;
        z-index: 1;
        background: #edf4f8;
        color: #244d66;
        font-weight: 800;
    }

    .search-results-table tbody tr {
        cursor: pointer;
    }

        .search-results-table tbody tr:hover {
            background: #f4f9fb;
        }

        .search-results-table tbody tr.selected {
            background: #dfeef7;
        }

    .search-results-table td.search-cell-text {
        max-width: 18rem;
        overflow: hidden;
        text-overflow: ellipsis;
    }

.search-viewer-pane {
    overflow: hidden;
}

.search-record-summary {
    flex: 0 0 auto;
    max-height: 10rem;
    overflow: auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .35rem .7rem;
    padding: .55rem .7rem;
    border-bottom: 1px solid #dce5eb;
    background: #fbfcf5;
}

.search-record-value {
    min-width: 0;
    display: grid;
    gap: .08rem;
}

    .search-record-value span:first-child {
        color: #667780;
        font-size: .68rem;
        font-weight: 700;
    }

    .search-record-value span:last-child {
        overflow: hidden;
        text-overflow: ellipsis;
        color: #263e4c;
        font-size: .78rem;
    }

.search-files-list {
    flex: 0 0 auto;
    max-height: 8.5rem;
    overflow: auto;
    display: grid;
    border-bottom: 1px solid #dce5eb;
    background: #fff;
}

.search-file-button {
    width: 100%;
    padding: .42rem .7rem;
    overflow: hidden;
    text-align: start;
    text-overflow: ellipsis;
    white-space: nowrap;
    border: 0;
    border-bottom: 1px solid #edf1f3;
    background: #fff;
    color: #4b616f;
    font-size: .76rem;
}

    .search-file-button:hover, .search-file-button.selected {
        background: #eaf4f9;
        color: #163f5a;
    }

.search-document-viewer {
    flex: 1 1 auto;
}

.search-mobile-tabs {
    display: none;
}

@media (max-width: 1180px) {
    .search-grid {
        grid-template-columns: minmax(18rem, 23rem) minmax(28rem, 1fr);
    }

    .search-viewer-pane {
        grid-column: 1 / -1;
        min-height: 26rem;
    }

    .search-workspace {
        height: auto;
        min-height: calc(100vh - 4.6rem);
    }

    .search-grid {
        flex: none;
        min-height: 64rem;
    }
}

@media (max-width: 640px) {
    .search-workspace {
        min-height: calc(100vh - 4.6rem);
        height: calc(100vh - 4.6rem);
    }

    .search-mobile-tabs {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        border-bottom: 1px solid #cbd8e1;
        background: #fff;
    }

    .search-grid {
        flex: 1 1 auto;
        min-height: 0;
        display: block;
        padding: .45rem;
    }

    .search-pane, .search-criteria-pane {
        display: none;
        height: 100%;
        min-height: 0;
    }

        .search-pane.active {
            display: flex;
        }

        .search-criteria-pane.active {
            display: grid;
        }

    .search-record-summary {
        grid-template-columns: 1fr;
        max-height: 9rem;
    }

    .search-table-wrap {
        min-height: 0;
    }

    .search-results-table {
        font-size: .73rem;
    }
}

@media (max-width: 1180px) {
    .archive-command-row {
        flex-wrap: wrap;
    }

    .archive-command-message {
        flex-basis: 100%;
        margin-left: 0;
        text-align: left;
    }
}

.organization-home-actions { display:flex; flex-wrap:wrap; gap:12px; align-items:center; }
.organization-home-link { display:inline-flex; align-items:center; gap:10px; text-decoration:none; background:#173f59; color:white; }
