:root {
    --navy: #0f2238;
    --navy-light: #1b3a5c;
    --gold: #c9a227;
    --gold-light: #e3c258;
    --bg: #f4f6f9;
    --sidebar-width: 250px;
}

html, body {
    height: 100%;
    background: var(--bg);
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* ---- Layout ---- */
.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--navy) 0%, var(--navy-light) 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 1040;
    transition: transform .25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 1.25rem 1.25rem 1rem;
    font-size: 1.15rem;
    letter-spacing: .3px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand i { color: var(--gold); font-size: 1.4rem; }
.sidebar-brand strong { color: var(--gold-light); }

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: .15rem;
}

.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    color: rgba(255,255,255,.75);
    text-decoration: none;
    padding: .65rem 1.25rem;
    font-size: .95rem;
    border-left: 3px solid transparent;
    transition: all .15s ease;
}

.sidebar-nav .nav-item:hover { color: #fff; background: rgba(255,255,255,.06); }

.sidebar-nav .nav-item.active {
    color: var(--gold-light);
    background: rgba(201,162,39,.12);
    border-left-color: var(--gold);
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,.08);
}

.api-status { display: flex; align-items: center; gap: .5rem; color: rgba(255,255,255,.7); }

.status-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    background: #9aa5b1;
    display: inline-block;
}
.status-dot.online { background: #28c76f; box-shadow: 0 0 6px rgba(40,199,111,.8); }
.status-dot.offline { background: #ea5455; box-shadow: 0 0 6px rgba(234,84,85,.8); }

.main-area {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid #e6e9ee;
    padding: .6rem 1.5rem;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.content { padding: 1.5rem; flex: 1; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-area { margin-left: 0; }
}

/* ---- Cards & stats ---- */
.card { border: none; border-radius: .75rem; box-shadow: 0 1px 4px rgba(15,34,56,.07); }
.card-header { background: #fff; border-bottom: 1px solid #eef1f5; font-weight: 600; color: var(--navy); border-radius: .75rem .75rem 0 0 !important; }

.stat-card {
    border-radius: .75rem;
    padding: 1.25rem;
    background: #fff;
    box-shadow: 0 1px 4px rgba(15,34,56,.07);
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 100%;
}

.stat-icon {
    width: 52px; height: 52px;
    border-radius: .75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-icon.navy { background: rgba(15,34,56,.1); color: var(--navy); }
.stat-icon.gold { background: rgba(201,162,39,.15); color: var(--gold); }
.stat-icon.green { background: rgba(40,199,111,.12); color: #28c76f; }
.stat-icon.red { background: rgba(234,84,85,.12); color: #ea5455; }

.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--navy); line-height: 1.1; }
.stat-label { color: #8a94a6; font-size: .85rem; }

/* ---- Buttons ---- */
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy-light); color: #fff; }
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { background: var(--gold-light); color: var(--navy); }

/* ---- Tables ---- */
.table thead th {
    background: #f8f9fb;
    color: #5e6b7e;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .4px;
    border-bottom: 1px solid #e6e9ee;
}
.table td { vertical-align: middle; }

/* ---- Auth page ---- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 60%, #2a4a70 100%);
    padding: 1rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 1rem;
    padding: 2.25rem;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.auth-logo { text-align: center; margin-bottom: 1.5rem; color: var(--navy); }
.auth-logo i { font-size: 2.5rem; color: var(--gold); }
.auth-logo h4 { margin-top: .5rem; font-weight: 700; }

/* ---- Misc ---- */
.badge.bg-gold { background: var(--gold) !important; }
.page-title { color: var(--navy); font-weight: 700; }
code.auth-code { background: #f0f3f7; color: var(--navy); padding: .15rem .45rem; border-radius: .35rem; font-size: .85em; }
pre.api-result {
    background: #0f2238;
    color: #9be29b;
    border-radius: .5rem;
    padding: 1rem;
    font-size: .8rem;
    max-height: 320px;
    overflow: auto;
}

/* ---- Live pulse ---- */
.live-pulse-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    background: #ea5455;
    display: inline-block;
    animation: livePulse 1.2s ease-in-out infinite;
}
@keyframes livePulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(234,84,85,.6); }
    50% { opacity: .6; box-shadow: 0 0 0 6px rgba(234,84,85,0); }
}
.badge.bg-live {
    background: #ea5455 !important;
    animation: livePulse 1.2s ease-in-out infinite;
}

/* ---- RTL (Arabic) ---- */
.lang-ar { font-family: "Cairo", "Segoe UI", system-ui, sans-serif; }

[dir="rtl"] .sidebar { left: auto; right: 0; }
[dir="rtl"] .main-area { margin-left: 0; margin-right: var(--sidebar-width); }
[dir="rtl"] .sidebar-nav .nav-item { border-left: none; border-right: 3px solid transparent; }
[dir="rtl"] .sidebar-nav .nav-item.active { border-right-color: var(--gold); }

@media (max-width: 991.98px) {
    [dir="rtl"] .sidebar { transform: translateX(100%); }
    [dir="rtl"] .sidebar.show { transform: translateX(0); }
    [dir="rtl"] .main-area { margin-right: 0; }
}

/* ---- API partner badges ---- */
.badge.bg-navy-soft { background: rgba(15,34,56,.85) !important; color: #e3c258; }
.key-box {
    background: #0f2238;
    color: #9be29b;
    border-radius: .5rem;
    padding: .65rem 1rem;
    font-family: ui-monospace, monospace;
    font-size: .85rem;
    word-break: break-all;
    direction: ltr;
    text-align: left;
}
