:root {
    --portal-ink: #17324d;
    --portal-muted: #6b7b8c;
    --portal-border: #e5ebf1;
    --portal-frame-border: #bccbd8;
    --portal-surface: #ffffff;
    --portal-background: #f5f8fb;
    --portal-blue: #2f6fae;
    --portal-teal: #238a8b;
    --portal-gold: #b17a22;
    --portal-green: #4d766f;
    --portal-purple: #72549b;
}

html {
    scroll-behavior: smooth;
}

#portal-content {
    scroll-margin-top: 1rem;
}

body.portal-page,
body.hold-transition.sidebar-mini {
    background: var(--portal-background);
}

.portal-header {
    min-height: 68px;
    border-bottom: 1px solid var(--portal-border);
    box-shadow: 0 2px 10px rgba(23, 50, 77, .05);
    padding: .55rem clamp(1rem, 3vw, 2.5rem);
}

.portal-brand {
    display: inline-flex;
    align-items: center;
    gap: .7rem;
    color: var(--portal-ink);
    line-height: 1.15;
}

.portal-brand:hover {
    color: var(--portal-blue);
    text-decoration: none;
}

.portal-brand-icon,
.portal-heading-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border-radius: 12px;
    color: #fff;
    background: linear-gradient(135deg, #2f6fae, #4d93c5);
}

.portal-brand-icon {
    width: 39px;
    height: 39px;
    font-size: 1.05rem;
}

.portal-brand strong,
.portal-brand small {
    display: block;
}

.portal-brand strong {
    font-size: 1rem;
    font-weight: 700;
}

.portal-brand small {
    margin-top: .15rem;
    color: var(--portal-muted);
    font-size: .75rem;
}

.portal-menu {
    padding: clamp(1.25rem, 3vw, 2.7rem) 0 0;
}

.portal-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    margin-bottom: 1.4rem;
}

.portal-eyebrow {
    margin: 0 0 .35rem;
    color: var(--portal-blue);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .12em;
}

.portal-heading h1 {
    margin: 0;
    color: var(--portal-ink);
    font-size: clamp(1.35rem, 2.3vw, 2rem);
    font-weight: 700;
}

.portal-heading p {
    margin: .35rem 0 0;
    color: var(--portal-muted);
    font-size: .95rem;
}

.portal-heading-icon {
    width: 58px;
    height: 58px;
    font-size: 1.5rem;
}

.portal-tabs {
    --portal-frame-accent: var(--portal-blue);
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: end;
    gap: .2rem;
    margin-bottom: 0;
    padding: .4rem .4rem 0;
    border: 1px solid var(--portal-frame-border);
    border-bottom: 0;
    border-left-color: var(--portal-frame-accent);
    border-radius: 11px 11px 0 0;
    background: linear-gradient(180deg, #f1f3f5 0%, #dfe4e9 100%);
    transition: border-color .18s ease;
}

.portal-tabs[data-active-portal-group="students"] {
    --portal-frame-accent: var(--portal-teal);
}

.portal-tabs[data-active-portal-group="management"] {
    --portal-frame-accent: var(--portal-gold);
}

.portal-tabs[data-active-portal-group="e-services"] {
    --portal-frame-accent: var(--portal-green);
}

.portal-tabs[data-active-portal-group="tutorials"] {
    --portal-frame-accent: var(--portal-purple);
}

.portal-tab {
    --portal-tab-accent: var(--portal-blue);
    --portal-tab-soft: #eaf3fb;
    --portal-tab-icon: #dcecf8;
    display: flex;
    align-items: center;
    min-width: 0;
    gap: .5rem;
    position: relative;
    z-index: 1;
    min-height: 44px;
    padding: .55rem .7rem;
    border: 1px solid #d2d7dc;
    border-bottom: 0;
    border-radius: 9px 9px 3px 3px;
    color: #4d5964;
    background: linear-gradient(180deg, #f8f9fa 0%, #e4e7ea 100%);
    text-align: left;
    cursor: pointer;
    transition: color .18s ease, background .18s ease, border-color .18s ease,
        box-shadow .18s ease, transform .18s ease;
}

.portal-tab:hover,
.portal-tab:focus-visible {
    color: var(--portal-tab-accent);
    background: linear-gradient(180deg, #ffffff 0%, var(--portal-tab-soft) 100%);
    box-shadow: 0 3px 8px rgba(23, 50, 77, .1);
    transform: translateY(-1px);
}

.portal-tab:focus-visible {
    outline: 3px solid rgba(47, 111, 174, .25);
    outline-offset: 2px;
}

.portal-tab.is-active {
    color: #fff;
    border-color: var(--portal-tab-accent);
    border-top-color: var(--portal-tab-accent);
    background: linear-gradient(180deg, var(--portal-tab-accent), rgba(23, 50, 77, .92));
    box-shadow: 0 -2px 9px rgba(23, 50, 77, .14);
    transform: translateY(-1px);
}

.portal-tab-blue {
    border-top: 3px solid var(--portal-blue);
}

.portal-tab-teal {
    --portal-tab-accent: var(--portal-teal);
    --portal-tab-soft: #e9f6f5;
    --portal-tab-icon: #d9efed;
    border-top: 3px solid var(--portal-teal);
}

.portal-tab-gold {
    --portal-tab-accent: var(--portal-gold);
    --portal-tab-soft: #faf3e5;
    --portal-tab-icon: #f6e6c6;
    border-top: 3px solid var(--portal-gold);
}

.portal-tab-green {
    --portal-tab-accent: var(--portal-green);
    --portal-tab-soft: #eaf3f0;
    --portal-tab-icon: #d9ebe5;
    border-top: 3px solid var(--portal-green);
}

.portal-tab-purple {
    --portal-tab-accent: var(--portal-purple);
    --portal-tab-soft: #f1ebf7;
    --portal-tab-icon: #e6daf1;
    border-top: 3px solid var(--portal-purple);
}

.portal-tab > i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
    border-radius: 9px;
    font-size: 1rem;
    transition: color .18s ease, background .18s ease,
        transform .22s cubic-bezier(.2, .8, .2, 1);
}

.portal-tab:hover > i,
.portal-tab:focus-visible > i,
.portal-tab.is-active > i {
    color: var(--portal-tab-accent);
    background: var(--portal-tab-icon);
    transform: translateY(-2px) scale(1.04);
}

.portal-tab.is-active > i {
    color: #fff;
    background: rgba(255, 255, 255, .18);
}

.portal-tab span {
    min-width: 0;
    overflow: hidden;
    font-size: .88rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.portal-tab small {
    margin-left: auto;
    color: var(--portal-muted);
    font-size: .72rem;
    white-space: nowrap;
}

.portal-tab.is-active small {
    color: rgba(255, 255, 255, .82);
}

.portal-group {
    --portal-group-accent: var(--portal-blue);
    --portal-group-hover: #edf5fa;
    --portal-group-active: #d6e7f3;
    --portal-group-icon: #e8f2f9;
    position: relative;
    z-index: 0;
    margin-bottom: 0;
    padding: .35rem .45rem .4rem;
    border: 1px solid var(--portal-group-accent);
    border-top: 0;
    border-radius: 0 0 10px 10px;
    background: linear-gradient(180deg, #e4e9ed 0%, #d9e0e6 100%);
    transition: border-color .18s ease;
}

.portal-group[hidden] {
    display: none;
}

.portal-group-teal {
    --portal-group-accent: var(--portal-teal);
    --portal-group-hover: #e9f6f5;
    --portal-group-active: #d2e9e6;
    --portal-group-icon: #e5f5f3;
}

.portal-group-gold {
    --portal-group-accent: var(--portal-gold);
    --portal-group-hover: #faf3e5;
    --portal-group-active: #f1dfbd;
    --portal-group-icon: #fff2da;
}

.portal-group-green {
    --portal-group-accent: var(--portal-green);
    --portal-group-hover: #eaf3f0;
    --portal-group-active: #d3e6e0;
    --portal-group-icon: #e5f2ee;
}

.portal-group-purple {
    --portal-group-accent: var(--portal-purple);
    --portal-group-hover: #f1ebf7;
    --portal-group-active: #e1d3ed;
    --portal-group-icon: #eee7f7;
}

.portal-menu-services {
    display: flex;
    align-items: center;
    gap: .25rem;
    overflow-x: auto;
    padding: 0;
    scrollbar-color: #c4d1cb transparent;
    scrollbar-width: thin;
}

.portal-service {
    display: flex;
    align-items: center;
    min-width: 145px;
    min-height: 39px;
    flex: 0 1 auto;
    gap: .5rem;
    position: relative;
    padding: .3rem .65rem;
    border: 1px solid transparent;
    border-radius: 7px;
    color: #40505d;
    background: rgba(255, 255, 255, .5);
    transition: color .18s ease, background .18s ease, border-color .18s ease,
        transform .18s ease;
}

.portal-service:hover,
.portal-service:focus {
    color: var(--portal-group-accent);
    text-decoration: none;
    background: var(--portal-group-hover);
    border-color: rgba(255, 255, 255, .7);
    transform: translateY(-1px);
}

.portal-service:focus-visible {
    outline: 3px solid rgba(47, 111, 174, .28);
    outline-offset: 2px;
}

.portal-service.is-active {
    color: #fff;
    background: linear-gradient(180deg, var(--portal-group-accent), rgba(23, 50, 77, .92));
    border-color: var(--portal-group-accent);
    box-shadow: 0 2px 6px rgba(23, 50, 77, .15);
}

.portal-service.is-active .portal-service-icon {
    color: #fff;
    background: rgba(255, 255, 255, .18);
    transform: translateY(-2px) scale(1.04);
}

.portal-service-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
    border-radius: 8px;
    color: var(--portal-group-accent);
    background: var(--portal-group-icon);
    transition: color .18s ease, background .18s ease,
        transform .22s cubic-bezier(.2, .8, .2, 1);
}

@media (prefers-reduced-motion: reduce) {
    .portal-tab,
    .portal-tab > i,
    .portal-service,
    .portal-service-icon {
        animation: none;
        transition: none;
    }

    .portal-tab:hover,
    .portal-tab:focus-visible,
    .portal-tab:hover > i,
    .portal-tab:focus-visible > i,
    .portal-tab.is-active > i,
    .portal-service:hover,
    .portal-service:focus,
    .portal-service.is-active .portal-service-icon {
        transform: none;
    }
}

.portal-service-copy {
    min-width: 0;
    flex: 1 1 auto;
}

.portal-service-copy strong {
    display: block;
}

.portal-service-copy strong {
    overflow: hidden;
    font-size: .8rem;
    font-weight: 700;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.portal-content.content {
    padding: 0;
}

.portal-content-shell {
    --portal-content-frame-accent: var(--portal-blue);
    margin-bottom: 1rem;
    border: 1px solid var(--portal-content-frame-accent);
    border-top: 0;
    border-radius: 0 0 14px 14px;
    background: var(--portal-surface);
    box-shadow: 0 8px 24px rgba(23, 50, 77, .055);
    transition: border-color .18s ease;
}

.portal-content-shell[data-portal-frame-group="students"] {
    --portal-content-frame-accent: var(--portal-teal);
}

.portal-content-shell[data-portal-frame-group="management"] {
    --portal-content-frame-accent: var(--portal-gold);
}

.portal-content-shell[data-portal-frame-group="e-services"] {
    --portal-content-frame-accent: var(--portal-green);
}

.portal-content-shell[data-portal-frame-group="tutorials"] {
    --portal-content-frame-accent: var(--portal-purple);
}

.portal-content-body {
    padding: 1rem;
}

.portal-header .nav-link {
    color: var(--portal-ink);
    white-space: nowrap;
}

.portal-header .nav-link:hover {
    color: var(--portal-blue);
}

.portal-user-menu {
    border-radius: 8px;
}

.portal-user-dropdown {
    min-width: 190px;
    margin-top: .35rem;
    padding: .4rem;
    border: 1px solid var(--portal-border);
    border-radius: 10px;
    box-shadow: 0 10px 24px rgba(23, 50, 77, .12);
}

.portal-user-dropdown .dropdown-item {
    border-radius: 7px;
    color: var(--portal-ink);
    font-size: .86rem;
}

.portal-user-dropdown .dropdown-item:hover,
.portal-user-dropdown .dropdown-item:focus {
    color: var(--portal-blue);
    background: #f0f7fc;
}

.content-wrapper {
    margin-left: 0 !important;
    background: var(--portal-background);
}

.portal-profile-summary {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    width: 100%;
    margin: 0;
    padding: .85rem clamp(.8rem, 3vw, 2.5rem);
    border: 1px solid #dbe8e5;
    border-width: 0 0 1px;
    border-radius: 0;
    background: linear-gradient(120deg, #ffffff, #f1f8f6);
    box-shadow: 0 7px 20px rgba(23, 50, 77, .06);
}

.portal-profile-main { display: flex; align-items: center; gap: .85rem; min-width: 260px; flex: 1 1 34%; }

.portal-profile-avatar,
.portal-profile-avatar img,
.portal-profile-avatar span {
    display: grid;
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    place-items: center;
    border-radius: 50%;
}

.portal-profile-avatar {
    overflow: hidden;
    color: #2f6d63;
    background: #dceee9;
    font-size: 1.25rem;
}

.portal-profile-avatar img { object-fit: cover; }
.portal-profile-copy { min-width: 0; flex: 1 1 auto; }
.portal-profile-label, .portal-profile-copy strong, .portal-profile-copy small { display: block; }
.portal-profile-label { color: #6a837e; font-size: .7rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.portal-profile-copy strong { overflow: hidden; color: #263b38; font-size: .95rem; text-overflow: ellipsis; white-space: nowrap; }
.portal-profile-copy small { overflow: hidden; color: #71817e; font-size: .76rem; text-overflow: ellipsis; white-space: nowrap; }
.portal-profile-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: stretch; gap: .5rem; flex: 1 1 45%; min-width: 360px; }
.portal-profile-stats > span { min-width: 72px; padding: .25rem .65rem; border-left: 1px solid #dbe8e5; text-align: center; }
.portal-profile-stats strong, .portal-profile-stats small { display: block; }
.portal-profile-stats strong { color: #2f6d63; font-size: 1.05rem; line-height: 1.1; }
.portal-profile-stats small { color: #71817e; font-size: .7rem; white-space: nowrap; }
.portal-profile-actions { display: flex; align-items: center; justify-content: flex-end; gap: .85rem; flex: 0 0 auto; }
.portal-profile-status { color: #52736b; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.portal-profile-status i { color: #38a169; font-size: .48rem; vertical-align: middle; }
.portal-profile-link { flex: 0 0 auto; color: #2f6d63; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.portal-profile-link:hover { color: #214f49; text-decoration: none; }

.main-footer {
    margin-left: 0 !important;
    border-top: 1px solid var(--portal-border);
    background: #fff;
}

@media (min-width: 992px) {
    .portal-tabs {
        border-bottom: 1px solid var(--portal-frame-accent);
    }

    .portal-tab.is-active {
        margin-bottom: -1px;
        border-bottom: 1px solid var(--portal-tab-accent);
    }
}

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

    .portal-service { flex-basis: 230px; }
}

@media (max-width: 575.98px) {
    .portal-profile-summary { align-items: flex-start; flex-wrap: wrap; gap: .65rem; padding: .7rem .65rem; }
    .portal-profile-main { min-width: 0; flex-basis: calc(100% - 52px); }
    .portal-profile-stats { order: 3; width: 100%; min-width: 0; flex-basis: 100%; grid-template-columns: repeat(3, minmax(0, 1fr)); justify-content: space-between; }
    .portal-profile-stats > span { min-width: 0; padding: .2rem .25rem; }
    .portal-profile-actions { margin-left: auto; }
    .portal-profile-status { display: none; }
    .portal-profile-link { padding: .35rem .45rem; border: 1px solid #cfe1dc; border-radius: 8px; font-size: 0; }
    .portal-profile-link i { margin: 0 !important; font-size: .85rem; }

    .portal-header {
        align-items: flex-start;
        padding-right: .65rem;
        padding-left: .65rem;
    }

    .portal-brand {
        min-width: 0;
    }

    .portal-brand small {
        display: none;
    }

    .portal-header .navbar-nav.ml-auto {
        align-items: flex-end;
    }

    .portal-header .nav-link {
        padding: .25rem 0 .25rem .55rem;
        font-size: .78rem;
    }

    .portal-heading-icon {
        display: none;
    }

    .portal-heading h1 {
        font-size: 1.3rem;
    }

    .portal-heading p {
        font-size: .84rem;
    }

    .portal-tabs {
        grid-template-columns: 1fr;
        gap: .45rem;
    }

    .portal-tab {
        min-height: 46px;
    }

    .portal-group {
        padding: .35rem .4rem .3rem;
    }

    .portal-content-shell {
        border-radius: 0 0 12px 12px;
    }

    .portal-service {
        min-width: 165px;
        min-height: 48px;
        flex-basis: 165px;
        padding: .4rem .55rem;
        border-right-color: #d9e3de;
    }

    .portal-content-body {
        padding: .7rem;
    }
}
