/* Home / archive / search presentation only. Stored indexing-form geometry is unchanged. */
#portalView {
    --portal-header-height: 74px;
    --portal-footer-height: 38px;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    color: #123b52;
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}
#portalView > .topbar {
    flex: 0 0 auto;
    min-height: 74px;
    padding: 8px clamp(16px, 2.5vw, 36px);
    background: #fff;
}
#portalView .header-logo-frame { background: transparent; height: 54px; width: 98px; }
#portalView .topbar-actions { gap: 10px; }
#portalView .topbar-actions .secondary-button { min-height: 38px; padding: 8px 14px; }
#portalView .user-chip { padding: 7px 12px; }
#portalView #currentSite { display: none; }
html[lang="ar"] #portalView > .topbar,
html[lang="ar"] #dashboardView { direction: rtl; }
#dashboardView {
    flex: 1 0 auto;
    width: min(100%, 78rem);
    padding: clamp(18px, 3vw, 34px);
}
#dashboardView .welcome-row { margin: 0 0 22px; text-align: start; }
#dashboardView .welcome-row h1 { font-size: clamp(1.5rem, 2.3vw, 2rem); line-height: 1.3; }
#dashboardView .welcome-row p { margin: 6px 0 0; font-size: 1rem; }
#dashboardView .module-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: clamp(12px, 1.6vw, 22px);
}
#dashboardView .module-card {
    min-height: clamp(170px, 25dvh, 232px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 18px 14px;
    text-align: center;
    text-decoration: none;
    border: 1px solid #d5e2ee;
    border-radius: 18px;
    color: #123b52;
    box-shadow: 0 7px 24px rgba(33, 73, 106, .045);
    transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
#dashboardView .home-module-icon {
    width: clamp(104px, 13dvh, 140px);
    height: clamp(104px, 13dvh, 140px);
    object-fit: contain;
    flex: 0 0 auto;
}
#dashboardView .module-card strong { font-size: clamp(1.08rem, 1.65vw, 1.45rem); line-height: 1.4; }
#dashboardView .module-card:not(:disabled):hover {
    border-color: #368afa;
    box-shadow: 0 9px 24px rgba(33, 107, 185, .1);
    transform: translateY(-2px);
}
#dashboardView .module-card:disabled { opacity: 1; color: #859bae; background: #fbfcfd; }
#dashboardView .module-card:disabled .home-module-icon { filter: grayscale(1); opacity: .42; }
.module-card:focus-visible, .icon-command:focus-visible, .match-segments input:focus-visible + span {
    outline: 3px solid #2481dd;
    outline-offset: 3px;
}
#portalView > .portal-footer {
    flex: 0 0 var(--portal-footer-height);
    height: var(--portal-footer-height);
    margin-top: auto;
    padding: 5px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid #dbe7f0;
    background: #fff;
    color: #718b9f;
    font-size: .78rem;
    direction: ltr;
}
.developer-brand { display: inline-flex; align-items: center; height: 28px; }
.developer-brand img { max-width: 104px; max-height: 27px; object-fit: contain; }
.developer-wordmark { color: #172e59; font: 800 21px/1 Arial, sans-serif; letter-spacing: .02em; }
.developer-wordmark::before { content: "◇"; color: #d4a127; padding-right: 4px; }
#portalView > .archive-workspace,
#portalView > .search-workspace {
    height: calc(100dvh - var(--portal-header-height) - var(--portal-footer-height));
    min-height: 320px;
    flex: 0 0 auto;
    background: #edf4fa;
}
#portalView .compact-commandbar {
    min-height: 54px;
    flex: 0 0 auto;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    white-space: nowrap;
}
#portalView .icon-command {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    min-height: 38px;
    padding: 7px;
    border: 1px solid #dbe7f1;
    border-radius: 9px;
    background: #f4f8fc;
    color: #145b99;
    text-decoration: none;
}
#portalView .icon-command:hover:not(:disabled) { background: #e7f2fe; border-color: #95c4f7; }
#portalView .primary-command { color: #0060b7; background: #e2f0ff; border-color: #b1d7fd; }
#portalView .danger-command { color: #b64148; }
#portalView .icon-command:disabled { opacity: .4; }
.action-icon { width: 23px; height: 23px; flex: none; pointer-events: none; }
#portalView .command-divider { flex: 0 0 1px; margin: 3px 4px; }
.workspace-caption { margin-left: auto; padding: 0 6px 0 18px; color: #123b52; font-size: 1.1rem; }
.workspace-message:empty { display: none; }
.workspace-message {
    flex: 0 0 auto;
    padding: 7px 16px;
    max-height: 6rem;
    overflow: auto;
    background: #fff8f7;
    border-bottom: 1px solid #edd9d9;
    color: #983b3b;
    font-size: .86rem;
    white-space: normal;
    overflow-wrap: anywhere;
}
.workspace-message.success { background: #f0f8f3; color: #246340; border-color: #d4e5d9; }
#portalView .search-toolbar-option { flex: 0 0 auto; gap: 7px; margin: 0 5px; font-size: .85rem; }
#portalView .search-toolbar-option select { height: 36px; min-width: 72px; padding: 4px 8px; border-radius: 7px; }
.search-match-modes { display: flex; align-items: center; gap: 9px; border: 0; padding: 0; margin: 0 6px; flex: 0 0 auto; min-width: 0; font-size: .85rem; }
.search-match-modes > span { font-weight: 600; }
.match-segments { display: flex; gap: 4px; }
html[lang="ar"] .match-segments { direction: rtl; }
.match-segments label { position: relative; display: block; margin: 0; cursor: pointer; font-size: .85rem; }
.match-segments input { position: absolute; width: 1px; height: 1px; padding: 0; margin: 0; opacity: 0; }
.match-segments span { display: block; padding: 8px 12px; min-height: 36px; line-height: 18px; background: #fff; border: 1px solid #cbdbea; border-radius: 7px; }
.match-segments input:checked + span { color: #fff; background: #145b99; border-color: #145b99; }
.search-match-modes:disabled { opacity: .55; }
.search-match-modes:disabled label { cursor: not-allowed; }
.portal-tooltip {
    position: fixed;
    z-index: 200;
    max-width: min(320px, calc(100vw - 16px));
    padding: 9px 12px;
    border-radius: 7px;
    background: #153e57;
    color: #fff;
    box-shadow: 0 5px 16px rgba(13, 39, 59, .2);
    font-size: .84rem;
    line-height: 1.5;
    text-align: center;
    overflow-wrap: anywhere;
}
#portalView .pane-heading { min-height: 42px; padding: 8px 12px; }
#portalView .pane-heading > .search-pager { flex-wrap: nowrap; }
#portalView .search-pager .icon-command { width: 30px; height: 30px; min-height: 30px; flex-basis: 30px; padding: 4px; }
#portalView .search-pager { white-space: nowrap; }
#portalView .archive-grid {
    grid-template-columns: minmax(190px, .78fr) minmax(340px, 1.15fr) minmax(320px, 1.8fr);
    min-height: 0;
}
#portalView .search-grid {
    display: grid;
    grid-template-columns: minmax(290px, 1fr) minmax(270px, 1.08fr) minmax(320px, 1.8fr);
    grid-template-rows: minmax(0, 1fr);
    flex: 1 1 auto;
    min-height: 0;
}
#portalView .search-viewer-pane { grid-column: auto; min-height: 0; }
#portalView .archive-navigation-pane { grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); }
#portalView .search-criteria-pane { grid-template-rows: minmax(120px, .65fr) minmax(180px, 1.35fr); }
#portalView .document-viewer > .viewer-frame,
#portalView .document-viewer > .pdf-blob-frame { min-height: 0; height: 100%; }
#portalView .viewer-placeholder { min-height: 8rem; }
#portalView .viewer-placeholder::before { content: ""; display: block; width: 48px; height: 60px; border: 3px solid #a4b9ca; border-radius: 6px; margin: 0 auto 12px; background: repeating-linear-gradient(to bottom, transparent 0 8px, #a4b9ca 8px 11px, transparent 11px 16px) center / 24px 36px no-repeat; }
/* Same panes and same forms on mobile; existing tabs select the visible pane. */
@media (max-width: 1000px) {
    #portalView .archive-mobile-tabs { display: grid; grid-template-columns: repeat(3, 1fr); flex: 0 0 auto; }
    #portalView .archive-grid, #portalView .search-grid { display: block; flex: 1 1 auto; min-height: 0; }
    #portalView .archive-pane, #portalView .search-pane { display: none; height: 100%; min-height: 0; }
    #portalView .archive-pane.active, #portalView .search-pane.active { display: flex; }
    #portalView .archive-navigation-pane.active { display: grid; grid-template-rows: minmax(120px, 1fr) minmax(120px, 1fr); }
    #portalView .search-criteria-pane.active { display: grid; grid-template-rows: minmax(110px, .65fr) minmax(180px, 1.35fr); }
    #portalView .archive-viewer-pane { grid-column: auto; }
    #portalView .workspace-caption { display: none; }
}
@media (max-width: 680px) {
    #portalView > .topbar { flex-wrap: wrap; gap: 5px; padding: 6px 12px; }
    #portalView .topbar-brand { gap: 8px; }
    #portalView .header-logo-frame { height: 40px; width: 76px; }
    #portalView .topbar-actions { width: 100%; justify-content: flex-end; gap: 6px; flex-wrap: nowrap; }
    #portalView .user-chip { width: auto; order: initial; font-size: .85rem; padding: 5px 8px; }
    #portalView .topbar-actions .secondary-button { padding: 6px 10px; font-size: .85rem; min-height: 34px; }
    #dashboardView { padding: 20px 14px; }
    #dashboardView .module-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    #dashboardView .module-card { min-height: 162px; padding: 14px 8px; }
    #dashboardView .module-card strong { font-size: 1.02rem; }
    #dashboardView .home-module-icon { width: 84px; height: 84px; }
    #portalView .icon-command { width: 42px; height: 42px; flex-basis: 42px; }
    #portalView .compact-commandbar { padding: 6px 10px; }
}
/* Preserve the existing full-size viewer without rebuilding its iframe. */
#portalView > #searchWorkspace.search-viewer-expanded { height: auto; min-height: 0; }
#portalView #searchWorkspace.search-viewer-expanded .search-grid { display: flex; }
#portalView #searchWorkspace.search-viewer-expanded .search-viewer-pane { display: flex; height: auto; }
#portalView #searchWorkspace.search-viewer-expanded .search-criteria-pane,
#portalView #searchWorkspace.search-viewer-expanded .search-results-pane,
#portalView #searchWorkspace.search-viewer-expanded .search-mobile-tabs { display: none; }
@media (prefers-reduced-motion: reduce) {
    #dashboardView .module-card { transition: none; }
    #dashboardView .module-card:not(:disabled):hover { transform: none; }
}

/* Reports keeps the search criteria and gives all remaining space to the grid. */
#portalView .reports-mode .search-grid { grid-template-columns: minmax(290px, .85fr) minmax(0, 2.8fr); }
#portalView .reports-mode .search-viewer-pane,
#portalView .reports-mode [data-search-pane="viewer"] { display: none; }
#portalView .reports-mode .search-results-table tbody tr { cursor: default; }
#portalView .reports-mode .search-cell-text { max-width: none; }
#portalView .export-command { color: #207347; background: #edf8f1; border-color: #b9dcc7; }
#portalView .export-command:hover:not(:disabled) { background: #e0f2e7; border-color: #6cb88d; }
#portalView .export-command[aria-busy="true"] .action-icon { opacity: .5; }
@media (max-width: 1000px) {
    #portalView .reports-mode .search-mobile-tabs { grid-template-columns: repeat(2, 1fr); }
}

/* Workflow inbox badge keeps its numeric value; no display cap. */
#workflowModule { position: relative; }
.workflow-pending-count { position: absolute; inset-block-start: 14px; inset-inline-end: 20px; color: #c52332; background: #fff1f2; border-radius: 999px; min-width: 36px; padding: 4px 10px; font-size: 1.35rem; font-weight: 800; line-height: 1.3; }

/* Nine home services retain a balanced grid on desktop screens. */
@media (min-width:1000px) {
    #dashboardView .module-grid { grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; }
    #dashboardView .module-card { min-height:clamp(132px,18dvh,188px); padding:12px; gap:6px; }
    #dashboardView .home-module-icon { width:clamp(76px,10dvh,106px); height:clamp(76px,10dvh,106px); }
    #dashboardView .module-card strong { font-size:clamp(1.05rem,1.4vw,1.32rem); }
}
