:root {
    --portal-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --portal-font-ar: 'Tajawal', 'Inter', sans-serif;
    --portal-bg: #f8fafc;
    --portal-bg-elevated: #ffffff;
    --portal-surface: rgba(255, 255, 255, 0.72);
    --portal-surface-border: rgba(15, 23, 42, 0.08);
    --portal-surface-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 32px rgba(15, 23, 42, 0.06);
    --portal-text: #0f172a;
    --portal-text-secondary: #475569;
    --portal-text-muted: #94a3b8;
    --portal-text-faint: #cbd5e1;
    --portal-accent: #2563eb;
    --portal-accent-hover: #1d4ed8;
    --portal-accent-soft: rgba(37, 99, 235, 0.08);
    --portal-accent-ring: rgba(37, 99, 235, 0.22);
    --portal-mesh-1: rgba(37, 99, 235, 0.07);
    --portal-mesh-2: rgba(99, 102, 241, 0.05);
    --portal-mesh-3: rgba(14, 165, 233, 0.04);
    --portal-grid: rgba(15, 23, 42, 0.035);
    --portal-blueprint: rgba(37, 99, 235, 0.06);
    --portal-node: rgba(37, 99, 235, 0.35);
    --portal-radius-sm: 8px;
    --portal-radius: 12px;
    --portal-radius-lg: 16px;
    --portal-radius-xl: 20px;
    --portal-transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    --portal-theme-transition: 0.24s ease-out;
    --portal-shell-max: 1080px;
}

[data-theme="dark"] {
    --portal-bg: #14141c;
    --portal-bg-elevated: #1c1c26;
    --portal-surface: rgba(28, 28, 38, 0.9);
    --portal-surface-border: rgba(255, 255, 255, 0.09);
    --portal-surface-shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 16px 48px rgba(0, 0, 0, 0.35);
    --portal-text: #fafafa;
    --portal-text-secondary: #d4d4d8;
    --portal-text-muted: #a1a1aa;
    --portal-text-faint: #71717a;
    --portal-accent: #3b82f6;
    --portal-accent-hover: #60a5fa;
    --portal-accent-soft: rgba(59, 130, 246, 0.14);
    --portal-accent-ring: rgba(59, 130, 246, 0.25);
}

body.kc-portal {
    font-family: var(--portal-font);
    font-size: 1rem;
    background: var(--portal-bg);
    color: var(--portal-text);
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
}

body.kc-portal::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background:
        radial-gradient(92% 24% at 50% -10%, rgba(59, 130, 246, 0.2) 0%, rgba(59, 130, 246, 0) 78%),
        radial-gradient(92% 24% at 50% 110%, rgba(59, 130, 246, 0.17) 0%, rgba(59, 130, 246, 0) 78%),
        radial-gradient(24% 92% at -8% 50%, rgba(59, 130, 246, 0.14) 0%, rgba(59, 130, 246, 0) 78%),
        radial-gradient(24% 92% at 108% 50%, rgba(59, 130, 246, 0.14) 0%, rgba(59, 130, 246, 0) 78%);
    opacity: 0.92;
    mix-blend-mode: normal;
}

[data-theme="dark"] body.kc-portal::before {
    background:
        radial-gradient(92% 20% at 50% -10%, rgba(96, 165, 250, 0.1) 0%, rgba(59, 130, 246, 0) 82%),
        radial-gradient(92% 20% at 50% 110%, rgba(96, 165, 250, 0.08) 0%, rgba(59, 130, 246, 0) 82%),
        radial-gradient(20% 92% at -8% 50%, rgba(59, 130, 246, 0.08) 0%, rgba(59, 130, 246, 0) 82%),
        radial-gradient(20% 92% at 108% 50%, rgba(59, 130, 246, 0.08) 0%, rgba(59, 130, 246, 0) 82%);
    opacity: 0.55;
}

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

html[dir="rtl"] body.kc-portal {
    font-family: var(--portal-font-ar);
}

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

.portal-canvas__mesh {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 15% 10%, var(--portal-mesh-1) 0%, transparent 50%),
        radial-gradient(ellipse 60% 50% at 85% 20%, var(--portal-mesh-2) 0%, transparent 45%),
        radial-gradient(ellipse 50% 40% at 50% 100%, var(--portal-mesh-3) 0%, transparent 50%),
        var(--portal-bg);
}

.portal-canvas__grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(var(--portal-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--portal-grid) 1px, transparent 1px);
    background-size: 64px 64px;
    mask-image: radial-gradient(ellipse 80% 70% at 50% 40%, black 20%, transparent 75%);
}

.portal-canvas__blueprint {
    position: absolute;
    inset: 0;
    opacity: 0.55;
    background-image:
        linear-gradient(var(--portal-blueprint) 1px, transparent 1px),
        linear-gradient(90deg, var(--portal-blueprint) 1px, transparent 1px);
    background-size: 320px 320px;
}

.portal-canvas__glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
}

.portal-canvas__glow--a {
    top: -10%;
    right: 15%;
    width: 420px;
    height: 420px;
    background: rgba(37, 99, 235, 0.12);
}

.portal-canvas__glow--b {
    bottom: -5%;
    left: 10%;
    width: 360px;
    height: 360px;
    background: var(--portal-mesh-2);
}

.portal-canvas__system-icons,
.portal-canvas__nodes {
    position: absolute;
    inset: 0;
}

.portal-bg-sys-icon {
    position: absolute;
    display: flex;
    color: var(--portal-text-muted);
    opacity: 0.07;
}

.portal-bg-sys-icon svg {
    width: 100%;
    height: 100%;
}

.portal-bg-sys-icon--1 { top: 14%; left: 7%; width: 52px; height: 52px; }
.portal-bg-sys-icon--2 { top: 22%; right: 10%; width: 44px; height: 44px; }
.portal-bg-sys-icon--3 { top: 48%; left: 5%; width: 40px; height: 40px; }
.portal-bg-sys-icon--4 { bottom: 28%; right: 8%; width: 48px; height: 48px; }
.portal-bg-sys-icon--5 { bottom: 18%; left: 14%; width: 56px; height: 56px; }
.portal-bg-sys-icon--6 { top: 38%; right: 18%; width: 38px; height: 38px; }

.portal-node {
    position: absolute;
    left: var(--x);
    top: var(--y);
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--portal-node);
}

.portal-topbar {
    position: relative;
    z-index: 20;
    max-width: var(--portal-shell-max);
    margin: 0 auto;
    padding: 0.875rem clamp(1.25rem, 3vw, 2rem);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.portal-topbar__start,
.portal-topbar__end {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.portal-topbar .portal-locale-toggle {
    display: inline-flex;
    align-items: center;
    padding: 0.4375rem 0.75rem;
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--portal-text-secondary);
    border: 1px solid var(--portal-surface-border);
    border-radius: var(--portal-radius-sm);
    background: var(--portal-surface);
    cursor: pointer;
    transition:
        border-color var(--portal-transition),
        color var(--portal-transition),
        background var(--portal-transition);
}

.portal-topbar .portal-locale-toggle:hover {
    color: var(--portal-accent);
    border-color: color-mix(in srgb, var(--portal-accent) 30%, var(--portal-surface-border));
}

.portal-theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.625rem 0.375rem 0.375rem;
    border: 1px solid var(--portal-surface-border);
    border-radius: 999px;
    background: var(--portal-surface);
    color: var(--portal-text-secondary);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
}

.kc-theme-toggle-label {
    font-family: inherit;
    font-weight: 500;
}

.kc-theme-toggle-track {
    display: flex;
    align-items: center;
    width: 36px;
    height: 20px;
    padding: 2px;
    border-radius: 999px;
    background: var(--portal-accent-soft);
}

.kc-theme-toggle-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--portal-bg-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--portal-transition);
}

[data-theme="dark"] .kc-theme-toggle-thumb {
    transform: translateX(16px);
}

html[dir="rtl"][data-theme="dark"] .kc-theme-toggle-thumb {
    transform: translateX(-16px);
}

.kc-theme-icon--moon { display: none; }
[data-theme="dark"] .kc-theme-icon--sun { display: none; }
[data-theme="dark"] .kc-theme-icon--moon { display: block; }

.portal-shell {
    position: relative;
    z-index: 10;
    max-width: var(--portal-shell-max);
    margin: 0 auto;
    padding: 0 2rem 2rem;
}

.portal-shell--stacked {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}

.portal-hero {
    text-align: center;
    max-width: 780px;
}

.portal-hero__logo {
    width: 110px;
    height: 125px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid var(--portal-surface-border);
    margin-bottom: 1rem;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
}

.portal-hero__title {
    margin: 0 0 0.375rem;
    font-size: clamp(1.125rem, 2.2vw, 1.5rem);
    font-weight: 700;
    line-height: 1.35;
}

.portal-hero__hint {
    margin: 0;
    font-size: 0.9375rem;
    color: var(--portal-text-muted);
}

.portal-page-footer {
    width: 100%;
    text-align: center;
    padding-top: 0.75rem;
}

.portal-page-footer .portal-social {
    margin-bottom: 0.875rem;
}

.social-icons-grid {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.social-icon-link {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: var(--portal-text-muted);
    border: 1px solid transparent;
    transition:
        transform var(--portal-transition),
        color var(--portal-transition),
        border-color var(--portal-transition);
}

.social-icon-link:hover {
    transform: scale(1.08);
    border-color: currentColor;
}

.social-icon-link[aria-label="Facebook"]:hover { color: #1877f2; }
.social-icon-link[aria-label="X"]:hover { color: #111827; }
.social-icon-link[aria-label="Instagram"]:hover { color: #e4405f; }
.social-icon-link[aria-label="LinkedIn"]:hover { color: #0a66c2; }
.social-icon-link[aria-label="YouTube"]:hover { color: #ff0000; }

.kc-copyright,
.kc-organization-unit {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.2;
    color: var(--portal-text-muted);
}

.floating-support-btn,
.support-menu-item {
    position: fixed;
    bottom: 1.5rem;
    inset-inline-end: 1.5rem;
    z-index: 50;
    border-radius: 50%;
    background: var(--portal-bg-elevated);
    border: 1px solid var(--portal-surface-border);
    color: var(--portal-text-secondary);
}

.floating-support-btn {
    width: 52px;
    height: 52px;
    cursor: pointer;
}

.support-menu-item {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: scale(0.3);
    transition: all 0.25s ease;
    text-decoration: none;
}

.support-menu-item.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: scale(1);
}

.support-menu-item.item-top.active {
    bottom: calc(1.5rem + 60px);
}

.support-menu-item.item-center.active {
    bottom: calc(1.5rem + 60px);
    inset-inline-end: calc(1.5rem + 60px);
}

.support-menu-item.item-right.active {
    inset-inline-end: calc(1.5rem + 60px);
}

.support-close-icon {
    display: none;
}

.floating-support-btn.active .support-main-icon {
    display: none;
}

.floating-support-btn.active .support-close-icon {
    display: block;
}

.portal-auth-status {
    display: flex;
    align-items: center;
}

.portal-user-menu {
    position: relative;
}

.portal-user-menu__btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    max-width: min(52vw, 18rem);
    padding: 0.375rem 0.75rem 0.375rem 0.375rem;
    border-radius: 999px;
    border: 1px solid var(--portal-surface-border);
    background: var(--portal-surface);
    color: var(--portal-text-secondary);
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.2;
    cursor: pointer;
    transition:
        border-color var(--portal-transition),
        background var(--portal-transition),
        box-shadow var(--portal-transition),
        color var(--portal-transition);
}

.portal-user-menu__btn:hover {
    border-color: color-mix(in srgb, var(--portal-accent) 28%, var(--portal-surface-border));
    background: var(--portal-bg-elevated);
}

.portal-user-menu.is-open .portal-user-menu__btn {
    border-color: color-mix(in srgb, var(--portal-accent) 38%, var(--portal-surface-border));
    background: var(--portal-bg-elevated);
    color: var(--portal-text);
    box-shadow: var(--portal-surface-shadow);
}

.portal-user-menu__label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.portal-user-menu__avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: var(--portal-accent-soft);
    color: var(--portal-accent);
    font-size: 0.75rem;
    font-weight: 700;
}

.portal-user-menu__chevron {
    flex-shrink: 0;
    color: var(--portal-text-muted);
    transition: transform var(--portal-transition);
}

.portal-user-menu.is-open .portal-user-menu__chevron {
    transform: rotate(180deg);
    color: var(--portal-accent);
}

.portal-user-menu__panel {
    position: absolute;
    top: calc(100% + 0.5rem);
    inset-inline-end: 0;
    min-width: 14.5rem;
    max-width: min(88vw, 20rem);
    border: 1px solid var(--portal-surface-border);
    border-radius: var(--portal-radius);
    background: var(--portal-bg-elevated);
    box-shadow: var(--portal-surface-shadow);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    pointer-events: none;
    transition:
        opacity var(--portal-transition),
        transform var(--portal-transition),
        visibility var(--portal-transition);
    z-index: 40;
    overflow: hidden;
}

.portal-user-menu.is-open .portal-user-menu__panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.portal-user-menu__info {
    padding: 0.625rem 0.875rem 0.5rem;
    border-bottom: 1px solid var(--portal-surface-border);
}

.portal-user-menu__name {
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--portal-text);
    word-break: break-word;
}

.portal-user-menu__username {
    margin-top: 0.125rem;
    font-size: 0.75rem;
    color: var(--portal-text-muted);
}

.portal-user-menu__actions {
    padding: 0.25rem 0;
}

.portal-user-menu__form {
    margin: 0;
}

.portal-user-menu__item {
    display: block;
    width: 100%;
    padding: 0.55rem 0.875rem;
    border: none;
    background: none;
    color: var(--portal-text-secondary);
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.35;
    text-align: start;
    text-decoration: none;
    cursor: pointer;
    transition:
        background var(--portal-transition),
        color var(--portal-transition);
}

.portal-user-menu__item:hover,
.portal-user-menu__item:focus-visible {
    background: var(--portal-accent-soft);
    color: var(--portal-accent);
    outline: none;
}

.portal-user-menu__item--logout:hover,
.portal-user-menu__item--logout:focus-visible {
    color: #dc2626;
    background: rgba(220, 38, 38, 0.08);
}
