/* HPC-AC institution administration surfaces. No JavaScript dependency. */
.hpc-page-scope { display: none !important; }

body:has(.hpc-scope-institution-users),
body:has(.hpc-scope-institution-roles),
body:has(.hpc-scope-assessment-schedule),
body:has(.hpc-scope-assessment-results),
body:has(.hpc-scope-assessment-reports),
body:has(.hpc-scope-tenant-backups),
body:has(.hpc-scope-report-templates),
body:has(.hpc-scope-tenant-marketplace) {
    overflow-x: hidden;
}

body:has(.hpc-scope-institution-users) main,
body:has(.hpc-scope-institution-roles) main,
body:has(.hpc-scope-assessment-schedule) main,
body:has(.hpc-scope-assessment-results) main,
body:has(.hpc-scope-assessment-reports) main,
body:has(.hpc-scope-tenant-backups) main,
body:has(.hpc-scope-report-templates) main,
body:has(.hpc-scope-tenant-marketplace) main {
    min-width: 0;
}

/* Core account/role administration: keep the three primary navigation items in one row. */
body:has(.hpc-scope-institution-roles) nav:has(a[href*="institution-users"]):has(a[href*="institution-roles"]),
body:has(.hpc-scope-institution-users) nav:has(a[href*="institution-users"]):has(a[href*="institution-roles"]) {
    display: flex !important;
    flex-flow: row wrap !important;
    align-items: center !important;
    gap: .5rem !important;
    width: 100% !important;
}
body:has(.hpc-scope-institution-roles) nav:has(a[href*="institution-users"]):has(a[href*="institution-roles"]) > *,
body:has(.hpc-scope-institution-users) nav:has(a[href*="institution-users"]):has(a[href*="institution-roles"]) > * {
    width: auto !important;
    flex: 0 0 auto !important;
    margin: 0 !important;
}
body:has(.hpc-scope-institution-roles) nav:has(a[href*="institution-users"]):has(a[href*="institution-roles"]) a,
body:has(.hpc-scope-institution-users) nav:has(a[href*="institution-users"]):has(a[href*="institution-roles"]) a {
    min-height: 2.5rem;
    padding: .55rem .85rem !important;
    white-space: nowrap;
}

/* Institution users: eliminate viewport clipping seen on wide metric cards/filter controls. */
body:has(.hpc-scope-institution-users) .grid,
body:has(.hpc-scope-institution-users) .ui-auto-grid,
body:has(.hpc-scope-institution-users) .adw-filter-grid {
    min-width: 0;
}
body:has(.hpc-scope-institution-users) .ui-auto-grid,
body:has(.hpc-scope-institution-users) .grid.grid-cols-3,
body:has(.hpc-scope-institution-users) .grid.grid-cols-4 {
    grid-template-columns: repeat(auto-fit, minmax(min(16rem, 100%), 1fr)) !important;
}
body:has(.hpc-scope-institution-users) form:has(input[type="search"]),
body:has(.hpc-scope-institution-users) form:has(input[name="q"]) {
    display: grid !important;
    grid-template-columns: minmax(15rem, 2fr) repeat(2, minmax(11rem, 1fr)) auto !important;
    align-items: end;
    gap: .65rem;
    min-width: 0;
}
body:has(.hpc-scope-institution-users) input,
body:has(.hpc-scope-institution-users) select {
    min-width: 0 !important;
    max-width: 100% !important;
}
body:has(.hpc-scope-institution-users) .alert,
body:has(.hpc-scope-institution-users) .ui-alert {
    max-width: 100%;
    white-space: normal !important;
    overflow-wrap: anywhere;
}

/* Dense tables use horizontal scrolling inside their own card, never the entire page. */
body:has(.hpc-scope-institution-users) .table-responsive,
body:has(.hpc-scope-institution-users) .as-table-wrap,
body:has(.hpc-scope-institution-users) .ui-table-shell,
body:has(.hpc-scope-assessment-schedule) .table-responsive,
body:has(.hpc-scope-assessment-schedule) .as-table-wrap,
body:has(.hpc-scope-assessment-results) .table-responsive,
body:has(.hpc-scope-assessment-results) .as-table-wrap,
body:has(.hpc-scope-assessment-reports) .table-responsive,
body:has(.hpc-scope-assessment-reports) .as-table-wrap,
body:has(.hpc-scope-tenant-backups) .table-responsive,
body:has(.hpc-scope-tenant-backups) .as-table-wrap {
    max-width: 100%;
    overflow-x: auto !important;
    overscroll-behavior-inline: contain;
}

/* Results/report group rows inserted server-side. */
.hpc-record-group-row > td {
    padding: .75rem 1rem !important;
    background: color-mix(in srgb, currentColor 4%, transparent) !important;
    border-top: 1px solid rgba(100,116,139,.22) !important;
    border-bottom: 1px solid rgba(100,116,139,.18) !important;
}
.hpc-record-group-row strong { font-size: .9rem; }
.hpc-record-group-row small { display: block; margin-top: .15rem; opacity: .72; }

/* Schedule/backups: readable cards and controls. */
body:has(.hpc-scope-assessment-schedule) form,
body:has(.hpc-scope-tenant-backups) form {
    min-width: 0;
}
body:has(.hpc-scope-assessment-schedule) input,
body:has(.hpc-scope-assessment-schedule) select,
body:has(.hpc-scope-tenant-backups) input,
body:has(.hpc-scope-tenant-backups) select {
    max-width: 100%;
}
body:has(.hpc-scope-assessment-schedule) .card,
body:has(.hpc-scope-tenant-backups) .card {
    min-width: 0;
}

/* Row action dropdown on Report Templates: escape cramped cell geometry and stay above table. */
body:has(.hpc-scope-report-templates) .as-table-wrap,
body:has(.hpc-scope-report-templates) .as-card:has(.as-table) {
    overflow: visible !important;
}
body:has(.hpc-scope-report-templates) .as-table { position: relative; }
body:has(.hpc-scope-report-templates) .as-actions { position: relative; overflow: visible !important; justify-content: flex-end; }
body:has(.hpc-scope-report-templates) .hpc-row-action-menu,
body:has(.hpc-scope-report-templates) [data-row-actions],
body:has(.hpc-scope-report-templates) details:has([role="menu"]) {
    position: relative;
    z-index: 40;
}
body:has(.hpc-scope-report-templates) [role="menu"] {
    min-width: 15rem !important;
    max-width: min(22rem, calc(100vw - 2rem));
    z-index: 9999 !important;
    white-space: normal;
}
body:has(.hpc-scope-report-templates) [role="menu"] a,
body:has(.hpc-scope-report-templates) [role="menu"] button {
    width: 100%;
    min-height: 2.35rem;
    display: flex;
    align-items: center;
    gap: .55rem;
    text-align: left;
}

/* Marketplace ownership summary. */
.hpc-commercial-ownership {
    margin: 0 0 1rem;
    padding: 1rem;
    border: 1px solid rgba(14,116,144,.22);
    border-radius: .9rem;
    background: rgba(14,116,144,.045);
}
.hpc-commercial-ownership__title { font-weight: 700; margin-bottom: .3rem; }
.hpc-commercial-ownership__items { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .65rem; }
.hpc-commercial-ownership__badge {
    display: inline-flex;
    align-items: center;
    min-height: 1.8rem;
    padding: .25rem .55rem;
    border: 1px solid rgba(34,197,94,.28);
    border-radius: 999px;
    background: rgba(34,197,94,.08);
    font-size: .78rem;
    font-weight: 650;
}

@media (max-width: 960px) {
    body:has(.hpc-scope-institution-users) form:has(input[type="search"]),
    body:has(.hpc-scope-institution-users) form:has(input[name="q"]) {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    }
}
@media (max-width: 640px) {
    body:has(.hpc-scope-institution-users) form:has(input[type="search"]),
    body:has(.hpc-scope-institution-users) form:has(input[name="q"]) {
        grid-template-columns: minmax(0, 1fr) !important;
    }
    body:has(.hpc-scope-institution-roles) nav:has(a[href*="institution-users"]):has(a[href*="institution-roles"]) > *,
    body:has(.hpc-scope-institution-users) nav:has(a[href*="institution-users"]):has(a[href*="institution-roles"]) > * {
        flex: 1 1 auto !important;
    }
}
