:root {
    --portal-blue: #0879fa;
    --portal-blue-dark: #155be0;
    --portal-blue-soft: #edf4ff;
    --portal-bg: #f0f5fd;
    --portal-ink: #172037;
    --portal-muted: #6d7f9b;
    --portal-line: #dce5f1;
    --portal-white: #ffffff;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    scroll-behavior: smooth;
}

body.school-portal {
    min-height: 100vh;
    margin: 0;
    padding: 10px 10px 24px;
    color: var(--portal-ink);
    background:
        radial-gradient(circle at 14% 12%, rgba(95, 130, 229, .12), transparent 24%),
        radial-gradient(circle at 83% 16%, rgba(92, 160, 238, .09), transparent 23%),
        linear-gradient(145deg, #f5f8fd 0%, #eaf1fc 100%);
    font-family: "Manrope", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

button,
a {
    font: inherit;
    -webkit-tap-highlight-color: transparent;
}

.portal-skip-link {
    position: fixed;
    z-index: 100;
    top: 12px;
    left: 12px;
    padding: 10px 15px;
    color: var(--portal-white);
    background: var(--portal-blue-dark);
    border-radius: 9px;
    transform: translateY(-160%);
}

.portal-skip-link:focus {
    transform: translateY(0);
}

.portal-header {
    display: flex;
    width: min(100%, 1900px);
    min-height: 70px;
    margin: 0 auto;
    padding: 9px 24px;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    background: rgba(255, 255, 255, .92);
    border: 1px solid rgba(255, 255, 255, .9);
    border-radius: 20px;
    box-shadow: 0 20px 44px rgba(44, 67, 107, .11);
    backdrop-filter: blur(18px);
}

.portal-brand {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 12px;
    color: #66738a;
    text-decoration: none;
}

.portal-brand img {
    width: 236px;
    height: 68px;
    object-fit: contain;
    object-position: left center;
}

.portal-brand span {
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.portal-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.portal-user,
.portal-button {
    display: inline-flex;
    min-height: 34px;
    padding: 0 14px;
    align-items: center;
    justify-content: center;
    gap: 9px;
    color: var(--portal-ink);
    background: rgba(255, 255, 255, .9);
    border: 1px solid var(--portal-line);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
}

.portal-user {
    color: #6e7b91;
    background: #f8faff;
}

.portal-button {
    cursor: default;
}

.portal-button:disabled {
    opacity: .68;
    cursor: not-allowed;
}

.portal-button-primary {
    color: var(--portal-white);
    background: linear-gradient(135deg, #155be0, #087edf);
    border-color: transparent;
    box-shadow: 0 11px 24px rgba(61, 104, 213, .24);
}

.portal-button-icon {
    display: inline-block;
    letter-spacing: -1px;
    transform: rotate(-42deg);
}

.portal-main {
    width: min(calc(100% - 88px), 1192px);
    margin: 40px auto 0;
    padding: 28px;
    background: rgba(255, 255, 255, .82);
    border: 1px solid rgba(255, 255, 255, .92);
    border-radius: 32px;
    box-shadow: 0 30px 65px rgba(47, 68, 106, .13);
    backdrop-filter: blur(16px);
}

.portal-title {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.portal-grid {
    display: grid;
    max-width: 912px;
    margin: 0 auto;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.portal-card {
    position: relative;
    display: flex;
    min-height: 194px;
    padding: 18px;
    overflow: hidden;
    flex-direction: column;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, .98), rgba(248, 250, 254, .9));
    border: 1px solid var(--portal-line);
    border-radius: 20px;
    box-shadow: 0 17px 37px rgba(48, 70, 111, .09);
    transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}

.portal-card::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, #4b74ff, #b7cbff 72%, rgba(142, 185, 242, .08));
}

.portal-card:nth-child(6)::before {
    background: linear-gradient(90deg, #25b8ec, #a4d9fb 72%, rgba(142, 185, 242, .08));
}

.portal-card:hover {
    border-color: #cddcf1;
    box-shadow: 0 23px 45px rgba(48, 70, 111, .14);
    transform: translateY(-5px);
}

.portal-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.portal-icon {
    display: grid;
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    place-items: center;
    color: #4e74df;
    background: linear-gradient(145deg, #f1f7ff, #e5efff);
    border: 1px solid #cfdef4;
    border-radius: 15px;
    box-shadow: inset 0 0 18px rgba(77, 116, 222, .04);
    font-size: 18px;
    font-weight: 800;
}

.portal-code {
    padding: 6px 9px;
    color: #0864fb;
    background: #e9f2ff;
    border: 1px solid #d5e3fa;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 800;
}

.portal-card h2 {
    margin: 12px 0 0;
    color: #151d31;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: -.025em;
    line-height: 1.3;
}

.portal-card p {
    margin: auto 0 0;
    padding-top: 10px;
    color: var(--portal-muted);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.55;
}

@media (max-width: 1060px) {
    .portal-user {
        display: none;
    }

    .portal-main {
        width: min(100%, 760px);
    }

    .portal-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 660px) {
    body.school-portal {
        padding: 14px 14px 48px;
    }

    .portal-header {
        padding: 16px;
        align-items: flex-start;
        flex-direction: column;
        gap: 16px;
        border-radius: 22px;
    }

    .portal-brand {
        width: 100%;
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
    }

    .portal-brand img {
        width: min(100%, 236px);
        height: auto;
    }

    .portal-brand span {
        font-size: 11px;
    }

    .portal-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 8px;
    }

    .portal-button {
        min-height: 44px;
        padding-inline: 12px;
        font-size: 11px;
    }

    .portal-button-primary {
        order: -1;
    }

    .portal-main {
        margin-top: 24px;
        padding: 25px 16px;
        border-radius: 26px;
    }

    .portal-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .portal-card {
        min-height: 210px;
    }

    .portal-card h2 {
        font-size: 16px;
    }

    .portal-card p {
        font-size: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .portal-card {
        transition: none;
    }
}
