.portal-module-topbar {
    min-height: 64px;
    background: #fff !important;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(16, 24, 40, .08);
    color: #0f172a;
}

.portal-module-topbar .nav-link {
    color: #475569;
}

.portal-module-topbar .navbar-brand {
    color: #0f172a !important;
}

.portal-module-topbar .navbar-brand:hover,
.portal-module-topbar .navbar-brand:focus-visible,
.portal-module-topbar .nav-link:hover,
.portal-module-topbar .nav-link:focus-visible {
    color: #0f172a;
}

.portal-header-brand .nav-link {
    display: flex;
    align-items: center;
    gap: .5rem;
    color: #0f172a;
    font-weight: 700;
    line-height: 1.1;
}

.portal-header-brand img {
    flex: 0 0 auto;
    border-radius: 7px;
    object-fit: contain;
}

.portal-header-brand small {
    display: block;
    margin-top: .15rem;
    color: #64748b;
    font-size: .68rem;
    font-weight: 500;
}

.admin-header-brand .nav-link {
    gap: .65rem;
    padding-left: 0;
}

.admin-header-brand img {
    width: 40px;
    height: 40px;
}

.admin-header-school-name {
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: min(52vw, 520px);
}

.portal-header-school-name {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.portal-header-school-title {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-header-school-name small {
    margin-top: .2rem;
}

.portal-module-topbar .navbar-brand > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.portal-tool-button,
.portal-user-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: #475569;
    background: transparent;
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

.legal-document-content {
    overflow-wrap: anywhere;
    line-height: 1.75;
}

.portal-release-toast {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1090;
    display: flex;
    align-items: flex-start;
    gap: .85rem;
    width: min(31rem, calc(100vw - 2rem));
    padding: 1rem 1.1rem;
    border: 2px solid #60a5fa;
    border-radius: 1rem;
    background: linear-gradient(135deg, #eff6ff, #fff);
    box-shadow: 0 12px 36px rgba(15, 23, 42, .32);
    color: #0f172a;
}

.portal-release-toast[hidden] {
    display: none;
}

.portal-release-toast-message {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: .25rem;
    font-size: .95rem;
}

.portal-release-toast-icon {
    margin-top: .15rem;
    color: #1d4ed8;
    font-size: 1.5rem;
}

.portal-release-toast-version {
    color: #475569;
    font-size: .82rem;
    font-weight: 500;
}

.portal-release-toast-link {
    display: inline-block;
    align-self: flex-start;
    margin-top: .25rem;
    color: #1d4ed8;
    font-size: .95rem;
    font-weight: 700;
    text-decoration: underline;
}

.portal-release-toast-link:hover,
.portal-release-toast-link:focus-visible {
    color: #1e40af;
}

.portal-release-toast-dismiss {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    margin: -.35rem -.4rem 0 0;
    padding: .2rem;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #334155;
    cursor: pointer;
    flex: 0 0 auto;
}

.portal-release-toast-dismiss:hover,
.portal-release-toast-dismiss:focus-visible {
    background: #dbeafe;
    color: #0f172a;
}

@media (max-width: 767.98px) {
    .portal-release-toast {
        right: .75rem;
        bottom: 88px;
        left: .75rem;
        width: auto;
        padding: .9rem;
        gap: .65rem;
    }

    .app-release-modal .modal-dialog-centered {
        min-height: 0;
        align-items: flex-start;
    }

    .app-release-modal .modal-dialog {
        height: auto !important;
        min-height: 0 !important;
        max-height: 80vh !important;
        max-height: 80dvh !important;
        margin: .5rem auto 9rem;
    }

    .app-release-modal .modal-content {
        height: auto !important;
        max-height: 80vh !important;
        max-height: 80dvh !important;
    }

    .app-release-modal .modal-body {
        min-height: 0;
        overflow-y: auto;
    }

    .app-release-modal .app-release-notes {
        max-height: 20vh;
    }
}

.app-release-notes {
    max-height: 45vh;
    overflow-y: auto;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.portal-tool-button {
    width: 40px;
    padding: 0;
    font-size: 1rem;
}

.portal-tool-button:hover,
.portal-tool-button:focus-visible,
.portal-user-button:hover,
.portal-user-button:focus-visible {
    color: #0f172a;
    background: #f1f5f9;
    border-color: #e2e8f0;
}

.portal-notification-center {
    position: relative;
}

.portal-notification-toggle {
    position: relative;
    display: inline-flex;
    min-width: 40px;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    padding: .5rem;
    border: 0;
    border-radius: .5rem;
    color: inherit;
    background: transparent;
}

.portal-notification-toggle:hover,
.portal-notification-toggle:focus-visible {
    color: #0f172a;
    background: #f1f5f9;
}

.portal-notification-menu {
    width: min(390px, calc(100vw - 1rem));
    max-height: min(520px, calc(100vh - 5rem));
    overflow: hidden;
    border: 1px solid #e2e8f0;
    border-radius: .75rem;
    box-shadow: 0 12px 30px rgba(15, 23, 42, .16);
}

.portal-notification-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .75rem 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.portal-notification-mark-all {
    padding: .4rem 1rem;
    text-align: right;
    border-bottom: 1px solid #eef2f6;
}

.portal-notification-list {
    max-height: min(360px, calc(100vh - 12rem));
    overflow-y: auto;
    overscroll-behavior: contain;
}

.portal-notification-item {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    padding: .65rem .75rem .65rem 1rem;
    border-bottom: 1px solid #eef2f6;
}

.portal-notification-content {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
    gap: .2rem;
    color: inherit;
    text-decoration: none;
}

.portal-notification-content:hover strong {
    text-decoration: underline;
}

.portal-notification-content span,
.portal-notification-content small {
    overflow-wrap: anywhere;
}

.portal-notification-content span {
    color: #475569;
    font-size: .82rem;
}

.portal-notification-content small {
    color: #64748b;
    font-size: .7rem;
}

.portal-notification-mark-read {
    white-space: nowrap;
    text-decoration: none;
    font-size: .72rem;
}

.portal-notification-extra {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .7rem 1rem;
    color: #334155;
    text-decoration: none;
    border-bottom: 1px solid #eef2f6;
}

.portal-notification-extra > span:first-of-type {
    min-width: 0;
    flex: 1;
    font-weight: 600;
}

.portal-notification-extra small {
    display: block;
    color: #64748b;
    font-size: .72rem;
    font-weight: 400;
}

.portal-notification-extra:hover,
.portal-notification-footer:hover {
    background: #f8fafc;
}

.portal-notification-empty {
    padding: 1.25rem 1rem;
    color: #64748b;
    text-align: center;
}

.portal-notification-footer {
    display: block;
    padding: .65rem 1rem;
    color: #2563eb;
    text-align: center;
    text-decoration: none;
    border-top: 1px solid #e2e8f0;
}

.portal-user-menu {
    display: flex;
    align-items: center;
    list-style: none;
}

.portal-user-button {
    justify-content: flex-start;
    gap: .6rem;
    padding: .25rem .5rem .25rem .25rem;
    text-align: left;
}

.portal-user-avatar {
    position: relative;
    display: inline-flex;
    flex: 0 0 36px;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: #fff;
    background: #2c6e91;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .02em;
    overflow: hidden;
}

.portal-user-avatar-photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    object-fit: cover;
}

.portal-user-details {
    display: flex;
    min-width: 0;
    flex-direction: column;
    line-height: 1.2;
}

.portal-user-name {
    max-width: 11rem;
    overflow: hidden;
    color: #0f172a;
    font-size: .85rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.portal-user-role {
    color: #64748b;
    font-size: .72rem;
}

.portal-user-chevron {
    margin-left: .2rem;
    color: #64748b;
    font-size: .7rem;
}

@media (max-width: 575.98px) {
    .portal-module-topbar {
        padding-right: .75rem !important;
        padding-left: .75rem !important;
    }

    .portal-module-topbar .navbar-nav {
        min-width: 0;
        flex-wrap: nowrap;
    }

    .portal-module-topbar .portal-header-brand {
        min-width: 0;
        max-width: 42vw;
        flex: 0 1 42vw;
    }

    .admin-header-brand .nav-link {
        min-width: 0;
        max-width: 100%;
        gap: .45rem;
    }

    .admin-header-brand img {
        width: 34px;
        height: 34px;
    }

    .admin-header-school-name {
        min-width: 0;
        max-width: calc(42vw - 42px);
    }

    .portal-module-topbar .portal-header-brand .nav-link,
    .portal-module-topbar a.portal-header-brand {
        min-width: 0;
        max-width: 42vw;
    }

    .portal-header-school-title {
        display: block;
        max-width: min(calc(42vw - 42px), 10rem);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .portal-header-school-title::after {
        content: " Portal";
    }

    .admin-header-school-title {
        font-size: 0;
    }

    .admin-header-school-title::after {
        content: attr(data-mobile-title);
        font-size: .95rem;
        line-height: 1.1;
    }

    .admin-header-school-name small {
        display: none;
    }

    .portal-header-brand small {
        display: none;
    }

    .portal-user-chevron {
        display: none;
    }

    .portal-user-role {
        display: none;
    }

    .portal-user-name {
        max-width: 4.5rem;
        font-size: .75rem;
    }

    .portal-user-menu,
    .portal-user-button,
    .portal-user-details {
        min-width: 0;
    }

    .portal-user-button {
        gap: .35rem;
        padding: .15rem .25rem .15rem .15rem;
    }

    .portal-tool-button {
        width: 36px;
        min-height: 36px;
    }

}

/* Keep oversized decorative icons proportionate across modules */
.card .fa-2x, .card .fa-3x, .alert .fa-2x { font-size: 1.5em; }
.card .fa-4x, .card .fa-5x, .modal .fa-4x, .modal .fa-5x { font-size: 2.5em; }
.icon-shape { width: 40px; height: 40px; font-size: 1rem; }
@media (max-width: 767.98px) {
    .card .fa-2x, .card .fa-3x, .alert .fa-2x, .modal .fa-2x, .modal .fa-3x { font-size: 1.25em; }
    .card .fa-4x, .card .fa-5x, .modal .fa-4x, .modal .fa-5x, .fa-4x, .fa-5x { font-size: 2em; }
    .icon-shape { width: 32px; height: 32px; font-size: .85rem; }
    /* Corner icons on stat cards add height without adding information */
    .card-body.d-flex > i.fa-2x, .card-body.d-flex > i.fa-3x,
    .card-body > .d-flex > i.fa-2x, .card-body > .d-flex > i.fa-3x,
    .card-body > .d-flex > .icon-shape, .card-body.d-flex > .icon-shape,
    .card-body .d-flex.justify-content-between > .icon-shape { display: none !important; }
    .card .mb-3 > i.fa-2x, .card .mb-3 > i.fa-3x, .card .mb-3 > i.fa-4x { margin-bottom: 0 !important; }
    .btn i.fas, .btn i.far { font-size: .9em; }
    .portal-notification-menu i { font-size: .95rem; }
}

/* Notification menu: pin to the viewport on phones so it never overflows */
@media (max-width: 575.98px) {
    .portal-notification-center {
        position: static;
    }

    .portal-notification-menu.show {
        position: fixed !important;
        top: 60px !important;
        right: .5rem !important;
        left: .5rem !important;
        width: auto;
        max-height: calc(100vh - 72px);
        margin: 0 !important;
        transform: none !important;
        display: flex;
        flex-direction: column;
    }

    .portal-notification-list {
        flex: 1 1 auto;
        max-height: none;
        -webkit-overflow-scrolling: touch;
    }

    .portal-notification-heading,
    .portal-notification-item,
    .portal-notification-extra {
        padding-right: .75rem;
        padding-left: .75rem;
    }

    .portal-notification-mark-read {
        min-height: 32px;
    }
}