/* Final cross-device compatibility layer shared by every web layout. */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

[hidden] {
    display: none !important;
}

body {
    max-width: 100%;
    overflow-x: hidden;
}

img,
svg,
video,
canvas {
    max-width: 100%;
}

img,
video {
    height: auto;
}

button,
input,
select,
textarea {
    max-width: 100%;
}

button,
select,
input[type="button"],
input[type="submit"] {
    touch-action: manipulation;
}

textarea {
    resize: vertical;
}

.filter-dialog {
    background: transparent;
    border: 0;
    margin: auto;
    max-height: calc(100dvh - 32px);
    max-width: 620px;
    padding: 0;
    width: calc(100vw - 32px);
}

.filter-dialog::backdrop {
    background: rgba(10, 32, 17, 0.58);
    backdrop-filter: blur(2px);
}

.filter-dialog-panel {
    background: #fff;
    border: 1px solid #d8e2dc;
    border-radius: 10px;
    box-shadow: 0 22px 64px rgba(10, 32, 17, 0.24);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
}

.filter-dialog-header,
.filter-dialog-actions {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 16px 18px;
}

.filter-dialog-header {
    border-bottom: 1px solid #e6ece8;
}

.filter-dialog-header h2 {
    color: var(--feu-green, #0f5a3d);
    font-size: 19px;
    margin: 0;
}

.filter-dialog-body {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 18px;
}

.filter-dialog-body label,
.filter-dialog-body .input-group {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.filter-dialog-body :is(input, select, textarea) {
    min-height: 42px;
    width: 100%;
}

.filter-dialog-actions {
    border-top: 1px solid #e6ece8;
    justify-content: flex-end;
}

.filter-trigger-count {
    align-items: center;
    background: var(--feu-green, #0f5a3d);
    border-radius: 999px;
    color: #fff;
    display: inline-flex;
    font-size: 10px;
    justify-content: center;
    margin-left: 5px;
    min-height: 19px;
    min-width: 19px;
    padding: 1px 5px;
}

/* Account menu remains correctly sized even if an optional asset is delayed. */
.portal-account-menu {
    position: relative;
    z-index: 120;
}

.portal-account-trigger {
    align-items: center;
    appearance: none;
    background: transparent;
    border: 0;
    box-shadow: none;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    gap: 8px;
    max-width: min(310px, 48vw);
    min-height: 42px;
    padding: 4px 0 4px 8px;
    text-align: left;
}

.portal-account-copy {
    display: grid;
    line-height: 1.15;
    min-width: 0;
}

.portal-account-copy strong,
.portal-account-copy small {
    display: block;
    max-width: 190px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.portal-account-copy strong {
    color: #fff;
    font-size: 14px;
}

.portal-account-copy small {
    color: rgba(255, 255, 255, 0.76);
    font-size: 11px;
    margin-top: 3px;
}

svg.portal-account-chevron {
    display: block;
    flex: 0 0 17px;
    height: 17px !important;
    max-height: 17px;
    max-width: 17px;
    overflow: visible;
    transition: transform 180ms ease;
    width: 17px !important;
}

.portal-account-menu.is-open .portal-account-chevron {
    transform: rotate(180deg);
}

.portal-account-dropdown {
    background: #fff;
    border: 1px solid #dfe6da;
    border-radius: 9px;
    box-shadow: 0 16px 36px rgba(25, 47, 31, 0.19);
    max-width: calc(100vw - 24px);
    min-width: 210px;
    padding: 6px;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 1300;
}

.portal-account-item {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: 6px;
    color: #344054;
    cursor: pointer;
    display: flex;
    font: inherit;
    font-size: 13px;
    min-height: 38px;
    padding: 8px 10px;
    text-align: left;
    text-decoration: none;
    width: 100%;
}

.portal-account-signout {
    border-top: 1px solid #edf0e9;
    margin: 5px 0 0;
    padding-top: 5px;
}

.portal-account-item-danger {
    color: #b42318;
}

.auth-client-feedback {
    display: none !important;
}

.auth-client-feedback.is-visible:not([hidden]) {
    display: flex !important;
}

:is(.admin-shell, .user-shell, .superadmin-shell) :is(
    .wrapper,
    .main-content,
    .content-frame,
    .container,
    .card,
    .form-card,
    .builder-page,
    .builder-grid,
    .builder-panel,
    .builder-workspace,
    .performance-page,
    .audit-page,
    .settings-page,
    .management-card
) {
    min-width: 0;
    max-width: 100%;
}

.portal-table-scroll,
.management-table-wrap,
.table-responsive,
.settings-table-wrap,
.audit-table-wrap,
.builder-table-wrap {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
}

:is(.portal-table-scroll, .management-table-wrap, .table-responsive, .settings-table-wrap, .audit-table-wrap, .builder-table-wrap) table {
    width: 100%;
}

@supports (overflow: clip) {
    body { overflow-x: clip; }
}

@media (max-width: 1024px) {
    body {
        background-attachment: scroll !important;
    }

    :is(.admin-shell, .user-shell, .superadmin-shell) :is(
        input:not([type="checkbox"]):not([type="radio"]),
        select,
        textarea
    ) {
        font-size: 16px;
    }

    .superadmin-shell .management-table-wrap,
    .admin-shell :is(.portal-table-scroll, .audit-table-wrap, .builder-table-wrap, .settings-table-wrap) {
        scrollbar-width: thin;
    }
}

@media (max-width: 900px) {
    .auth-shell {
        min-width: 0;
    }

    .auth-page,
    .auth-panel,
    .auth-panel-inner,
    .auth-card {
        max-width: 100%;
        min-width: 0;
    }

    .auth-panel-inner {
        padding-bottom: max(27px, env(safe-area-inset-bottom));
    }

    .admin-shell .main-content,
    .user-shell .student-shell-content,
    .superadmin-shell .superadmin-content {
        width: 100%;
    }
}

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

    .filter-dialog-actions {
        align-items: stretch;
        flex-direction: column-reverse;
    }

    .filter-dialog-actions > * {
        justify-content: center;
        width: 100%;
    }
    :is(.admin-shell, .user-shell, .superadmin-shell) :is(.page-actions, .directory-page-actions, .form-actions) {
        gap: 10px;
    }

    :is(.admin-shell, .user-shell, .superadmin-shell) :is(.page-actions, .directory-page-actions, .form-actions) > * {
        min-width: 0;
        max-width: 100%;
    }

    :is(.admin-shell, .user-shell, .superadmin-shell) table {
        font-size: 13px;
    }

    :is(.admin-shell, .user-shell, .superadmin-shell) :is(th, td) {
        padding-inline: 10px;
    }

    .auth-card,
    .auth-card form,
    .auth-card .field {
        min-width: 0;
        width: 100%;
    }

    .auth-footer {
        align-items: center;
        flex-wrap: wrap;
        row-gap: 3px;
        text-align: center;
    }
}

@media (max-width: 380px) {
    .portal-topbar .portal-account-copy small {
        display: none;
    }

    .portal-topbar .brand-lockup-text {
        max-width: 74px;
    }

    .auth-brand-copy strong {
        white-space: normal;
    }
}

@media (hover: none) and (pointer: coarse) {
    :is(a, button, summary, input, select, textarea) {
        -webkit-tap-highlight-color: rgba(15, 90, 61, 0.14);
    }

    :is(.subject-card, .card, .form-card):hover {
        transform: none !important;
    }
}

/* Balanced application density: less decorative whitespace, unchanged usability. */
:is(
    .portal-eyebrow,
    .student-eyebrow,
    .superadmin-eyebrow,
    .builder-eyebrow,
    .performance-eyebrow,
    .audit-kicker,
    .settings-eyebrow,
    .section-kicker
) {
    display: none !important;
}

.admin-shell .main-content {
    padding: 20px 24px 36px;
}

.admin-shell :is(.page-content, .builder-page, .performance-page, .audit-page, .settings-page) {
    gap: 14px;
}

.admin-shell :is(.page-heading, .portal-page-hero, .builder-hero, .performance-hero, .audit-hero, .settings-hero),
.user-shell .student-hero,
.superadmin-shell .superadmin-hero {
    gap: 16px;
    margin-bottom: 14px;
    padding-bottom: 10px;
}

.admin-shell :is(.page-heading, .dashboard-hero, .builder-hero, .performance-hero, .audit-hero, .settings-hero) :is(h1, h2),
.user-shell :is(.student-hero h1, .header-card h1),
.superadmin-shell .superadmin-hero h1 {
    font-size: clamp(21px, 1.7vw, 25px) !important;
    line-height: 1.25 !important;
}

.portal-page-description,
.admin-shell :is(.builder-subtitle, .performance-hero p, .audit-hero p, .settings-hero p),
.student-hero p,
.superadmin-hero p {
    margin-top: 4px;
    line-height: 1.45;
}

.period-badge,
.admin-shell .audit-current-view,
.superadmin-hero-badge {
    gap: 1px;
    min-width: 145px;
    padding: 8px 11px;
}

.user-shell .student-shell-content,
.superadmin-shell .superadmin-content {
    margin-top: 22px;
    margin-bottom: 40px;
}

/* Medium primary actions with a restrained tactile texture. */
:is(.admin-shell, .user-shell, .superadmin-shell) .btn-primary {
    background-color: #0f6546 !important;
    background-image:
        radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.12) 1px, transparent 1.2px),
        linear-gradient(180deg, #147451, #0d5b3f) !important;
    background-size: 10px 10px, 100% 100% !important;
    border: 1px solid #0b543a !important;
    border-radius: 8px !important;
    box-shadow: 0 3px 8px rgba(8, 72, 49, 0.18), inset 0 1px rgba(255, 255, 255, 0.14) !important;
    color: #fff !important;
    font-size: 13px;
    font-weight: 700;
    min-height: 40px;
    padding: 8px 15px;
}

:is(.admin-shell, .user-shell, .superadmin-shell) .btn-primary:hover {
    background-color: #0b573c !important;
    background-image:
        radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.1) 1px, transparent 1.2px),
        linear-gradient(180deg, #126946, #094c35) !important;
    box-shadow: 0 5px 12px rgba(8, 72, 49, 0.22), inset 0 1px rgba(255, 255, 255, 0.12) !important;
}

.directory-page-actions .btn-primary,
.management-card-header .btn-primary {
    min-width: 0;
    white-space: nowrap;
}

/* Faculty and student directories: compact controls and thinner result rows. */
.admin-shell .directory-action-panel {
    padding: 16px !important;
}

.admin-shell .directory-action-panel h3,
.admin-shell .directory-action-panel .help-text {
    margin-top: 0;
}

.admin-shell #directory-results {
    overflow: hidden;
    padding: 0 !important;
}

.admin-shell #directory-results .card-heading {
    margin: 0;
    padding: 14px 16px 8px;
}

.admin-shell #directory-results .card-heading h3 {
    font-size: 17px;
}

.admin-shell #directory-results .directory-toolbar {
    padding: 0 16px 12px;
}

.admin-shell .directory-search-row {
    gap: 8px;
}

.admin-shell #directory-results table th {
    padding: 9px 14px !important;
}

.admin-shell #directory-results table td {
    font-size: 13px;
    line-height: 1.25;
    padding: 7px 12px !important;
    vertical-align: middle;
}

.admin-shell #directory-results table td small {
    font-size: 11px;
}

.admin-shell #directory-results :is(.status-pill, .btn-small) {
    min-height: 28px !important;
    padding: 4px 9px !important;
}

.directory-assignment-dropdown { min-width: 150px; }
.directory-assignment-dropdown > summary { background: #fff; border: 1px solid #cdd9d1; border-radius: 6px; color: var(--feu-green); cursor: pointer; font-weight: 700; list-style: none; padding: 6px 30px 6px 9px; position: relative; }
.directory-assignment-dropdown > summary::after { content: '⌄'; position: absolute; right: 9px; }
.directory-assignment-dropdown[open] > summary::after { content: '⌃'; }
.directory-assignment-menu { background: #fff; border: 1px solid #d8e2dc; border-radius: 8px; display: grid; gap: 5px; margin-top: 5px; max-height: 230px; min-width: 280px; overflow-y: auto; padding: 7px; }
.directory-assignment-menu > div { align-items: center; background: #f8faf7; border-radius: 5px; display: flex; gap: 8px; justify-content: space-between; padding: 5px 7px; }
.directory-assignment-menu span strong,
.directory-assignment-menu span small { display: block; }
.directory-assignment-menu span small { color: #667085; margin-top: 2px; }
.directory-assignment-menu form { display: inline-flex; }
.directory-empty-value { color: #667085; }

.admin-shell .directory-modal {
    max-height: min(84dvh, 720px);
    width: min(700px, calc(100% - 32px));
}

.admin-shell .directory-modal-header,
.admin-shell .directory-modal-body {
    padding: 16px 18px;
}

.admin-shell .directory-modal-section {
    margin-bottom: 14px;
    padding-bottom: 14px;
}

/* Security page: preserve hierarchy while fitting more useful information. */
.admin-shell .audit-page {
    gap: 12px;
}

.admin-shell .audit-hero {
    margin-bottom: 0;
    padding: 0 0 10px;
}

.admin-shell .audit-hero h1 {
    font-size: clamp(22px, 1.8vw, 26px);
    margin-top: 0;
}

.admin-shell .audit-current-view strong {
    font-size: 15px;
    margin-top: 1px;
}

.admin-shell .audit-section-heading > div > span,
.admin-shell .audit-filter-header > div > span,
.admin-shell .audit-table-header > div > span,
.admin-shell .audit-current-view > span {
    display: none;
}

.admin-shell .audit-section-heading h2 {
    font-size: 18px;
    margin-top: 0;
}

.admin-shell .audit-summary-grid {
    gap: 9px;
}

.admin-shell .audit-summary-card {
    gap: 4px;
    min-height: 88px;
    padding: 11px 13px;
}

.admin-shell .audit-summary-card strong {
    font-size: 24px;
}

.admin-shell .audit-summary-card small {
    font-size: 11px;
    line-height: 1.3;
}

.admin-shell .audit-card {
    padding: 14px;
}

.admin-shell .audit-filter-card {
    gap: 11px;
}

.admin-shell .audit-filter-header h2,
.admin-shell .audit-table-header h2 {
    font-size: 17px;
    margin-top: 0;
}

.admin-shell .audit-filter-form {
    gap: 9px;
}

.admin-shell .audit-filter-main,
.admin-shell .audit-advanced-grid {
    gap: 9px;
}

.admin-shell .audit-filter-form input,
.admin-shell .audit-filter-form select {
    min-height: 40px;
}

.admin-shell .audit-advanced {
    padding-top: 9px;
}

.admin-shell .audit-table-header {
    padding: 12px 14px;
}

.admin-shell .audit-table th {
    padding: 9px 12px !important;
}

.admin-shell .audit-table td {
    line-height: 1.35;
    padding: 10px 12px !important;
}

.admin-shell .audit-activity p {
    margin-top: 4px;
}

/* Superadmin: compact cards and a centered, bounded account dialog. */
.superadmin-shell .stats-grid {
    gap: 12px;
    margin-bottom: 18px;
}

.superadmin-shell .stat-card {
    padding: 16px !important;
}

.superadmin-shell .stat-value {
    font-size: 30px;
    margin: 4px 0 0;
}

.superadmin-shell .management-card-header {
    padding: 16px 18px;
}

.superadmin-shell .management-card-header p {
    margin: 4px 0 0;
}

.superadmin-shell .management-table-wrap {
    padding: 0 18px 16px;
}

.superadmin-shell .admin-table :is(th, td) {
    padding-block: 10px !important;
}

.superadmin-shell .modal-overlay {
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 16px;
}

.superadmin-shell .modal-overlay > .modal-card {
    margin: auto;
    max-height: min(88dvh, 690px);
    max-width: 560px !important;
    overflow-y: auto;
    width: min(560px, calc(100vw - 32px)) !important;
}

.superadmin-shell .modal-header {
    padding: 16px 18px;
}

.superadmin-shell .modal-body {
    gap: 10px;
    padding: 16px 18px 18px;
}

.superadmin-shell .modal-body .form-group {
    margin: 0;
}

.superadmin-shell .modal-body .form-control {
    margin: 4px 0 0;
    min-height: 40px;
    padding-block: 8px;
}

.superadmin-shell .modal-actions {
    margin-top: 3px;
}

@media (max-width: 900px) {
    .admin-shell .main-content {
        padding: 18px 14px 30px;
    }
}

@media (max-width: 640px) {
    .admin-shell :is(.page-heading, .portal-page-hero, .builder-hero, .performance-hero, .audit-hero, .settings-hero),
    .user-shell .student-hero,
    .superadmin-shell .superadmin-hero {
        gap: 10px;
        margin-bottom: 12px;
        padding-bottom: 9px;
    }

    .directory-page-actions .btn-primary,
    .management-card-header .btn-primary {
        width: 100%;
    }

    .admin-shell .audit-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .admin-shell .audit-summary-card {
        min-height: 82px;
    }

    .superadmin-shell .modal-overlay > .modal-card {
        max-height: calc(100dvh - 16px);
        width: calc(100vw - 16px) !important;
    }
}

@media print {
    .login-transition,
    .portal-topbar,
    .sidebar,
    .sidebar-scrim,
    .nav-menu-toggle {
        display: none !important;
    }

    body {
        background: #fff !important;
        overflow: visible;
    }
}
