:root {
    --ae-bg: #060608;
    --ae-surface: rgba(14, 14, 18, 0.72);
    --ae-surface-solid: #0e0e12;
    --ae-border: rgba(255, 255, 255, 0.06);
    --ae-border-glow: rgba(245, 158, 11, 0.22);
    --ae-gold: #f59e0b;
    --ae-gold-soft: #fbbf24;
    --ae-gold-dim: rgba(245, 158, 11, 0.12);
    --ae-text: #f4f4f5;
    --ae-muted: #a1a1aa;
    --ae-radius: 1rem;
    --ae-ease: cubic-bezier(0.22, 1, 0.36, 1);
    --ae-sidebar: 17.5rem;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body.ae-app {
    font-family: 'Cairo', system-ui, sans-serif;
    background: var(--ae-bg);
    color: var(--ae-text);
    min-height: 100vh;
    overflow-x: hidden;
}

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

.ae-bg::before,
.ae-bg::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.45;
    animation: ae-drift 18s var(--ae-ease) infinite alternate;
}

.ae-bg::before {
    width: 42vw;
    height: 42vw;
    top: -12%;
    left: -8%;
    background: radial-gradient(circle, rgba(245, 158, 11, 0.35), transparent 68%);
}

.ae-bg::after {
    width: 36vw;
    height: 36vw;
    bottom: -10%;
    right: -6%;
    background: radial-gradient(circle, rgba(180, 120, 20, 0.2), transparent 70%);
    animation-delay: -6s;
}

.ae-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse 80% 70% at 50% 30%, black, transparent);
}

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

@keyframes ae-rise {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes ae-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes ae-shimmer {
    0% { background-position: 200% center; }
    100% { background-position: -200% center; }
}

@keyframes ae-pulse-glow {
    0%, 100% { box-shadow: 0 0 0 rgba(245, 158, 11, 0); }
    50% { box-shadow: 0 0 28px rgba(245, 158, 11, 0.15); }
}

.ae-shell {
    position: relative;
    z-index: 1;
    display: flex;
    min-height: 100vh;
}

.ae-sidebar {
    width: var(--ae-sidebar);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--ae-border);
    background: linear-gradient(180deg, rgba(10,10,14,0.94), rgba(8,8,10,0.88));
    backdrop-filter: blur(18px);
    animation: ae-fade-in 0.5s var(--ae-ease);
}

.ae-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem 1.25rem;
    text-decoration: none;
    color: inherit;
}

.ae-brand-mark {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.85rem;
    background: linear-gradient(135deg, #f59e0b, #b45309);
    display: grid;
    place-items: center;
    font-weight: 800;
    color: #0a0a0a;
    box-shadow: 0 8px 24px rgba(245, 158, 11, 0.25);
    animation: ae-pulse-glow 4s ease-in-out infinite;
}

.ae-brand-title {
    font-weight: 800;
    font-size: 1.05rem;
    line-height: 1.2;
    background: linear-gradient(90deg, #fde68a, #f59e0b);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.ae-brand-sub { font-size: 0.68rem; color: var(--ae-muted); }

.ae-nav { flex: 1; display: flex; flex-direction: column; gap: 0.35rem; }

.ae-nav-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.72rem 0.85rem;
    border-radius: 0.85rem;
    color: var(--ae-muted);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 600;
    transition: all 0.25s var(--ae-ease);
    position: relative;
    overflow: hidden;
}

.ae-nav-link svg {
    width: 1.15rem;
    height: 1.15rem;
    flex-shrink: 0;
    opacity: 0.75;
    transition: transform 0.25s var(--ae-ease), opacity 0.25s;
}

.ae-nav-link:hover {
    color: var(--ae-text);
    background: rgba(255,255,255,0.04);
    transform: translateX(-3px);
}

.ae-nav-link:hover svg { opacity: 1; transform: scale(1.08); }

.ae-nav-link.is-active {
    color: #fde68a;
    background: linear-gradient(90deg, var(--ae-gold-dim), transparent);
    border: 1px solid rgba(245, 158, 11, 0.18);
}

.ae-nav-link.is-active svg { opacity: 1; color: var(--ae-gold-soft); }

.ae-sidebar-foot {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--ae-border);
}

.ae-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 0.5rem;
    margin-bottom: 0.5rem;
}

.ae-user-avatar {
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 999px;
    background: linear-gradient(135deg, #3f3f46, #18181b);
    border: 1px solid var(--ae-border);
    display: grid;
    place-items: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--ae-gold-soft);
}

.ae-user-name { font-size: 0.82rem; font-weight: 700; }
.ae-user-role { font-size: 0.68rem; color: var(--ae-muted); }

.ae-main {
    flex: 1;
    min-width: 0;
    padding: 1.25rem 1.5rem 2.5rem;
    animation: ae-rise 0.55s var(--ae-ease);
}

.ae-topbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.ae-menu-btn {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    border: 1px solid var(--ae-border);
    background: var(--ae-surface);
    color: var(--ae-text);
    cursor: pointer;
}

.ae-page-header {
    margin-bottom: 1.75rem;
    animation: ae-rise 0.6s var(--ae-ease) backwards;
}

.ae-page-title {
    font-size: clamp(1.6rem, 3vw, 2.15rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(90deg, #fff 0%, #d4d4d8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.ae-page-desc {
    margin-top: 0.35rem;
    color: var(--ae-muted);
    font-size: 0.92rem;
    max-width: 42rem;
}

.ae-card {
    background: var(--ae-surface);
    border: 1px solid var(--ae-border);
    border-radius: calc(var(--ae-radius) + 4px);
    backdrop-filter: blur(14px);
    transition: border-color 0.3s var(--ae-ease), transform 0.3s var(--ae-ease), box-shadow 0.3s var(--ae-ease);
}

.ae-card:hover {
    border-color: var(--ae-border-glow);
    box-shadow: 0 12px 40px rgba(0,0,0,0.35);
}

.ae-card-lift:hover { transform: translateY(-3px); }

.ae-stat {
    padding: 1.15rem 1.2rem;
    animation: ae-rise 0.65s var(--ae-ease) backwards;
}

.ae-stat-label { font-size: 0.78rem; color: var(--ae-muted); margin-bottom: 0.35rem; }

.ae-stat-value {
    font-size: 1.85rem;
    font-weight: 800;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.ae-stat-value.gold { color: var(--ae-gold-soft); }
.ae-stat-value.emerald { color: #6ee7b7; }
.ae-stat-value.orange { color: #fdba74; }

.ae-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.62rem 1.15rem;
    border-radius: 0.85rem;
    font-weight: 700;
    font-size: 0.88rem;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: transform 0.2s var(--ae-ease), box-shadow 0.25s, filter 0.25s;
    position: relative;
    overflow: hidden;
}

.ae-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.18) 50%, transparent 60%);
    transform: translateX(120%);
    transition: transform 0.55s var(--ae-ease);
}

.ae-btn:hover::after { transform: translateX(-120%); }
.ae-btn:hover { transform: translateY(-1px); }
.ae-btn:active { transform: translateY(0) scale(0.98); }

.ae-btn-primary {
    background: linear-gradient(135deg, #fbbf24, #d97706);
    color: #111;
    box-shadow: 0 8px 24px rgba(245, 158, 11, 0.28);
}

.ae-btn-primary:hover { box-shadow: 0 12px 32px rgba(245, 158, 11, 0.38); }

.ae-btn-emerald {
    background: linear-gradient(135deg, #34d399, #059669);
    color: #052e1c;
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.22);
}

.ae-btn-ghost {
    background: rgba(255,255,255,0.04);
    color: var(--ae-text);
    border: 1px solid var(--ae-border);
}

.ae-btn-danger { background: transparent; color: #fca5a5; border: none; padding: 0.4rem 0.6rem; }

.ae-table-wrap {
    overflow: hidden;
    border-radius: calc(var(--ae-radius) + 4px);
    animation: ae-rise 0.7s var(--ae-ease) backwards;
}

.ae-table { width: 100%; font-size: 0.88rem; border-collapse: collapse; }

.ae-table thead {
    background: rgba(255,255,255,0.03);
    color: var(--ae-muted);
}

.ae-table th, .ae-table td { padding: 0.85rem 1rem; text-align: right; }

.ae-table tbody tr {
    border-top: 1px solid var(--ae-border);
    transition: background 0.2s, transform 0.2s;
}

.ae-table tbody tr:hover { background: rgba(245, 158, 11, 0.04); }

.ae-table .mono { font-family: ui-monospace, monospace; color: var(--ae-gold-soft); font-size: 0.82rem; }

.ae-link {
    color: var(--ae-gold-soft);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.ae-link:hover { color: #fde68a; }

.ae-badge {
    display: inline-flex;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    border: 1px solid transparent;
}

.ae-badge-active { background: rgba(245,158,11,0.12); color: #fcd34d; border-color: rgba(245,158,11,0.2); }
.ae-badge-done { background: rgba(16,185,129,0.12); color: #6ee7b7; border-color: rgba(16,185,129,0.2); }
.ae-badge-muted { background: rgba(255,255,255,0.05); color: var(--ae-muted); border-color: var(--ae-border); }

.ae-flash {
    padding: 0.85rem 1rem;
    border-radius: 0.85rem;
    margin-bottom: 1rem;
    animation: ae-rise 0.4s var(--ae-ease);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.9rem;
}

.ae-flash-success {
    border: 1px solid rgba(16, 185, 129, 0.28);
    background: rgba(16, 185, 129, 0.08);
    color: #a7f3d0;
}

.ae-flash-error {
    border: 1px solid rgba(239, 68, 68, 0.28);
    background: rgba(239, 68, 68, 0.08);
    color: #fecaca;
}

.ae-input,
.ae-select,
.ae-textarea {
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.72rem 1rem;
    border-radius: 0.85rem;
    background: rgba(0,0,0,0.45);
    border: 1px solid var(--ae-border);
    color: var(--ae-text);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ae-input:focus,
.ae-select:focus,
.ae-textarea:focus {
    border-color: rgba(245, 158, 11, 0.45);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

.ae-label { font-size: 0.82rem; color: var(--ae-muted); }

.ae-section {
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    animation: ae-rise 0.65s var(--ae-ease) backwards;
}

.ae-section-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--ae-gold-soft);
    margin-bottom: 1rem;
}

.ae-stagger > *:nth-child(1) { animation-delay: 0.05s; }
.ae-stagger > *:nth-child(2) { animation-delay: 0.1s; }
.ae-stagger > *:nth-child(3) { animation-delay: 0.15s; }
.ae-stagger > *:nth-child(4) { animation-delay: 0.2s; }
.ae-stagger > *:nth-child(5) { animation-delay: 0.25s; }

.ae-quick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.85rem;
    margin-bottom: 1.75rem;
}

.ae-quick {
    padding: 1rem;
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.ae-quick-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    display: grid;
    place-items: center;
    background: var(--ae-gold-dim);
    color: var(--ae-gold-soft);
    transition: transform 0.25s var(--ae-ease);
}

.ae-quick:hover .ae-quick-icon { transform: scale(1.08) rotate(-4deg); }

.ae-pagination nav { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.ae-pagination nav a,
.ae-pagination nav span {
    padding: 0.45rem 0.75rem;
    border-radius: 0.55rem;
    border: 1px solid var(--ae-border);
    background: rgba(255,255,255,0.03);
    color: var(--ae-muted);
    text-decoration: none;
    font-size: 0.82rem;
    transition: all 0.2s;
}
.ae-pagination nav a:hover { border-color: var(--ae-border-glow); color: var(--ae-gold-soft); }
.ae-pagination nav span[aria-current="page"] {
    background: var(--ae-gold-dim);
    color: var(--ae-gold-soft);
    border-color: rgba(245,158,11,0.25);
}

.ae-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 40;
    backdrop-filter: blur(3px);
}

@media (max-width: 1024px) {
    .ae-sidebar {
        position: fixed;
        top: 0;
        right: 0;
        z-index: 50;
        transform: translateX(100%);
        transition: transform 0.35s var(--ae-ease);
        box-shadow: -20px 0 60px rgba(0,0,0,0.5);
    }
    .ae-sidebar.is-open { transform: translateX(0); }
    .ae-overlay.is-open { display: block; }
    .ae-topbar { display: flex; }
    .ae-main { padding: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Login */
.ae-login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    position: relative;
    z-index: 1;
}

.ae-login-card {
    width: 100%;
    max-width: 26rem;
    padding: 2rem;
    animation: ae-rise 0.7s var(--ae-ease);
}

.ae-login-glow {
    position: absolute;
    width: 120%;
    height: 120%;
    top: -10%;
    right: -10%;
    background: radial-gradient(circle at 30% 20%, rgba(245,158,11,0.15), transparent 55%);
    pointer-events: none;
}