/* Portal v2 — Animated glassmorphism (rose theme) */
@view-transition {
    navigation: auto;
}

:root {
    color-scheme: light;
    --bg-base: #fdf2f4;
    --ink: #1a0f14;
    --ink-soft: #4a3a42;
    --ink-faint: #6b5560;
    --ink-muted: #5c4a55;
    --ink-on-dark: #fff5f7;
    --ink-on-dark-soft: #f5d0d9;
    --ink-on-dark-muted: #e8b4c0;
    --accent: #e11d48;
    --accent-deep: #9f1239;
    --accent-text: #be123c;
    --accent-light: #fb7185;
    --accent-secondary: #ec4899;
    --accent-glow: rgba(225, 29, 72, 0.42);
    --sidebar-bg: rgba(42, 10, 22, 0.9);
    --sidebar-stroke: rgba(255, 255, 255, 0.1);
    --glass: rgba(255, 255, 255, 0.2);
    --glass-strong: rgba(255, 255, 255, 0.82);
    --glass-soft: rgba(255, 255, 255, 0.45);
    --glass-stroke: rgba(255, 255, 255, 0.65);
    --glass-stroke-dim: rgba(255, 255, 255, 0.28);
    --glass-blur: 20px;
    --glass-saturate: 180%;
    --shadow-float: 0 30px 80px rgba(120, 35, 55, 0.12);
    --shadow-soft: 0 12px 40px rgba(120, 35, 55, 0.08);
    --shadow-card:
        inset 0 1px 0 rgba(255, 255, 255, 0.95),
        inset 0 -1px 0 rgba(55, 15, 28, 0.04),
        0 2px 4px rgba(55, 15, 28, 0.05),
        0 8px 16px rgba(55, 15, 28, 0.08),
        0 16px 32px rgba(120, 35, 55, 0.1),
        0 24px 40px rgba(120, 35, 55, 0.08);
    --shadow-card-hover:
        inset 0 1px 0 rgba(255, 255, 255, 1),
        inset 0 -2px 0 rgba(55, 15, 28, 0.05),
        0 6px 12px rgba(55, 15, 28, 0.08),
        0 16px 32px rgba(120, 35, 55, 0.14),
        0 28px 56px rgba(120, 35, 55, 0.16),
        0 40px 72px rgba(225, 29, 72, 0.2);
    --highlight: inset 0 1px 0 rgba(255, 255, 255, 0.8);
    --radius-xl: 30px;
    --radius-lg: 18px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --radius-pill: 999px;
    --nav-touch: 44px;
    --icon-stroke: 1.85;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-liquid: cubic-bezier(0.22, 1.2, 0.36, 1);
}

html {
    background-color: var(--bg-base);
}

html,
body,
*,
button,
input,
select,
textarea,
option {
    font-family: "Sarabun", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
}

*::before,
*::after {
    font-family: inherit;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    color: var(--ink);
    background-color: var(--bg-base);
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}

.ambient {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.ambient::before,
.ambient::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.55;
    animation: ambient-drift 24s var(--ease) infinite alternate;
    z-index: 1;
}

.ambient::before {
    width: min(55vw, 540px);
    height: min(55vw, 540px);
    top: -15%;
    left: -10%;
    background: radial-gradient(circle, rgba(225, 29, 72, 0.32), transparent 70%);
}

.ambient::after {
    width: min(50vw, 480px);
    height: min(50vw, 480px);
    right: -8%;
    bottom: -12%;
    background: radial-gradient(circle, rgba(244, 63, 94, 0.28), transparent 72%);
    animation-duration: 30s;
    animation-delay: -6s;
}

@keyframes ambient-drift {
    from { transform: translate3d(0, 0, 0) scale(1); }
    to { transform: translate3d(3%, -4%, 0) scale(1.06); }
}

.glass,
.ios-panel,
.ad-card,
.ad-metric,
.status-box,
.overview-stat,
.app-item,
.branding-preview-card {
    background: var(--glass-strong);
    backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
    border: 1px solid var(--glass-stroke);
    box-shadow: var(--shadow-soft), var(--highlight);
}

.portal-root {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
}

.school-portal {
    position: relative;
    display: grid;
    grid-template-columns: 1fr;
    min-height: 100dvh;
    min-height: 100vh;
    border-radius: 0;
    overflow: hidden;
    isolation: isolate;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.school-portal::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image: var(--portal-bg, url("../../images/school-bg.jpg"));
    background-size: cover;
    background-position: center top;
    background-repeat: no-repeat;
    transform: scale(1.03);
    filter: hue-rotate(58deg) saturate(1.22) brightness(1.06) contrast(0.96);
}

.school-portal::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        linear-gradient(180deg, rgba(255, 251, 252, 0.74) 0%, rgba(253, 242, 244, 0.52) 40%, rgba(252, 231, 236, 0.45) 100%),
        radial-gradient(ellipse 90% 70% at 50% 0%, rgba(255, 228, 235, 0.6), transparent 58%),
        radial-gradient(ellipse 70% 50% at 100% 100%, rgba(251, 113, 133, 0.16), transparent 55%);
}

.portal-sidebar,
.portal-main,
.mobile-bottom-nav {
    position: relative;
    z-index: 2;
}

/* â”€â”€ Sidebar â”€â”€ */
.portal-sidebar {
    display: none;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    padding: 18px 12px 14px;
    color: var(--ink-on-dark);
    background:
        linear-gradient(180deg, rgba(42, 10, 22, 0.94) 0%, rgba(58, 14, 30, 0.9) 48%, rgba(32, 8, 18, 0.96) 100%);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border-right: 1px solid var(--sidebar-stroke);
    overflow: hidden;
}

.portal-sidebar__scroll {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.portal-sidebar__scroll::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.portal-sidebar::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.sidebar-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
    flex-shrink: 0;
    text-align: center;
}

.sidebar-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-width: 0;
    padding: 4px 6px 2px;
    flex-shrink: 0;
}

.sidebar-logo-shell {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.28);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.35),
        0 10px 28px rgba(225, 29, 72, 0.28);
    animation: sidebar-logo-float 4.5s var(--ease) infinite alternate;
}

.sidebar-logo-shell::before {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: inherit;
    background: conic-gradient(
        from 0deg,
        rgba(225, 29, 72, 0.9),
        rgba(236, 72, 153, 0.35),
        rgba(251, 113, 133, 0.85),
        rgba(225, 29, 72, 0.9)
    );
    z-index: 0;
    animation: sidebar-ring-spin 8s linear infinite;
    opacity: 0.85;
}

.sidebar-logo-shell::after {
    content: "";
    position: absolute;
    inset: 2px;
    border-radius: inherit;
    background: linear-gradient(180deg, rgba(58, 14, 30, 0.96), rgba(32, 8, 18, 0.98));
    z-index: 0;
}

.sidebar-logo {
    position: relative;
    z-index: 1;
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 50%;
    flex-shrink: 0;
}

.sidebar-brand-text {
    margin: 0;
    min-width: 0;
    width: 100%;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: baseline;
    justify-content: center;
    gap: 0.35em;
}

.sidebar-brand-text__line {
    display: inline;
    font-size: 0.86rem;
    line-height: 1.2;
    font-weight: 800;
    color: var(--ink-on-dark);
    letter-spacing: -0.01em;
    text-transform: lowercase;
}

.sidebar-brand-text__line--accent {
    font-weight: 700;
    background: linear-gradient(90deg, #fda4af, #fb7185, #ffe4e6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: #fecdd3;
}

.sidebar-clock-card {
    position: relative;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    border-radius: 16px;
    padding: 14px 12px 12px;
    text-align: center;
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.12), rgba(225, 29, 72, 0.08));
    border: 1px solid rgba(251, 113, 133, 0.42);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.22),
        0 10px 30px rgba(159, 18, 57, 0.28);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    overflow: hidden;
    flex-shrink: 0;
    isolation: isolate;
    animation: sidebar-clock-breathe 3.8s var(--ease) infinite alternate;
}

.sidebar-clock-card__glow {
    position: absolute;
    inset: -40%;
    background: radial-gradient(circle, rgba(251, 113, 133, 0.35), transparent 62%);
    opacity: 0.55;
    animation: sidebar-glow-pulse 3.8s var(--ease) infinite alternate;
    pointer-events: none;
    z-index: 0;
}

.sidebar-clock-card::after {
    content: "";
    position: absolute;
    top: -120%;
    left: -60%;
    width: 55%;
    height: 320%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.22), transparent);
    transform: rotate(18deg);
    animation: sidebar-clock-shimmer 5.5s var(--ease) infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes sidebar-logo-float {
    from { transform: translateY(0); }
    to { transform: translateY(-4px); }
}

@keyframes sidebar-ring-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes sidebar-clock-breathe {
    from {
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.22),
            0 8px 24px rgba(159, 18, 57, 0.22);
        border-color: rgba(251, 113, 133, 0.35);
    }
    to {
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.3),
            0 14px 36px rgba(225, 29, 72, 0.38);
        border-color: rgba(196, 181, 253, 0.62);
    }
}

@keyframes sidebar-glow-pulse {
    from { opacity: 0.35; transform: scale(0.96); }
    to { opacity: 0.75; transform: scale(1.04); }
}

@keyframes sidebar-clock-shimmer {
    0%, 72% { left: -70%; opacity: 0; }
    78% { opacity: 1; }
    100% { left: 130%; opacity: 0; }
}

.sidebar-time,
.portal-sidebar [data-live-clock] {
    position: relative;
    z-index: 1;
    margin: 0;
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
    color: var(--ink-on-dark);
    text-shadow: 0 0 22px rgba(251, 113, 133, 0.35);
}

.sidebar-date {
    position: relative;
    z-index: 1;
    margin: 4px 0 0;
    font-size: 0.7rem;
    line-height: 1.4;
    color: var(--ink-on-dark-soft);
    font-weight: 600;
    overflow-wrap: anywhere;
}

.sidebar-menu-heading {
    position: relative;
    z-index: 2;
    margin: 8px 0 4px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-align: center;
    color: var(--ink-on-dark-muted);
}

.sidebar-menu {
    position: relative;
    display: grid;
    gap: 3px;
    margin-top: 2px;
    isolation: isolate;
    min-width: 0;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-liquid-blob {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 0;
    width: var(--sidebar-blob-w, 100%);
    height: var(--sidebar-blob-h, 44px);
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(225, 29, 72, 0.85), rgba(236, 72, 153, 0.75));
    box-shadow:
        0 0 24px var(--accent-glow),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
    pointer-events: none;
    transform: translateY(var(--sidebar-blob-y, 0px));
    transition:
        transform 0.5s var(--ease-liquid),
        height 0.5s var(--ease-liquid),
        width 0.5s var(--ease-liquid);
}

.sidebar-menu.no-blob-anim .sidebar-liquid-blob {
    transition: none;
}

.sidebar-menu.is-liquid-moving .sidebar-liquid-blob {
    filter: blur(0.2px);
    transform: translateY(var(--sidebar-blob-y, 0px)) scaleX(1.02) scaleY(0.94);
}

.sidebar-menu-item {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    border-radius: 12px;
    padding: 9px 10px;
    color: var(--ink-on-dark-soft);
    text-decoration: none;
    border: 1px solid transparent;
    background: transparent;
    min-width: 0;
    transition:
        color 0.28s var(--ease),
        transform 0.32s var(--ease-liquid),
        background 0.28s ease,
        border-color 0.28s ease,
        box-shadow 0.32s ease;
}

.sidebar-menu-item:not(.is-active):hover {
    color: var(--ink-on-dark);
    transform: translateX(3px);
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 18px rgba(225, 29, 72, 0.12);
}

.sidebar-menu-item:not(.is-active):hover .sidebar-menu-icon {
    transform: scale(1.08);
}

.sidebar-menu-item.is-active {
    color: var(--ink-on-dark);
    font-weight: 700;
}

.sidebar-menu-item.is-featured.is-active .sidebar-menu-icon::after {
    content: "\2605";
    position: absolute;
    top: -6px;
    right: -8px;
    font-size: 0.65rem;
    color: #fbbf24;
    text-shadow: 0 0 8px rgba(251, 191, 36, 0.8);
}

.sidebar-menu-icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.32s var(--ease-liquid);
}

.sidebar-menu-icon .portal-nav-icon-svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
}

.sidebar-menu-label {
    min-width: 0;
    font-size: 0.74rem;
    font-weight: 600;
    line-height: 1.28;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
}

.sidebar-menu-badge {
    font-size: 0.62rem;
    font-weight: 800;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: var(--radius-pill);
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.96);
    border: 0;
    color: var(--accent-text);
    flex-shrink: 0;
}

.sidebar-menu-item.is-active .sidebar-menu-badge {
    background: linear-gradient(135deg, #9f1239, #db2777);
    color: var(--ink-on-dark);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid var(--sidebar-stroke);
    flex-shrink: 0;
    min-width: 0;
}

.sidebar-admin {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-height: 42px;
    padding: 0 12px;
    border-radius: 12px;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--ink-on-dark);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.24);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition:
        background 0.28s ease,
        transform 0.32s var(--ease-liquid),
        border-color 0.28s ease,
        box-shadow 0.32s ease;
    overflow: hidden;
}

.sidebar-admin:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.32);
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(225, 29, 72, 0.18);
}

.sidebar-admin span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-admin .portal-nav-icon-svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
}

/* â”€â”€ Mobile bottom nav â”€â”€ */
.mobile-bottom-nav {
    position: fixed;
    left: 50%;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 90;
    width: min(calc(100% - 20px), 520px);
    transform: translateX(-50%);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.65);
    box-shadow: 0 16px 40px rgba(120, 35, 55, 0.18), var(--highlight);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    padding: 5px;
    display: flex;
    align-items: stretch;
    isolation: isolate;
}

.liquid-tab-blob {
    position: absolute;
    top: 50%;
    left: 0;
    z-index: 0;
    width: var(--blob-size, 50px);
    height: var(--blob-size, 50px);
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(225, 29, 72, 0.92), rgba(236, 72, 153, 0.82));
    box-shadow: 0 4px 20px var(--accent-glow), var(--highlight);
    pointer-events: none;
    transform: translate(var(--blob-x, 0px), -50%);
    transition: transform 0.48s var(--ease-liquid), width 0.48s var(--ease-liquid), height 0.48s var(--ease-liquid);
}

.mobile-bottom-nav.is-liquid-moving .liquid-tab-blob {
    transform: translate(var(--blob-x, 0px), -50%) scale(1.08);
}

.mobile-bottom-nav.no-blob-anim .liquid-tab-blob {
    transition: none;
}

.mobile-bottom-nav-item {
    position: relative;
    z-index: 1;
    flex: 1 1 0;
    min-width: 0;
    min-height: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5px 2px;
    border-radius: 18px;
    color: var(--ink-muted);
    text-decoration: none;
    transition: color 0.28s ease;
}

.mobile-bottom-nav-item:hover {
    color: var(--ink);
}

.mobile-bottom-nav-item.is-active {
    color: #fff;
}

.mobile-bottom-nav-item__inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    transform: scale(0.9);
    transform-origin: center center;
    transition: transform 0.38s var(--ease-liquid);
}

.mobile-bottom-nav-item.is-active .mobile-bottom-nav-item__inner {
    transform: scale(1.14);
}

.mobile-bottom-nav-item__icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-bottom-nav-item.is-active .mobile-bottom-nav-item__icon {
    transform: none;
}

.mobile-bottom-nav-item .portal-nav-icon-svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

.mobile-bottom-nav-item__label {
    font-size: 0.58rem;
    font-weight: 700;
    line-height: 1.1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.portal-nav-icon-svg,
.mobile-nav-icon-svg {
    flex-shrink: 0;
    stroke: currentColor;
    stroke-width: var(--icon-stroke);
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

/* â”€â”€ Main area â”€â”€ */
.portal-main {
    padding: 18px 20px calc(96px + env(safe-area-inset-bottom));
    background: transparent;
    overflow: auto;
}

.portal-hero {
    position: relative;
    margin-bottom: 18px;
    padding: 0 0 8px;
    overflow: hidden;
    min-height: 120px;
}

.portal-hero::after {
    content: "";
    position: absolute;
    right: -4%;
    top: -18%;
    width: min(56%, 520px);
    height: 140%;
    background-image: var(--hero-image, var(--portal-bg));
    background-size: cover;
    background-repeat: no-repeat;
    background-position: right top;
    opacity: 0.5;
    filter: hue-rotate(58deg) saturate(1.2) brightness(1.05);
    pointer-events: none;
    mask-image: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, 0.12) 22%, #000 52%);
    -webkit-mask-image: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, 0.12) 22%, #000 52%);
}

.portal-hero__topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.portal-hero__datetime {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-text);
    font-variant-numeric: tabular-nums;
}

.portal-hero__datetime-sep {
    margin: 0 4px;
    color: var(--ink-muted);
    opacity: 1;
}

.portal-notify {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 0 12px;
    border-radius: var(--radius-pill);
    border: 1px solid rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--accent-text);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow-soft), var(--highlight);
    transition: transform 0.2s var(--ease), box-shadow 0.2s ease;
}

.portal-notify svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.portal-notify:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(225, 29, 72, 0.15), var(--highlight);
}

.portal-hero__welcome {
    position: relative;
    z-index: 1;
    max-width: min(68%, 560px);
}

.portal-hero__center {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
}

.portal-hero__logo-shell {
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.75);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.85),
        0 10px 28px rgba(225, 29, 72, 0.2);
}

.portal-hero__logo-shell::before {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: inherit;
    background: conic-gradient(
        from 0deg,
        rgba(225, 29, 72, 0.85),
        rgba(236, 72, 153, 0.3),
        rgba(251, 113, 133, 0.8),
        rgba(225, 29, 72, 0.85)
    );
    animation: sidebar-ring-spin 9s linear infinite;
    z-index: 0;
}

.portal-hero__logo-shell::after {
    content: "";
    position: absolute;
    inset: 2px;
    border-radius: inherit;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(245, 247, 255, 0.9));
    z-index: 0;
}

.portal-hero__logo {
    position: relative;
    z-index: 1;
    width: 52px;
    height: 52px;
    object-fit: contain;
    border-radius: 50%;
}

.portal-hero__center .portal-hero__welcome {
    max-width: 100%;
}

.portal-hero__kicker {
    margin: 0;
    font-size: clamp(1.5rem, 4.5vw, 2.15rem);
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.portal-hero__title {
    margin: 4px 0 0;
    font-size: clamp(1.55rem, 4.8vw, 2.35rem);
    line-height: 1.12;
    font-weight: 800;
    letter-spacing: -0.03em;
    display: flex;
    flex-wrap: nowrap;
    align-items: baseline;
    justify-content: center;
    gap: 0.28em;
    white-space: nowrap;
}

.portal-hero__title-brand {
    color: var(--ink);
}

.portal-hero__title-accent {
    display: inline;
    margin-left: 0;
    color: var(--accent-text);
    background: linear-gradient(135deg, #be123c 0%, #db2777 48%, #9f1239 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* â”€â”€ Content card â”€â”€ */
.portal-content-card {
    border-radius: var(--radius-xl);
    padding: 22px 22px 24px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(24px) saturate(170%);
    -webkit-backdrop-filter: blur(24px) saturate(170%);
    box-shadow: var(--shadow-float), var(--highlight);
    overflow: visible;
}

.department-stage {
    position: relative;
    overflow-x: clip;
    overflow-y: visible;
    min-height: 120px;
    padding: 10px 8px 28px;
}

.department-stage.is-transitioning {
    display: grid;
    overflow: hidden;
}

.department-stage.is-transitioning > .department-panel.is-active,
.department-stage.is-transitioning > .department-panel.is-leaving {
    grid-area: 1 / 1;
    position: relative;
    width: 100%;
    min-width: 0;
    align-self: start;
}

.department-stage.is-transitioning > .department-panel.is-leaving {
    z-index: 1;
}

.department-stage.is-transitioning > .department-panel.is-active {
    z-index: 2;
}

.department-panel {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: 0;
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.department-panel.is-active {
    position: relative;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    z-index: 1;
}

.department-panel.is-leaving {
    position: absolute;
    opacity: 1;
    visibility: visible;
    z-index: 1;
    pointer-events: none;
}

.department-panel.enter-rtl { animation: portal-enter-rtl 0.34s var(--ease) both; }
.department-panel.exit-ltr { animation: portal-exit-ltr 0.34s var(--ease) both; }
.department-panel.enter-ltr { animation: portal-enter-ltr 0.34s var(--ease) both; }
.department-panel.exit-rtl { animation: portal-exit-rtl 0.34s var(--ease) both; }

@keyframes portal-enter-rtl {
    from { transform: translate3d(100%, 0, 0); }
    to { transform: translate3d(0, 0, 0); }
}
@keyframes portal-exit-ltr {
    from { transform: translate3d(0, 0, 0); }
    to { transform: translate3d(-100%, 0, 0); }
}
@keyframes portal-enter-ltr {
    from { transform: translate3d(-100%, 0, 0); }
    to { transform: translate3d(0, 0, 0); }
}
@keyframes portal-exit-rtl {
    from { transform: translate3d(0, 0, 0); }
    to { transform: translate3d(100%, 0, 0); }
}

.school-portal.is-switching-groups .app-card,
.school-portal.is-switching-groups .app-card::before,
.school-portal.is-switching-groups .app-card::after {
    animation: none !important;
    transition: none !important;
}

.school-portal.is-switching-groups .portal-content-card {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.panel-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.panel-toolbar__lead {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.panel-toolbar__icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, rgba(225, 29, 72, 0.15), rgba(236, 72, 153, 0.1));
    border: 1px solid rgba(225, 29, 72, 0.2);
    color: var(--accent-text);
    flex-shrink: 0;
}

.panel-toolbar__icon .portal-nav-icon-svg {
    width: 22px;
    height: 22px;
}

.panel-toolbar__title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.panel-toolbar__meta {
    margin: 2px 0 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink-muted);
}

.view-toggle {
    display: inline-flex;
    padding: 3px;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.6);
    gap: 2px;
}

.view-toggle__btn {
    width: 36px;
    height: 32px;
    border: 0;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--ink-muted);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background 0.2s ease, color 0.2s ease;
}

.view-toggle__btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.view-toggle__btn.is-active {
    background: linear-gradient(135deg, var(--accent), #ec4899);
    color: #fff;
    box-shadow: 0 4px 12px var(--accent-glow);
}

/* App cards */
.app-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-items: start;
    padding: 6px 4px 12px;
}

.app-grid.is-list-view {
    grid-template-columns: 1fr;
}

.app-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    align-self: start;
    text-align: center;
    gap: 6px;
    padding: 12px 8px 10px;
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, #ffffff 0%, #f8f9fc 100%);
    border: 1px solid rgba(255, 255, 255, 0.95);
    border-bottom-color: rgba(203, 213, 225, 0.75);
    box-shadow: var(--shadow-card);
    text-decoration: none;
    color: inherit;
    min-width: 0;
    height: auto;
    overflow: visible;
    isolation: isolate;
    transform: translateY(0) translateZ(0);
    transition:
        transform 0.38s var(--ease-liquid),
        box-shadow 0.38s ease,
        border-color 0.38s ease;
}

.app-card::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(145deg, rgba(225, 29, 72, 0.14) 0%, rgba(236, 72, 153, 0.04) 42%, transparent 72%);
    opacity: 0;
    transition: opacity 0.38s ease;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.app-card::after {
    content: "";
    position: absolute;
    top: 0;
    left: -120%;
    width: 55%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
    transform: skewX(-18deg);
    opacity: 0;
    transition: left 0.55s var(--ease), opacity 0.3s ease;
    pointer-events: none;
    z-index: 0;
}

@keyframes card-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.app-card:hover,
.app-card:focus-visible {
    transform: translateY(-10px) scale(1.03);
    border-color: rgba(255, 255, 255, 0.98);
    border-bottom-color: rgba(225, 29, 72, 0.22);
    box-shadow: var(--shadow-card-hover);
}

.app-card:hover::before,
.app-card:focus-visible::before {
    opacity: 1;
}

.app-card:hover::after,
.app-card:focus-visible::after {
    left: 140%;
    opacity: 1;
}

.app-card > * {
    position: relative;
    z-index: 1;
}

.app-card__icon-wrap {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
    border: 1px solid rgba(255, 255, 255, 0.95);
    border-bottom-color: rgba(203, 213, 225, 0.8);
    flex-shrink: 0;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.9),
        0 4px 10px rgba(55, 15, 28, 0.1),
        0 8px 18px rgba(120, 35, 55, 0.08);
    transition:
        transform 0.38s var(--ease-liquid),
        box-shadow 0.38s ease,
        border-color 0.38s ease;
}

.app-card:hover .app-card__icon-wrap,
.app-card:focus-visible .app-card__icon-wrap {
    transform: translateY(-3px) scale(1.1);
    border-bottom-color: rgba(225, 29, 72, 0.25);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 1),
        0 8px 16px rgba(55, 15, 28, 0.12),
        0 14px 28px rgba(225, 29, 72, 0.2);
}

.app-card__icon {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 6px;
}

.app-card__fallback {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--accent-text);
    background: linear-gradient(160deg, #ffe4e6, #fecdd3);
}

.app-card__fallback[hidden] {
    display: none;
}

.app-card__name {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--ink);
    line-height: 1.28;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    width: 100%;
    min-height: 2.56em;
    transition: color 0.3s ease;
}

.app-card:hover .app-card__name,
.app-card:focus-visible .app-card__name {
    color: var(--accent-text);
}

.app-card__url {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--ink-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    line-height: 1.2;
}

.app-card__action {
    margin-top: 2px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: linear-gradient(180deg, #f43f5e 0%, #ec4899 55%, #9f1239 100%);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.35);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.35),
        0 4px 10px rgba(159, 18, 57, 0.35),
        0 8px 18px rgba(225, 29, 72, 0.28);
    flex-shrink: 0;
    transition:
        transform 0.38s var(--ease-liquid),
        box-shadow 0.38s ease,
        background 0.38s ease;
}

.app-card:hover .app-card__action,
.app-card:focus-visible .app-card__action {
    transform: scale(1.14);
    background: linear-gradient(180deg, #fb7185 0%, #e11d48 55%, #be185d 100%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.45),
        0 6px 14px rgba(159, 18, 57, 0.4),
        0 12px 28px rgba(225, 29, 72, 0.45);
}

.app-card__action svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 2.5;
    fill: none;
    transition: transform 0.38s var(--ease);
}

.app-card:hover .app-card__action svg,
.app-card:focus-visible .app-card__action svg {
    transform: translateX(2px);
}

.app-grid.is-list-view .app-card {
    flex-direction: row;
    text-align: left;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
}

.app-grid.is-list-view .app-card__icon-wrap {
    width: 48px;
    height: 48px;
}

.app-grid.is-list-view .app-card__name,
.app-grid.is-list-view .app-card__url {
    text-align: left;
}

.app-grid.is-list-view .app-card__action {
    margin-top: 0;
    margin-left: auto;
    flex-shrink: 0;
}

/* â”€â”€ Quote footer â”€â”€ */
.portal-quote-footer {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid rgba(225, 29, 72, 0.12);
    text-align: center;
}

.portal-quote {
    margin: 0;
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.55;
    color: var(--ink-soft);
    position: relative;
    display: inline-block;
    max-width: 520px;
}

.portal-quote__mark {
    color: var(--accent-text);
    font-size: 1.4rem;
    font-weight: 800;
    line-height: 0;
    vertical-align: -0.15em;
}

.portal-quote__mark--end {
    margin-left: 2px;
}

.portal-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 14px;
}

.portal-dot {
    width: 8px;
    height: 8px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(225, 29, 72, 0.25);
    cursor: pointer;
    transition: transform 0.25s var(--ease), background 0.25s ease, width 0.25s ease;
}

.portal-dot.is-active {
    width: 24px;
    border-radius: var(--radius-pill);
    background: linear-gradient(90deg, var(--accent), #ec4899);
    box-shadow: 0 2px 10px var(--accent-glow);
}

.portal-dot:hover:not(.is-active) {
    background: rgba(225, 29, 72, 0.45);
    transform: scale(1.15);
}

/* â”€â”€ Shared utilities â”€â”€ */
.notice-box,
.flash-alert,
.empty-state,
.department-empty,
.empty-box {
    border: 1px solid var(--glass-stroke);
    background: rgba(255, 255, 255, 0.78);
    color: var(--ink);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    font-size: 0.92rem;
    font-weight: 600;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.notice-box,
.flash-stack { margin-bottom: 12px; }
.flash-stack { display: grid; gap: 8px; }
.flash-alert.success { background: rgba(220, 252, 231, 0.8); color: #0f7641; }
.flash-alert.error { background: rgba(255, 228, 230, 0.85); color: #be123c; }

.admin-content { min-width: 0; }
.ios-panel { border-radius: var(--radius-xl); }

.glass-field {
    width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-stroke);
    background: rgba(255, 255, 255, 0.55);
    padding: 12px 14px;
    font-size: 1rem;
    color: var(--ink);
    outline: none;
    box-shadow: var(--highlight);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.glass-field:focus {
    border-color: rgba(225, 29, 72, 0.55);
    box-shadow: 0 0 0 4px rgba(225, 29, 72, 0.14), var(--highlight);
}

.glass-submit,
.glass-submit-secondary {
    appearance: none;
    width: 100%;
    min-height: 46px;
    border-radius: var(--radius-md);
    font-weight: 700;
    cursor: pointer;
}

.glass-submit {
    border: 1px solid rgba(255, 255, 255, 0.32);
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));
    box-shadow: 0 10px 24px var(--accent-glow), var(--highlight);
}

.glass-submit-secondary {
    border: 1px solid var(--glass-stroke);
    background: rgba(255, 255, 255, 0.42);
    color: var(--ink);
}

.btn,
.portal-action-link,
.portal-action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 14px;
    border-radius: 14px;
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.22s var(--ease), filter 0.22s ease;
}

.btn.primary,
.portal-action-link,
.portal-action-button {
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));
    border: 1px solid rgba(255, 255, 255, 0.32);
    box-shadow: 0 10px 22px var(--accent-glow), var(--highlight);
}

.btn {
    color: var(--ink);
    background: rgba(255, 255, 255, 0.46);
    border: 1px solid var(--glass-stroke);
}

.btn.warn {
    color: #7c4a00;
    background: linear-gradient(180deg, rgba(255, 243, 199, 0.9), rgba(254, 215, 170, 0.85));
}

.btn.danger {
    color: #fff;
    background: linear-gradient(180deg, #ef4444, #dc2626);
    border: 0;
}

body.admin-login-modal-open { overflow: hidden; }
body.admin-login-modal-open .portal-root { visibility: hidden; pointer-events: none; }

.admin-login-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 1.25rem 1rem 2rem;
    overflow-y: auto;
}

.admin-login-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(42, 10, 22, 0.45);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
}

.admin-login-modal__inner {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 28rem;
    margin: auto;
}

.admin-login-modal__close {
    position: absolute;
    top: 0.7rem;
    right: 0.7rem;
    z-index: 2;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--glass-stroke);
    background: rgba(255, 255, 255, 0.72);
    color: var(--accent-deep);
    font-size: 1.25rem;
    text-decoration: none;
    display: grid;
    place-items: center;
}

/* â”€â”€ Responsive â”€â”€ */
@media (min-width: 480px) {
    .app-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .mobile-bottom-nav-item__label { font-size: 0.62rem; }
}

@media (min-width: 640px) {
    .app-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
    .portal-main { padding: 18px 20px calc(100px + env(safe-area-inset-bottom)); }
    .portal-content-card { padding: 22px 20px 24px; }
}

@media (min-width: 768px) {
    .portal-hero__welcome { max-width: min(62%, 520px); }
}

@media (min-width: 900px) {
    .app-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

@media (min-width: 1061px) {
    .school-portal {
        grid-template-columns: 276px minmax(0, 1fr);
        min-height: 100vh;
        min-height: 100dvh;
    }

    .portal-sidebar {
        display: flex;
        width: 276px;
        max-width: 276px;
    }
    .portal-main { padding: 26px 34px 30px; }
    .mobile-bottom-nav { display: none; }
    .portal-notify span { display: inline; }
    .portal-content-card { padding: 26px 28px 28px; }
    .app-grid {
        grid-template-columns: repeat(6, minmax(108px, 1fr));
        gap: 12px;
    }

    .portal-hero__logo-shell {
        display: none;
    }

    .portal-hero__center {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
        gap: 4px;
    }

    .portal-hero__title {
        justify-content: flex-start;
    }

    .portal-hero__center .portal-hero__welcome {
        max-width: min(68%, 560px);
    }
}

@media (max-width: 1060px) {
    body:has(.school-portal) {
        overflow: hidden;
        height: 100dvh;
        height: 100vh;
    }

    .portal-root {
        height: 100dvh;
        height: 100vh;
        overflow: hidden;
    }

    .school-portal {
        display: flex;
        flex-direction: column;
        height: 100dvh;
        height: 100vh;
        max-height: 100dvh;
        max-height: 100vh;
        overflow: hidden;
    }

    .portal-main {
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        padding: 8px 10px calc(62px + env(safe-area-inset-bottom));
        touch-action: pan-y;
    }

    .portal-hero {
        min-height: 0;
        margin-bottom: 8px;
        padding: 8px 10px 12px;
        flex-shrink: 0;
        border-radius: 18px;
        text-align: center;
        background:
            linear-gradient(165deg, rgba(255, 255, 255, 0.82) 0%, rgba(255, 241, 245, 0.72) 55%, rgba(254, 226, 232, 0.65) 100%);
        border: 1px solid rgba(255, 255, 255, 0.85);
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.9),
            0 10px 28px rgba(225, 29, 72, 0.12);
    }

    .portal-hero::after {
        display: none;
    }

    .school-portal::before {
        background-position: center 10%;
        filter: hue-rotate(58deg) saturate(1.18) brightness(1.08) contrast(0.94);
    }

    .portal-hero__topbar {
        margin-bottom: 8px;
    }

    .portal-hero__datetime {
        font-size: 0.68rem;
    }

    .portal-hero__center {
        gap: 8px;
    }

    .portal-hero__logo-shell {
        width: 64px;
        height: 64px;
        animation: sidebar-logo-float 4.5s var(--ease) infinite alternate;
    }

    .portal-hero__logo {
        width: 46px;
        height: 46px;
    }

    .portal-hero__welcome {
        max-width: 100%;
    }

    .portal-hero__kicker {
        font-size: 1.18rem;
        line-height: 1.15;
        font-weight: 800;
    }

    .portal-hero__title {
        font-size: 1.22rem;
        margin-top: 2px;
        line-height: 1.15;
        justify-content: center;
    }

    .portal-hero__title-accent {
        display: inline;
        margin-left: 0;
        margin-top: 0;
    }

    .portal-notify span { display: none; }

    .portal-notify {
        min-height: 28px;
        min-width: 28px;
        padding: 0 7px;
        justify-content: center;
    }

    .portal-notify svg {
        width: 15px;
        height: 15px;
    }

    .portal-content-card {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        padding: 8px 8px 6px;
        border-radius: 16px;
        overflow: hidden;
    }

    .department-stage {
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
        padding: 2px 0 2px;
    }

    .department-stage.is-transitioning > .department-panel.is-active,
    .department-stage.is-transitioning > .department-panel.is-leaving {
        display: flex;
        flex-direction: column;
        height: 100%;
        min-height: 0;
    }

    .department-panel {
        display: flex;
        flex-direction: column;
        height: 100%;
        min-height: 0;
    }

    .department-panel.is-active {
        position: relative;
        flex: 1 1 auto;
        min-height: 0;
    }

    .panel-toolbar {
        margin-bottom: 6px;
        gap: 6px;
        flex-shrink: 0;
    }

    .panel-toolbar__lead {
        gap: 7px;
        min-width: 0;
    }

    .panel-toolbar__icon {
        width: 28px;
        height: 28px;
        border-radius: 9px;
    }

    .panel-toolbar__icon .portal-nav-icon-svg {
        width: 15px;
        height: 15px;
    }

    .panel-toolbar__title {
        font-size: 0.76rem;
        line-height: 1.2;
    }

    .panel-toolbar__meta {
        font-size: 0.6rem;
        margin-top: 0;
    }

    .view-toggle {
        padding: 2px;
        flex-shrink: 0;
    }

    .view-toggle__btn {
        width: 28px;
        height: 24px;
    }

    .view-toggle__btn svg {
        width: 13px;
        height: 13px;
    }

    .app-grid {
        flex: 1 1 auto;
        min-height: 0;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
        padding: 2px 1px 2px;
        align-content: start;
        overflow-y: auto;
        overflow-x: hidden;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .app-grid::-webkit-scrollbar {
        display: none;
        width: 0;
        height: 0;
    }

    .app-card {
        padding: 6px 5px 5px;
        gap: 3px;
        border-radius: 11px;
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.95),
            0 2px 6px rgba(55, 15, 28, 0.07),
            0 6px 14px rgba(120, 35, 55, 0.09);
    }

    .app-card:hover,
    .app-card:focus-visible {
        transform: translateY(-2px) scale(1.01);
    }

    .app-card__icon-wrap {
        width: 32px;
        height: 32px;
        border-radius: 8px;
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.9),
            0 2px 6px rgba(55, 15, 28, 0.08);
    }

    .app-card__icon {
        padding: 4px;
    }

    .app-card__name {
        font-size: 0.56rem;
        min-height: 2.15em;
        line-height: 1.18;
    }

    .app-card__url {
        font-size: 0.48rem;
    }

    .app-card__action {
        width: 20px;
        height: 20px;
        margin-top: 0;
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.3),
            0 3px 8px rgba(159, 18, 57, 0.28);
    }

    .app-card__action svg {
        width: 11px;
        height: 11px;
    }

    .portal-quote-footer {
        flex-shrink: 0;
        margin-top: 4px;
        padding-top: 0;
        border-top: 0;
    }

    .portal-quote {
        display: none;
    }

    .portal-pagination {
        margin-top: 0;
        gap: 6px;
    }

    .portal-dot {
        width: 6px;
        height: 6px;
    }

    .portal-dot.is-active {
        width: 18px;
    }

    .mobile-bottom-nav {
        width: min(calc(100% - 14px), 460px);
        bottom: calc(6px + env(safe-area-inset-bottom));
        padding: 3px;
        border-radius: 18px;
    }

    .mobile-bottom-nav-item {
        min-height: 42px;
        padding: 3px 1px;
        border-radius: 14px;
    }

    .mobile-bottom-nav-item .portal-nav-icon-svg {
        width: 17px;
        height: 17px;
    }

    .mobile-bottom-nav-item__label {
        font-size: 0.52rem;
    }

    .liquid-tab-blob {
        width: var(--blob-size, 42px);
        height: var(--blob-size, 42px);
        border-radius: 50%;
    }

    .app-grid.is-list-view .app-card {
        padding: 6px 8px;
        gap: 8px;
    }

    .app-grid.is-list-view .app-card__icon-wrap {
        width: 30px;
        height: 30px;
    }
}

@media (max-width: 1060px) and (max-height: 740px) {
    .portal-main {
        padding-top: 6px;
        padding-bottom: calc(56px + env(safe-area-inset-bottom));
    }

    .portal-hero {
        padding: 6px 8px 8px;
        margin-bottom: 6px;
    }

    .portal-hero__logo-shell {
        width: 52px;
        height: 52px;
    }

    .portal-hero__logo {
        width: 38px;
        height: 38px;
    }

    .portal-hero__kicker {
        font-size: 1rem;
    }

    .portal-hero__title {
        font-size: 1.05rem;
    }

    .portal-content-card {
        padding: 6px 6px 4px;
    }

    .app-card {
        padding: 5px 4px 4px;
    }

    .app-card__icon-wrap {
        width: 28px;
        height: 28px;
    }

    .app-card__name {
        font-size: 0.52rem;
        min-height: 2em;
    }

    .mobile-bottom-nav-item {
        min-height: 38px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
    .app-card:hover,
    .app-card:focus-visible,
    .app-card:hover .app-card__icon-wrap,
    .app-card:hover .app-card__action,
    .sidebar-menu-item:not(.is-active):hover {
        transform: none;
    }
    .app-card::after { display: none; }
    .department-panel.enter-rtl,
    .department-panel.exit-ltr,
    .department-panel.enter-ltr,
    .department-panel.exit-rtl { animation: none !important; transform: none; }
}

@media (prefers-reduced-transparency: reduce) {
    .school-portal,
    .portal-sidebar,
    .portal-content-card,
    .mobile-bottom-nav,
    .app-card,
    .ios-panel,
    .ad-card,
    .glass-field {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: rgba(255, 255, 255, 0.96);
    }

    .portal-sidebar {
        background: #2a0a16;
    }

    .admin-login-modal__backdrop {
        backdrop-filter: none;
        background: rgba(55, 15, 28, 0.9);
    }
}

/* Admin dashboard */
.admindash {
    display: grid;
    gap: 14px;
}

.ad-metrics {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ad-metric {
    border-radius: 20px;
    padding: 14px;
    transition: transform 0.2s var(--ease);
}

.ad-metric:hover {
    transform: translateY(-2px);
}

.ad-metric.k1 { background: linear-gradient(160deg, rgba(255, 251, 235, 0.72), rgba(255, 237, 213, 0.55)); }
.ad-metric.k2 { background: linear-gradient(160deg, rgba(232, 251, 243, 0.72), rgba(220, 247, 234, 0.55)); }
.ad-metric.k3 { background: linear-gradient(160deg, rgba(255, 246, 231, 0.72), rgba(255, 240, 214, 0.55)); }
.ad-metric.k4 { background: linear-gradient(160deg, rgba(255, 247, 237, 0.72), rgba(254, 215, 170, 0.5)); }

.ad-metric .label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.ad-metric .value {
    margin-top: 6px;
    font-size: 1.55rem;
    line-height: 1;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: -0.03em;
}

.ad-metric .hint {
    margin-top: 6px;
    font-size: 0.84rem;
    color: var(--ink-soft);
    font-weight: 600;
}

.ad-card {
    border-radius: 22px;
    padding: 16px;
}

.ad-card h2 {
    margin: 0;
    font-size: 1.16rem;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: -0.02em;
}

.ad-card p.sub {
    margin: 4px 0 0;
    font-size: 0.9rem;
    color: var(--ink-soft);
    font-weight: 600;
}

.overview-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr;
}

.overview-stat-list {
    margin-top: 12px;
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.overview-stat {
    border-radius: 16px;
    padding: 10px;
}

.overview-stat .label {
    font-size: 0.76rem;
    color: var(--ink-soft);
    font-weight: 700;
    line-height: 1.35;
}

.overview-stat .value {
    margin-top: 4px;
    font-size: 1.2rem;
    line-height: 1;
    font-weight: 800;
    color: var(--ink);
}

.overview-actions,
.ad-actions {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.ad-panel .panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.panel-toggle {
    min-height: 34px;
    padding: 0 12px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--glass-stroke);
    background: rgba(255, 255, 255, 0.5);
    color: var(--ink);
    font-size: 0.82rem;
    font-weight: 800;
    cursor: pointer;
}

.ad-panel .panel-content {
    margin-top: 10px;
}

.ad-panel.is-collapsed .panel-content {
    display: none;
}

.status-grid {
    margin-top: 12px;
    display: grid;
    gap: 8px;
    grid-template-columns: 1fr;
}

.status-box {
    border-radius: 16px;
    padding: 10px;
}

.status-title {
    font-size: 0.76rem;
    color: var(--ink-soft);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.status-value {
    margin-top: 3px;
    font-size: 0.9rem;
    font-weight: 800;
}

.ok { color: #0f9f57; }
.bad { color: #dc2626; }
.warn { color: #d97706; }

.form-grid {
    margin-top: 12px;
    display: grid;
    gap: 10px;
}

.row2,
.row3 {
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr;
}

.field label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--ink-soft);
}

.text-input,
.file-input {
    width: 100%;
    border-radius: 14px;
    border: 1px solid var(--glass-stroke);
    background: rgba(255, 255, 255, 0.58);
    padding: 10px 12px;
    font-size: 0.92rem;
    color: var(--ink);
    outline: none;
    box-shadow: var(--highlight);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.text-input:focus,
.file-input:focus {
    border-color: rgba(225, 29, 72, 0.55);
    box-shadow: 0 0 0 4px rgba(225, 29, 72, 0.14), var(--highlight);
}

.select-input {
    padding-right: 34px;
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, #be123c 50%), linear-gradient(135deg, #be123c 50%, transparent 50%);
    background-position: calc(100% - 18px) calc(1em + 1px), calc(100% - 13px) calc(1em + 1px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

.file-input {
    padding: 7px 10px;
}

.file-input::file-selector-button {
    border: 0;
    border-radius: 9px;
    background: var(--accent-deep);
    color: #fff;
    font-weight: 700;
    padding: 7px 10px;
    margin-right: 8px;
    cursor: pointer;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    border-radius: 14px;
    border: 1px solid var(--glass-stroke);
    background: rgba(255, 255, 255, 0.5);
    padding: 0 10px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--ink);
}

.preview {
    margin-top: 8px;
    width: 64px;
    height: 64px;
    border-radius: 16px;
    object-fit: cover;
    border: 1px solid var(--glass-stroke);
}

.registry-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.registry-tools {
    display: grid;
    gap: 8px;
    justify-items: start;
}

.badge-set,
.registry-filter,
.registry-live {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-start;
}

.quick-search,
.quick-sort,
.registry-filter .text-input {
    width: 100%;
    max-width: 100%;
}

.quick-view-mode,
.quick-chip-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px;
    border: 1px solid var(--glass-stroke);
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.42);
    flex-wrap: wrap;
}

.view-chip,
.quick-chip,
.mini-action,
.filter-reset {
    min-height: 30px;
    padding: 0 10px;
    border-radius: var(--radius-pill);
    border: 1px solid transparent;
    background: transparent;
    color: var(--ink);
    font-size: 0.78rem;
    font-weight: 800;
    cursor: pointer;
    text-decoration: none;
}

.view-chip:hover,
.quick-chip:hover,
.mini-action:hover {
    background: rgba(255, 255, 255, 0.55);
}

.view-chip.is-active,
.quick-chip.is-active {
    background: linear-gradient(180deg, #f43f5e, var(--accent-deep));
    color: #fff;
}

.quick-live-count {
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--ink-soft);
}

.app-list {
    display: grid;
    gap: 10px;
}

.app-item {
    border-radius: 18px;
    padding: 12px;
}

.app-item.is-hidden {
    display: none;
}

.app-item.is-collapsed .app-form,
.app-item.is-collapsed form[data-delete-form] {
    display: none;
}

.app-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.app-ident {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.icon-box {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--glass-stroke);
    object-fit: cover;
    flex-shrink: 0;
}

.branding-panel {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed var(--glass-stroke-dim);
}

.branding-head h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--ink);
}

.branding-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin: 14px 0;
}

.branding-preview-card {
    border-radius: 16px;
    padding: 12px;
    text-align: center;
}

.branding-preview-card p {
    margin: 0 0 10px;
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--ink-soft);
}

.branding-preview-logo,
.branding-upload-preview {
    width: 76px;
    height: 76px;
    object-fit: contain;
    border-radius: 50%;
    border: 1px solid var(--glass-stroke);
    background: rgba(255, 255, 255, 0.7);
}

.branding-preview-favicon,
.branding-preview-pwa {
    object-fit: contain;
    border: 1px solid var(--glass-stroke);
    background: #fff;
}

.branding-preview-favicon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
}

.branding-preview-pwa {
    width: 56px;
    height: 56px;
    border-radius: 14px;
}

.branding-form {
    display: grid;
    gap: 12px;
    max-width: 560px;
}

.branding-note,
.branding-meta {
    margin: 0;
    font-size: 0.86rem;
    line-height: 1.5;
    color: var(--ink-soft);
    font-weight: 600;
}

.branding-upload-preview.hidden {
    display: none;
}

.app-item .app-name {
    margin: 0;
    font-size: 1rem;
    line-height: 1.2;
    color: var(--ink);
    font-weight: 800;
    display: block;
    -webkit-line-clamp: unset;
    overflow: visible;
    white-space: normal;
    text-align: left;
}

.app-meta {
    margin-top: 2px;
    font-size: 0.78rem;
    color: var(--ink-soft);
    font-weight: 600;
}

.app-state-group,
.app-inline-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.mini-action {
    border: 1px solid var(--glass-stroke);
    background: rgba(255, 255, 255, 0.46);
}

.mini-action.warn {
    color: #8b3d16;
    background: rgba(255, 233, 209, 0.8);
}

.state-pill {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    border-radius: var(--radius-pill);
    padding: 0 10px;
    font-size: 0.76rem;
    font-weight: 800;
    border: 1px solid;
}

.state-pill.active {
    color: #0b8f4d;
    background: rgba(233, 251, 242, 0.8);
    border-color: #b8f1d2;
}

.state-pill.inactive {
    color: #a92d2d;
    background: rgba(255, 240, 241, 0.8);
    border-color: #fecdd3;
}

.app-form {
    display: grid;
    gap: 10px;
}

.empty-box.is-hidden {
    display: none;
}

@media (min-width: 640px) {
    .ad-metrics {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

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

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

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

    .quick-search,
    .registry-filter .text-input {
        width: 280px;
    }

    .quick-sort {
        width: 170px;
    }

    .registry-tools,
    .badge-set,
    .registry-filter,
    .registry-live {
        justify-items: end;
        justify-content: flex-end;
    }
}

@media (min-width: 1061px) {
    .overview-grid {
        grid-template-columns: 1.2fr 1fr;
    }
}

