:root {
    color-scheme: light;
    --bg: #f6f8fb;
    --surface: #ffffff;
    --ink: #162033;
    --muted: #667085;
    --line: #dce3ee;
    --primary: #0f766e;
    --primary-strong: #115e59;
    --accent: #d99a2b;
    --blue: #2563eb;
    --danger: #c2410c;
    --success: #15803d;
    --shadow: 0 22px 60px rgba(22, 32, 51, .12);
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #10141c;
    --surface: #171d28;
    --ink: #f4f7fb;
    --muted: #9aa6b8;
    --line: #2b3444;
    --primary: #2dd4bf;
    --primary-strong: #14b8a6;
    --accent: #f5b84b;
    --blue: #60a5fa;
    --shadow: 0 22px 60px rgba(0, 0, 0, .28);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: "Cairo", "Inter", system-ui, sans-serif;
    background: var(--bg);
    color: var(--ink);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select {
    font: inherit;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 24px;
    padding: 14px clamp(18px, 4vw, 56px);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(16px);
}
.topbar .brand {
    grid-column: 2; /* Center */
    justify-self: center;
}
.topbar .header-actions {
    grid-column: 3; /* Left side in RTL */
    justify-self: end;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: max-content;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-family: "Inter", sans-serif;
    font-weight: 800;
}

.brand strong,
.brand small {
    display: block;
    line-height: 1.2;
}

.brand small,
.eyebrow,
.lead,
.section-title p,
.side-panel p,
.footer,
label,
.form-note,
.risk-box p,
.quote-card span,
.trade-ticket span,
.stats-grid span,
.dashboard-top span {
    color: var(--muted);
}

.nav-links,
.header-actions,
.hero-actions,
.trust-strip,
.terminal-head,
.trade-ticket,
.dashboard-top,
.stats-grid,
.row {
    display: flex;
    align-items: center;
}

/* Sidebar Menu Styles */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: 0.3s ease;
}
.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}
.sidebar-menu {
    position: fixed;
    top: 0;
    right: -300px;
    width: 300px;
    height: 100vh;
    background: var(--surface);
    z-index: 1000;
    box-shadow: var(--shadow);
    transition: 0.3s ease;
    display: flex;
    flex-direction: column;
}
.sidebar-menu.active {
    right: 0;
}
.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--line);
}
.sidebar-links {
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 15px;
    overflow-y: auto;
}
.sidebar-links a {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--ink);
    padding: 10px;
    border-radius: 8px;
    transition: background 0.2s;
}
.sidebar-links a:hover {
    background: var(--line);
}
.sidebar-links [data-icon] {
    color: var(--primary);
}

.header-actions {
    gap: 10px;
}

.btn,
.icon-button {
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    transition: .2s ease;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 18px;
    border-radius: 8px;
    font-weight: 800;
}

.btn-icon {
    display: none;
}

.btn:hover,
.icon-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(22, 32, 51, .12);
}

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

.btn.secondary {
    background: color-mix(in srgb, var(--primary) 10%, var(--surface));
    border-color: color-mix(in srgb, var(--primary) 32%, var(--line));
    color: var(--primary-strong);
}

.btn.ghost {
    background: transparent;
}

.btn.large {
    min-height: 52px;
    padding-inline: 26px;
}

.btn.compact {
    min-height: 36px;
}

.btn.full {
    width: 100%;
}

.icon-button {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 8px;
}

main {
    overflow: hidden;
}

.hero {
    min-height: calc(100vh - 73px);
    display: grid;
    grid-template-columns: minmax(0, .95fr) minmax(360px, 1.05fr);
    align-items: center;
    gap: clamp(28px, 5vw, 70px);
    padding: clamp(38px, 6vw, 74px) clamp(18px, 5vw, 72px);
    background:
        linear-gradient(120deg, color-mix(in srgb, var(--primary) 12%, transparent), transparent 40%),
        radial-gradient(circle at 20% 15%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 28%);
}

.eyebrow {
    margin: 0 0 10px;
    font-family: "Inter", sans-serif;
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    max-width: 740px;
    margin-bottom: 18px;
    font-size: clamp(2.4rem, 6vw, 5.8rem);
    line-height: .98;
}

h2 {
    margin-bottom: 12px;
    font-size: clamp(1.8rem, 3.2vw, 3.2rem);
    line-height: 1.08;
}

h3 {
    font-size: 1.25rem;
}

.lead {
    max-width: 650px;
    font-size: clamp(1rem, 1.5vw, 1.22rem);
    line-height: 1.9;
}

.hero-actions {
    gap: 12px;
    flex-wrap: wrap;
    margin: 26px 0 22px;
}

.trust-strip {
    flex-wrap: wrap;
    gap: 10px;
}

.trust-strip span {
    padding: 9px 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: color-mix(in srgb, var(--surface) 74%, transparent);
    font-weight: 800;
}

.terminal-panel,
.dashboard-shell,
.side-panel,
.form-panel,
.login-panel,
.account-card,
.quote-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.terminal-panel {
    overflow: hidden;
}

.terminal-head {
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
    font-family: "Inter", sans-serif;
}

.terminal-head strong {
    color: var(--success);
}

.chart-wrap {
    height: 330px;
    padding: 18px;
}

#priceChart {
    width: 100%;
    height: 100%;
}

.trade-ticket {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding: 16px;
    border-top: 1px solid var(--line);
}

.trade-ticket div {
    min-width: 0;
}

.trade-ticket strong,
.trade-ticket span {
    display: block;
    direction: ltr;
    text-align: right;
}

.buy,
.sell {
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    color: #fff;
    font-weight: 900;
}

.buy {
    background: var(--success);
}

.sell {
    background: var(--danger);
}

.band,
.workspace,
.portal {
    padding: clamp(44px, 7vw, 86px) clamp(18px, 5vw, 72px);
}

.section-title {
    max-width: 760px;
    margin-bottom: 26px;
}

.quote-grid,
.account-grid,
.portal-grid {
    display: grid;
    gap: 16px;
}

.quote-grid {
    grid-template-columns: repeat(5, minmax(150px, 1fr));
}

.quote-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px;
    box-shadow: none;
}

.quote-card strong,
.quote-card span {
    display: block;
    direction: ltr;
    text-align: left;
}

.quote-card b.up,
.positive {
    color: var(--success);
}

.quote-card b.down,
.negative {
    color: var(--danger);
}

.workspace {
    display: grid;
    grid-template-columns: .78fr 1.22fr;
    gap: 20px;
}

.side-panel {
    padding: 28px;
    box-shadow: none;
}

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

.feature-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
}

.dashboard-shell {
    padding: 20px;
}

.dashboard-top {
    justify-content: space-between;
    gap: 12px;
}

.dashboard-top strong,
.dashboard-top span {
    display: block;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 18px 0;
}

.stats-grid div {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.stats-grid strong {
    display: block;
    margin-top: 8px;
    direction: ltr;
    text-align: right;
    font-size: 1.35rem;
}

.positions {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.row {
    display: grid;
    grid-template-columns: 1.3fr repeat(3, 1fr);
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}

.row:last-child {
    border-bottom: 0;
}

.row.head {
    background: color-mix(in srgb, var(--primary) 8%, var(--surface));
    color: var(--muted);
    font-weight: 800;
}

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

.account-card {
    padding: 24px;
    box-shadow: none;
}

.account-card > strong {
    display: block;
    margin: 8px 0 20px;
    color: var(--primary-strong);
    font-size: 2.4rem;
    direction: ltr;
    text-align: right;
}

dl,
dd {
    margin: 0;
}

.account-card dl {
    display: grid;
    gap: 12px;
    margin-bottom: 20px;
}

.account-card dl div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

dt {
    color: var(--muted);
}

dd {
    font-weight: 800;
    text-align: left;
}

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

.form-panel,
.login-panel {
    padding: 24px;
    box-shadow: none;
}

label {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
    font-weight: 800;
}

input,
select {
    width: 100%;
    min-height: 48px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: color-mix(in srgb, var(--surface) 88%, var(--bg));
    color: var(--ink);
}

.form-note {
    margin: 12px 0 0;
}

.risk-box {
    margin-top: 18px;
    padding: 16px;
    border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
    border-radius: 8px;
    background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}

.risk-box p {
    margin-bottom: 0;
    line-height: 1.8;
}

.footer {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 24px clamp(18px, 5vw, 72px);
    border-top: 1px solid var(--line);
    background: var(--surface);
}

[data-icon] {
    width: 20px;
    height: 20px;
    display: inline-block;
}

.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: color-mix(in srgb, var(--surface) 95%, transparent);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--line);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 0;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--muted);
    gap: 6px;
}

.bottom-nav a:hover,
.bottom-nav a:active {
    color: var(--primary);
}

@media (max-width: 1100px) {
    .nav-links {
        display: none;
    }

    .hero,
    .workspace,
    .portal-grid {
        grid-template-columns: 1fr;
    }

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

.rank-1 { background: #ffd700; color: #000; }
.rank-2 { background: #c0c0c0; color: #000; }
.rank-3 { background: #cd7f32; color: #000; }

/* ------------------- SLIDER ------------------- */
.slideshow-container { position: relative; overflow: hidden; width: 100%; border-radius: 12px; }
.hero-slide { 
    display: none; 
    animation-name: slideX; 
    animation-duration: 0.8s; 
    padding: 15px; 
    border-radius: 12px;
    background-size: cover;
    background-position: center;
    position: relative;
    z-index: 1;
}
.hero-slide::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to left, rgba(0,0,0,0.8), rgba(0,0,0,0.2));
    z-index: -1;
    border-radius: 12px;
}
@keyframes slideX { from {transform: translateX(100%); opacity: 0;} to {transform: translateX(0); opacity: 1;} }
.dot { height: 10px; width: 10px; margin: 0 4px; background-color: var(--line); border-radius: 50%; display: inline-block; cursor: pointer; transition: background-color 0.3s ease; }
.dot.active, .dot:hover { background-color: var(--primary); transform: scale(1.3); }

/* ------------------- PARTNER GRID ------------------- */

/* ------------------- MOBILE HEADER ------------------- */
@media (max-width: 768px) {
    .topbar {
        padding-inline: 15px;
    }
    .brand > span:not(.brand-mark) { display: none !important; }
    
    .header-actions {
        gap: 6px;
    }
    .header-actions .btn-text { display: none !important; }
    .header-actions .btn-icon { display: block !important; margin: 0 !important; width: 18px; height: 18px; }
    .header-actions .btn, .header-actions .icon-button { 
        padding: 0 !important; 
        min-width: 36px !important; 
        max-width: 36px !important;
        min-height: 36px !important;
        max-height: 36px !important;
        width: 36px !important;
        height: 36px !important;
        border-radius: 8px;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        overflow: hidden;
    }
    .header-actions [data-icon] {
        width: 18px;
        height: 18px;
    }
    .account-grid { grid-template-columns: 1fr !important; }
}

/* ------------------- NEW SECTIONS ------------------- */
.courses-grid, .competitions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 5%;
}

.course-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.course-img {
    height: 180px;
    background-size: cover;
    background-position: center;
}
.course-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex: 1;
}
.course-content h3 { margin-bottom: 10px; }
.course-content p { color: var(--text); font-size: 0.95rem; margin-bottom: 20px; flex: 1; }

.comp-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    position: relative;
    overflow: hidden;
}
.comp-status {
    position: absolute;
    top: 15px; left: -30px;
    background: var(--primary);
    color: white;
    font-size: 0.75rem;
    font-weight: 800;
    padding: 4px 30px;
    transform: rotate(-45deg);
}
.comp-card.finished .comp-status { background: #95a5a6; }
.comp-card.upcoming .comp-status { background: #f39c12; }
.comp-card h3 { margin-top: 10px; margin-bottom: 20px; text-align: center; font-size: 1.4rem; }
.comp-details {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 15px;
    background: var(--bg);
    border-radius: 8px;
}
.comp-details div { display: flex; flex-direction: column; align-items: center; }
.comp-details span { font-size: 0.8rem; color: var(--text); }
.comp-details strong { font-size: 1.1rem; color: var(--ink); }

.leaderboard-wrap {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 5%;
    overflow-x: auto;
}
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}
.leaderboard-table th, .leaderboard-table td {
    padding: 16px 20px;
    text-align: right;
    border-bottom: 1px solid var(--border);
}
.leaderboard-table th {
    background: var(--bg);
    font-size: 0.9rem;
    color: var(--text);
}
.leaderboard-table tr:last-child td { border-bottom: none; }
.profit-up { color: #00a651; font-weight: bold; }

@media (max-width: 720px) {
    .bottom-nav {
        display: flex;
    }
    
    body {
        padding-bottom: 64px;
    }

    .hero {
        min-height: auto;
    }

    .hero-slide {
        background-position: right center !important;
        background-size: cover !important;
    }

    .terminal-panel {
        min-width: 0;
    }

    .trade-ticket,
    .stats-grid,
    .account-grid,
    .quote-grid {
        grid-template-columns: 1fr;
    }

    .row {
        grid-template-columns: 1.2fr .8fr .8fr .9fr;
        font-size: .88rem;
        padding-inline: 10px;
    }

    .footer {
        flex-direction: column;
        padding-bottom: 84px; /* extra space above bottom nav */
    }
}
