:root {
    /* MeGa NeT / Malak Royal Dark (linepro) Default Theme */
    --bg: #0d0820;
    --bg-gradient: linear-gradient(160deg, #130b2e 0%, #0d0820 55%, #090617 100%);
    --surface: rgba(24, 16, 52, 0.88);
    --surface-card: linear-gradient(145deg, rgba(28, 19, 62, 0.9) 0%, rgba(18, 12, 42, 0.94) 100%);
    --surface-subtle: rgba(15, 10, 36, 0.72);
    --surface-input: rgba(12, 8, 28, 0.85);
    --text: #f8fafc;
    --text-soft: #e2e8f0;
    --muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.16);

    --sidebar-bg: linear-gradient(180deg, #140c30 0%, #0d0822 100%);
    --sidebar-hover: rgba(255, 255, 255, 0.06);
    --sidebar-text: #d1d5db;

    --primary: #E50914;
    --primary-hover: #c80812;
    --primary-soft: rgba(229, 9, 20, 0.16);
    --primary-glow: rgba(229, 9, 20, 0.28);
    --accent-royal: #c084fc;
    --accent-soft: rgba(192, 132, 252, 0.16);

    --success: #10b981;
    --success-soft: rgba(16, 185, 129, 0.16);
    --success-text: #6ee7b7;

    --warning: #f59e0b;
    --warning-soft: rgba(245, 158, 11, 0.16);
    --warning-text: #fde68a;

    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.18);
    --danger-text: #fca5a5;

    --info-soft: rgba(56, 189, 248, 0.16);
    --info-text: #7dd3fc;

    --topbar-bg: rgba(17, 11, 41, 0.92);
    --track-bg: rgba(255, 255, 255, 0.08);
    --row-hover: rgba(255, 255, 255, 0.04);
    --topbar-btn-bg: rgba(255, 255, 255, 0.06);

    --radius: 16px;
    --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    --shadow: 0 14px 36px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

html.light-theme {
    --bg: #f3f6fb;
    --bg-gradient:
        radial-gradient(rgba(15, 23, 42, 0.04) 1px, transparent 1px),
        radial-gradient(circle at 12% 0%, rgba(79, 70, 229, 0.09) 0%, transparent 45%),
        radial-gradient(circle at 88% 12%, rgba(14, 165, 233, 0.07) 0%, transparent 40%);
    --surface: #ffffff;
    --surface-card: #ffffff;
    --surface-subtle: #f8fafc;
    --surface-input: #ffffff;
    --text: #0f172a;
    --text-soft: #475569;
    --muted: #64748b;
    --border: rgba(15, 23, 42, 0.08);
    --border-strong: #cbd5e1;

    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef2ff;
    --primary-glow: rgba(79, 70, 229, 0.2);
    --accent-royal: #4f46e5;
    --accent-soft: #eef2ff;

    --success-soft: #ecfdf5;
    --success-text: #047857;
    --warning-soft: #fffbeb;
    --warning-text: #b45309;
    --danger-soft: #fef2f2;
    --danger-text: #b91c1c;
    --info-soft: #eff6ff;
    --info-text: #1d4ed8;

    --topbar-bg: rgba(255, 255, 255, 0.9);
    --track-bg: #eef2f6;
    --row-hover: #f8fafc;
    --topbar-btn-bg: #ffffff;

    --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.03);
    --shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #0d0820; }
::-webkit-scrollbar-thumb { background: #2b1d54; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }
html.light-theme ::-webkit-scrollbar-track { background: #f1f5f9; }
html.light-theme ::-webkit-scrollbar-thumb { background: #cbd5e1; }

body {
    margin: 0;
    font-family: "Cairo", "Tajawal", "Segoe UI", Tahoma, Arial, sans-serif;
    background-color: var(--bg);
    background-image:
        radial-gradient(circle at 15% 0%, rgba(124, 58, 237, 0.16) 0%, transparent 45%),
        radial-gradient(circle at 85% 15%, rgba(229, 9, 20, 0.12) 0%, transparent 40%),
        var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

html.light-theme body {
    background-color: var(--bg);
    background-image: var(--bg-gradient);
    background-size: 22px 22px, 100% 100%, 100% 100%;
    background-attachment: scroll;
}

a { color: var(--accent-royal); text-decoration: none; }
html.light-theme a { color: var(--primary); }

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Admin App Shell */
.admin-shell {
    display: grid;
    grid-template-columns: 244px 1fr;
    min-height: 100vh;
}

.admin-sidebar {
    background: var(--sidebar-bg);
    color: #fff;
    padding: 16px 11px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.35);
}

.sidebar-section-label {
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.4px;
    color: #9ca3af;
    padding: 10px 10px 4px;
    text-transform: uppercase;
}

.sidebar-clockbox {
    background: rgba(12, 8, 28, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 10px;
    padding: 8px 10px;
    margin: 0 2px 10px;
    text-align: center;
    line-height: 1.45;
}
.sidebar-clockbox .clock-date-txt {
    color: #e2e8f0;
    font-size: 0.74rem;
    font-weight: 700;
}
.sidebar-clockbox .clock-time-txt {
    color: #fbbf24;
    font-size: 0.84rem;
    font-weight: 900;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    letter-spacing: 0.6px;
    display: inline-block;
    margin-top: 2px;
}

.sidebar-status-box {
    margin: 12px 2px 10px;
    padding: 9px 11px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.09);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.78rem;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.pulse-dot.ok {
    background: #10b981;
    box-shadow: 0 0 8px #10b981, 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.pulse-dot.warn {
    background: #fbbf24;
    box-shadow: 0 0 8px #fbbf24, 0 0 0 3px rgba(251, 191, 36, 0.2);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 10px;
}

.sidebar-logo {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: linear-gradient(135deg, #E50914 0%, #9333ea 100%);
    box-shadow: 0 6px 16px rgba(229, 9, 20, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
}

.stu-wordmark {
    display: flex;
    align-items: baseline;
    gap: 5px;
    line-height: 1.1;
}
.stu-word-p1 {
    font-size: 1.14rem;
    font-weight: 900;
    color: #ffffff;
    letter-spacing: 0.4px;
}
html.light-theme .stu-topbar .stu-word-p1 {
    color: #0f172a;
}
.stu-word-p2 {
    font-size: 1.05rem;
    font-weight: 900;
    background: linear-gradient(90deg, #ff6b00 0%, #fbbf24 55%, #10b981 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.stu-word-sub {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    color: #94a3b8;
    margin-top: 2px;
}

.sidebar-nav {
    display: grid;
    gap: 4px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8.5px 10px;
    border-radius: 11px;
    color: var(--sidebar-text);
    font-weight: 700;
    font-size: 0.86rem;
    border: 1px solid transparent;
    position: relative;
    transition: all 0.15s ease;
}

.sidebar-link-left {
    display: inline-flex;
    align-items: center;
    gap: 9px;
}

.nav-icon-tile {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(30, 41, 59, 0.78);
    border: 1px solid rgba(148, 163, 184, 0.25);
    color: #cbd5e1;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.09);
}

.sidebar-link:hover .nav-icon-tile {
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.22);
}

.sidebar-link.active {
    background: linear-gradient(to left, rgba(229, 9, 20, 0.26) 0%, rgba(229, 9, 20, 0.11) 58%, rgba(229, 9, 20, 0.02) 100%);
    color: #ffffff;
    border: 1px solid rgba(229, 9, 20, 0.42);
    border-right: 3.5px solid #E50914;
    box-shadow: 0 3px 12px rgba(229, 9, 20, 0.2);
    font-weight: 800;
}

.sidebar-link.active .nav-icon-tile {
    background: rgba(229, 9, 20, 0.24);
    border-color: rgba(229, 9, 20, 0.55);
    color: #ff4d57;
}

.sidebar-pill {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 999px;
}

.sidebar-pill.warn {
    background: #f59e0b;
    color: #0f172a;
}

.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 10px;
    display: grid;
    gap: 5px;
}

.admin-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.admin-topbar {
    background: var(--topbar-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
    padding: 12px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 30;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
}

.admin-topbar h1 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 900;
    color: var(--text);
}

.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 11px;
    border-radius: 9px;
    border: 1px solid var(--border-strong);
    background: var(--topbar-btn-bg);
    color: var(--text);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.theme-toggle-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.admin-content {
    padding: 18px 22px 44px;
    max-width: 1280px;
    width: 100%;
}

/* Modern Hero Strip in Admin Overview */
.admin-hero-strip {
    background:
        radial-gradient(circle at 12% 20%, rgba(229, 9, 20, 0.22) 0%, transparent 45%),
        radial-gradient(circle at 88% 80%, rgba(168, 85, 247, 0.24) 0%, transparent 45%),
        linear-gradient(135deg, #160c36 0%, #241046 56%, #3c0a24 100%);
    color: #fff;
    border-radius: 18px;
    padding: 18px 22px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.11);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.38);
}

.admin-hero-strip::after {
    content: "";
    position: absolute;
    left: -60px;
    top: -60px;
    width: 190px;
    height: 190px;
    border-radius: 50%;
    border: 24px solid rgba(255, 255, 255, 0.04);
    pointer-events: none;
}

.admin-hero-strip h3 {
    margin: 0 0 3px;
    font-size: 1.04rem;
    font-weight: 800;
    color: #fff;
}

.admin-hero-strip p {
    margin: 0;
    font-size: 0.84rem;
    color: #cbd5e1;
}

.admin-hero-pills {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.hero-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: #f8fafc;
    font-size: 0.79rem;
    font-weight: 700;
    white-space: nowrap;
}

.hero-chip.ok {
    background: rgba(16, 185, 129, 0.2);
    border-color: rgba(52, 211, 153, 0.45);
    color: #6ee7b7;
}

.hero-chip.warn {
    background: rgba(245, 158, 11, 0.22);
    border-color: rgba(251, 191, 36, 0.45);
    color: #fde68a;
}

/* Public / Student Topbar */
.stu-topbar {
    background: var(--topbar-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 40;
}

.stu-topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding-top: 11px;
    padding-bottom: 11px;
    flex-wrap: wrap;
}

.stu-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
}

.stu-logo {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    background: linear-gradient(135deg, #E50914, #9333ea);
    box-shadow: 0 5px 15px rgba(229, 9, 20, 0.3);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.stu-brand strong { display: block; font-size: 1rem; color: var(--text); }
.stu-brand small { display: block; font-size: 0.76rem; color: var(--muted); }

.stu-nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.stu-main {
    padding-top: 24px;
    padding-bottom: 48px;
}

/* KPI Grid (Clean 4-column desktop / 2x2 tablet) */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.kpi-card {
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 17px 14px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 10px;
    position: relative;
    overflow: hidden;
    transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.18s ease, border-color 0.18s ease;
}

.kpi-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #E50914, #c084fc);
}
html.light-theme .kpi-card::before {
    background: linear-gradient(90deg, #6366f1, #0ea5e9);
}

.kpi-card.amber::before { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.kpi-card.green::before { background: linear-gradient(90deg, #10b981, #34d399); }
.kpi-card.sky::before { background: linear-gradient(90deg, #06b6d4, #38bdf8); }

.kpi-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.kpi-sub {
    font-size: 0.76rem;
    color: var(--muted);
    font-weight: 700;
    margin-top: 2px;
}

.kpi-bar {
    height: 5px;
    border-radius: 999px;
    background: var(--track-bg);
    overflow: hidden;
}

.kpi-bar > span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #E50914, #c084fc);
}
html.light-theme .kpi-bar > span { background: linear-gradient(90deg, #6366f1, #0ea5e9); }

.kpi-card.amber .kpi-bar > span { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.kpi-card.green .kpi-bar > span { background: linear-gradient(90deg, #10b981, #34d399); }
.kpi-card.sky .kpi-bar > span { background: linear-gradient(90deg, #06b6d4, #38bdf8); }

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: rgba(255, 255, 255, 0.18);
}

/* Telemetry Meters & Toggle Switches & Toast */
.meter-list { display: grid; gap: 13px; }
.meter-item { display: grid; gap: 5px; }
.meter-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.84rem;
    font-weight: 700;
}
.meter-track {
    height: 8px;
    border-radius: 999px;
    background: var(--track-bg);
    overflow: hidden;
}
.meter-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #E50914, #a855f7);
}
html.light-theme .meter-fill { background: linear-gradient(90deg, #4f46e5, #06b6d4); }
.meter-fill.green { background: linear-gradient(90deg, #059669, #34d399); }

.stu-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.88rem;
    user-select: none;
}
.stu-toggle input {
    appearance: none;
    -webkit-appearance: none;
    width: 40px;
    height: 22px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.35);
    border: 1px solid var(--border);
    position: relative;
    cursor: pointer;
    transition: background 0.16s ease;
    flex-shrink: 0;
}
.stu-toggle input::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: transform 0.16s ease;
}
.stu-toggle input:checked { background: var(--primary); border-color: var(--primary); }
.stu-toggle input:checked::after { transform: translateX(18px); }

.stu-toast {
    position: fixed;
    left: 22px;
    bottom: 22px;
    background: #140c30;
    color: #f8fafc;
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 700;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(229, 9, 20, 0.45);
    z-index: 200;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: all 0.2s ease;
}
.stu-toast.show { opacity: 1; transform: translateY(0); }

.kpi-label {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 700;
    margin-bottom: 4px;
    white-space: nowrap;
}

.kpi-val {
    font-size: 1.48rem;
    font-weight: 900;
    line-height: 1.15;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.kpi-icon.indigo { background: rgba(229, 9, 20, 0.18); color: #ff4d57; border-color: rgba(229, 9, 20, 0.3); }
.kpi-icon.green { background: rgba(16, 185, 129, 0.16); color: #34d399; border-color: rgba(16, 185, 129, 0.3); }
.kpi-icon.amber { background: rgba(245, 158, 11, 0.16); color: #fbbf24; border-color: rgba(245, 158, 11, 0.3); }
.kpi-icon.sky { background: rgba(56, 189, 248, 0.16); color: #38bdf8; border-color: rgba(56, 189, 248, 0.3); }

html.light-theme .kpi-icon { border-color: transparent; }
html.light-theme .kpi-icon.indigo { background: linear-gradient(135deg, #eef2ff, #e0e7ff); color: var(--primary); }
html.light-theme .kpi-icon.green { background: linear-gradient(135deg, #ecfdf5, #d1fae5); color: var(--success-text); }
html.light-theme .kpi-icon.amber { background: linear-gradient(135deg, #fffbeb, #fef3c7); color: var(--warning-text); }
html.light-theme .kpi-icon.sky { background: linear-gradient(135deg, #e0f2fe, #bae6fd); color: #0284c7; }

/* Cards */
.card {
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 18px;
}

.card-highlight {
    border-color: rgba(192, 132, 252, 0.35);
    background: linear-gradient(145deg, rgba(32, 20, 72, 0.92), rgba(20, 12, 48, 0.96));
}
html.light-theme .card-highlight {
    border-color: rgba(79, 70, 229, 0.3);
    background: linear-gradient(180deg, #ffffff, #f8fafc);
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.card-head h2 {
    margin: 0;
    font-size: 1.02rem;
    font-weight: 800;
    color: var(--text);
}

.grid-2 {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.hero-grid {
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    gap: 24px;
    align-items: start;
}

.price-banner {
    background:
        radial-gradient(circle at 10% 15%, rgba(229, 9, 20, 0.25) 0%, transparent 45%),
        linear-gradient(135deg, #140c30 0%, #241046 58%, #3c0a24 100%);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.price-tag {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.28);
    padding: 8px 18px;
    border-radius: 999px;
    margin: 12px 0;
}

.price-tag strong { font-size: 1.9rem; color: #fde047; }

.feature-list {
    list-style: none;
    padding: 0;
    margin: 18px 0 0;
    display: grid;
    gap: 10px;
}

.feature-list li {
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 14px;
    border-radius: 12px;
    font-weight: 600;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 6px;
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    padding: 5px;
    border-radius: 12px;
    margin-bottom: 18px;
}

.tab-btn {
    flex: 1;
    border: none;
    background: transparent;
    padding: 9px 10px;
    border-radius: 9px;
    font-family: inherit;
    font-weight: 800;
    font-size: 0.9rem;
    cursor: pointer;
    color: var(--muted);
    transition: all 0.15s ease;
}

.tab-btn.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px var(--primary-glow);
}

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 120px;
    gap: 12px;
}

@media (max-width: 560px) {
    .form-grid-3 { grid-template-columns: 1fr; }
}

.form-row-inline {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-weight: 700; margin-bottom: 5px; font-size: 0.86rem; color: var(--text-soft); }
.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.93rem;
    background: var(--surface-input);
    color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-control option {
    background: #140c30;
    color: #f8fafc;
}
html.light-theme .form-control option {
    background: #ffffff;
    color: #0f172a;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

code {
    background: rgba(255, 255, 255, 0.08);
    color: #e9d5ff;
    padding: 1px 6px;
    border-radius: 6px;
    font-size: 0.85em;
}
html.light-theme code {
    background: #f1f5f9;
    color: #4338ca;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 10px;
    border: 1px solid transparent;
    font-family: inherit;
    font-weight: 700;
    font-size: 0.89rem;
    cursor: pointer;
    transition: filter 0.12s ease, background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px var(--primary-glow);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { filter: brightness(0.95); }
.btn-warning { background: var(--warning); color: #0f172a; font-weight: 800; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline {
    background: var(--topbar-btn-bg);
    color: var(--text);
    border-color: var(--border-strong);
}
.btn-outline:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-soft);
}
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--row-hover); color: var(--text); }
.btn-sm { padding: 6px 11px; font-size: 0.81rem; border-radius: 8px; }
.btn-xs { padding: 4px 8px; font-size: 0.77rem; border-radius: 7px; }
.btn-lg { padding: 12px 22px; font-size: 1rem; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.action-btns {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.77rem;
    font-weight: 800;
    white-space: nowrap;
    border: 1px solid transparent;
}
.badge-success { background: var(--success-soft); color: var(--success-text); border-color: rgba(16, 185, 129, 0.28); }
.badge-danger { background: var(--danger-soft); color: var(--danger-text); border-color: rgba(239, 68, 68, 0.28); }
.badge-warning { background: var(--warning-soft); color: var(--warning-text); border-color: rgba(245, 158, 11, 0.28); }
.badge-info { background: var(--accent-soft); color: var(--accent-royal); border-color: rgba(192, 132, 252, 0.28); }
html.light-theme .badge { border-color: transparent; }

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 18px;
    font-weight: 700;
    font-size: 0.92rem;
    border: 1px solid transparent;
}
.alert-success { background: var(--success-soft); color: var(--success-text); border-color: rgba(16, 185, 129, 0.35); }
.alert-danger { background: var(--danger-soft); color: var(--danger-text); border-color: rgba(239, 68, 68, 0.35); }
.alert-warning { background: var(--warning-soft); color: var(--warning-text); border-color: rgba(245, 158, 11, 0.35); }
.alert-info { background: var(--info-soft); color: var(--info-text); border-color: rgba(56, 189, 248, 0.35); }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
table.data-table th, table.data-table td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
    text-align: right;
    vertical-align: middle;
}
table.data-table th {
    background: var(--surface-subtle);
    color: var(--muted);
    font-weight: 800;
    font-size: 0.79rem;
    white-space: nowrap;
}
table.data-table tbody tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover { background: var(--row-hover); }

.avatar-circle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.code-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #0c081c;
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.14);
    padding: 6px 11px;
    border-radius: 10px;
    font-family: Consolas, monospace;
    font-weight: 700;
    direction: ltr;
    font-size: 0.85rem;
}

.code-chip .copy-code-btn {
    background: rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
    border-color: rgba(255, 255, 255, 0.18);
}

.code-chip .copy-code-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.chapter-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-subtle);
    margin-bottom: 10px;
}

/* Smart Detached Action Dropdown (Malak style) */
.stu-drop-wrap {
    position: relative;
    display: inline-block;
}

.stu-action-trigger {
    background: rgba(56, 189, 248, 0.12);
    border: 1.5px solid rgba(56, 189, 248, 0.42);
    color: #38bdf8;
    padding: 5px 11px;
    border-radius: 9px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}
.stu-action-trigger:hover,
.stu-drop-wrap.open .stu-action-trigger {
    background: rgba(56, 189, 248, 0.22);
    border-color: #38bdf8;
    box-shadow: 0 4px 14px rgba(56, 189, 248, 0.25);
}
.stu-action-trigger .caret {
    font-size: 0.7rem;
    transition: transform 0.15s ease;
}
.stu-drop-wrap.open .stu-action-trigger .caret {
    transform: rotate(180deg);
}

html.light-theme .stu-action-trigger {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #0284c7;
}
html.light-theme .stu-action-trigger:hover,
html.light-theme .stu-drop-wrap.open .stu-action-trigger {
    background: #dbeafe;
    border-color: #0284c7;
}

.stu-action-menu {
    display: none;
    position: fixed;
    z-index: 99999;
    width: 222px;
    padding: 10px;
    border-radius: 13px;
    background: linear-gradient(155deg, rgba(22, 15, 50, 0.98) 0%, rgba(12, 8, 28, 0.99) 100%);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(56, 189, 248, 0.15);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    overflow-y: auto;
    overflow-x: hidden;
    direction: rtl;
}
.stu-action-menu.open {
    display: block;
    animation: stuDropIn 0.14s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes stuDropIn {
    from { opacity: 0; transform: translateY(-4px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

html.light-theme .stu-action-menu {
    background: #ffffff;
    border-color: #cbd5e1;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
}

.stu-action-menu-inner {
    padding: 7px;
    background: rgba(15, 10, 36, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 9px;
}
html.light-theme .stu-action-menu-inner {
    background: #f8fafc;
    border-color: #e2e8f0;
}

.stu-action-menu-head {
    font-size: 0.78rem;
    color: #38bdf8;
    font-weight: 800;
    text-align: center;
    padding-bottom: 7px;
    margin-bottom: 7px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
html.light-theme .stu-action-menu-head {
    color: #0284c7;
    border-bottom-color: #e2e8f0;
}

.stu-action-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stu-action-list form {
    margin: 0;
    width: 100%;
}

.stu-drop-item {
    width: 100%;
    border: none;
    border-radius: 8px;
    padding: 7px 10px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    text-align: right;
    color: #ffffff;
    cursor: pointer;
    text-decoration: none;
    transition: filter 0.12s ease, transform 0.12s ease;
}
.stu-drop-item:hover {
    filter: brightness(1.08);
    color: #ffffff;
    transform: translateX(-2px);
}
.stu-drop-item.emerald { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }
.stu-drop-item.cyan { background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%); }
.stu-drop-item.amber { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); color: #0f172a; }
.stu-drop-item.crimson { background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); }

/* Modal */
.stu-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(9, 6, 23, 0.74);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 14px;
    overflow-y: auto;
}
.stu-modal-backdrop.open { display: flex; }
.stu-modal {
    width: 100%;
    max-width: 610px;
    max-height: calc(100vh - 28px);
    overflow-y: auto;
    margin: auto;
    background: var(--surface-card);
    border: 1px solid var(--border-strong);
    color: var(--text);
    border-radius: 18px;
    padding: 18px 20px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.stu-modal .card-head {
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.stu-modal .form-grid,
.stu-modal .form-grid-3 {
    gap: 10px 12px;
}
.stu-modal .form-group {
    margin-bottom: 10px;
}
.stu-modal .form-group label {
    margin-bottom: 4px;
    font-size: 0.82rem;
}
.stu-modal .form-control {
    padding: 8px 10px;
    font-size: 0.9rem;
}

@media (max-width: 1180px) {
    .admin-shell { grid-template-columns: 214px 1fr; }
    .admin-content { padding: 16px 16px 36px; }
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-2 { grid-template-columns: 1fr; }
    table.data-table.compact-users th,
    table.data-table.compact-users td {
        padding: 8px 6px;
        font-size: 0.82rem;
    }
    table.data-table.compact-users .avatar-circle {
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
    }
}

@media (max-width: 960px) {
    .admin-shell { grid-template-columns: 1fr; }
    .admin-sidebar { position: static; height: auto; }
    .hero-grid { grid-template-columns: 1fr; }
    .admin-content { padding: 16px 14px 36px; }
}

@media (max-width: 600px) {
    .kpi-grid { grid-template-columns: 1fr; }
}
