:root {
    --ap-sidebar-w: 264px;
    --ap-bg: #f5f7fb;
    --ap-surface: #ffffff;
    --ap-sidebar-bg: #0b1120;
    --ap-sidebar-bg-2: #111827;
    --ap-sidebar-hover: rgba(255, 255, 255, 0.08);
    --ap-primary: #4f46e5;
    --ap-primary-hover: #4338ca;
    --ap-primary-soft: rgba(79, 70, 229, 0.1);
    --ap-accent: #0ea5e9;
    --ap-success: #10b981;
    --ap-danger: #ef4444;
    --ap-warning: #f59e0b;
    --ap-text: #0f172a;
    --ap-muted: #64748b;
    --ap-border: #e5e9f2;
    --ap-radius: 16px;
    --ap-shadow: 0 2px 12px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.03);
    --ap-shadow-lg: 0 18px 40px -12px rgba(15, 23, 42, 0.12);
}

.admin-theme {
    --ap-primary: #6366f1;
    --ap-primary-hover: #4f46e5;
    --ap-primary-soft: rgba(99, 102, 241, 0.12);
}

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

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

body {
    font-family: 'Plus Jakarta Sans', 'Inter', 'Noto Sans Bengali', system-ui, -apple-system, sans-serif;
    background-color: var(--ap-bg);
    color: var(--ap-text);
    -webkit-font-smoothing: antialiased;
    font-size: 14.5px;
    margin: 0;
}

code, pre, .font-monospace {
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important;
}

/* Desktop-Locked Fixed Sidebar Shell (Never scrolls up out of view) */
.ap-layout {
    min-height: 100vh;
    width: 100%;
}

.ap-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--ap-sidebar-w);
    background: linear-gradient(180deg, var(--ap-sidebar-bg) 0%, var(--ap-sidebar-bg-2) 100%);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    z-index: 1050;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.ap-sidebar-header {
    padding: 1.1rem 1.2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.ap-sidebar .brand {
    display: flex;
    align-items: center;
    gap: 0.78rem;
    color: #ffffff;
    text-decoration: none;
    font-weight: 800;
    font-size: 1.08rem;
    letter-spacing: -0.02em;
}

.ap-sidebar .brand-badge {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    background: linear-gradient(135deg, #4f46e5, #0ea5e9);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.4);
    font-size: 0.95rem;
    flex-shrink: 0;
}

.admin-theme .ap-sidebar .brand-badge {
    background: linear-gradient(135deg, #6366f1, #10b981);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.3);
}

.ap-sidebar .brand-sub {
    display: block;
    font-size: 0.64rem;
    font-weight: 600;
    color: #94a3b8;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.ap-sidebar .nav-section {
    padding: 0.9rem 1.15rem 0.3rem;
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: #64748b;
    font-weight: 700;
}

.ap-sidebar .nav-link {
    color: #94a3b8;
    padding: 0.6rem 0.9rem;
    margin: 0.12rem 0.65rem;
    border-radius: 0.72rem;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    font-size: 0.86rem;
    font-weight: 500;
    transition: all 0.18s ease;
}

.ap-sidebar .nav-link i {
    width: 18px;
    text-align: center;
    font-size: 0.92rem;
    opacity: 0.85;
}

.ap-sidebar .nav-link:hover {
    background: var(--ap-sidebar-hover);
    color: #f8fafc;
}

.ap-sidebar .nav-link.active {
    background: linear-gradient(90deg, rgba(79, 70, 229, 0.95), rgba(37, 99, 235, 0.9));
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 6px 18px rgba(79, 70, 229, 0.35);
}

.ap-sidebar .nav-link.active i {
    opacity: 1;
}

.ap-sidebar-footer {
    padding: 0.85rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(15, 23, 42, 0.65);
    flex-shrink: 0;
}

.ap-avatar {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.82rem;
    flex-shrink: 0;
}

/* Main Content Offset by Sidebar Width on Desktop */
.ap-main {
    margin-left: var(--ap-sidebar-w);
    width: calc(100% - var(--ap-sidebar-w));
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ap-topbar {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--ap-border);
    padding: 0.8rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.ap-page-title {
    font-size: 1.02rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    color: var(--ap-text);
    margin: 0;
}

.ap-content {
    padding: 1.5rem;
    flex: 1;
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
    min-width: 0;
}

/* Cards & KPI Surfaces */
.ap-card {
    background: var(--ap-surface);
    border: 1px solid var(--ap-border);
    border-radius: var(--ap-radius);
    box-shadow: var(--ap-shadow);
    min-width: 0;
}

.ap-card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1.1rem;
}

.welcome-banner {
    background: linear-gradient(135deg, #ffffff 0%, #eef2ff 100%);
    border: 1px solid #dbe4ff;
    border-radius: var(--ap-radius);
    padding: 1.25rem 1.45rem;
    box-shadow: var(--ap-shadow);
}

.stat-card {
    border-radius: var(--ap-radius);
    border: 1px solid var(--ap-border);
    background: #ffffff;
    padding: 1.15rem 1.2rem;
    box-shadow: var(--ap-shadow);
    position: relative;
    overflow: hidden;
    height: 100%;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.stat-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--ap-primary), var(--ap-accent));
}

.stat-card.accent-emerald::before { background: linear-gradient(90deg, #10b981, #34d399); }
.stat-card.accent-amber::before { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.stat-card.accent-cyan::before { background: linear-gradient(90deg, #0ea5e9, #38bdf8); }
.stat-card.accent-rose::before { background: linear-gradient(90deg, #f43f5e, #fb7185); }

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--ap-shadow-lg);
}

.stat-value {
    font-size: 1.55rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    line-height: 1.15;
}

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

/* API Key Hero Panel */
.api-hero-card {
    background: linear-gradient(135deg, #0b1120 0%, #1e1b4b 55%, #172554 100%);
    color: #f8fafc;
    border-radius: var(--ap-radius);
    border: 1px solid rgba(99, 102, 241, 0.35);
    box-shadow: 0 18px 36px -14px rgba(30, 27, 75, 0.48);
    position: relative;
    overflow: hidden;
}

.api-hero-card::after {
    content: "";
    position: absolute;
    width: 240px;
    height: 240px;
    top: -100px;
    right: -70px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(56, 189, 248, 0.24), transparent 70%);
    pointer-events: none;
}

.key-box-item {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    padding: 0.95rem;
}

.api-key-pill {
    font-family: 'JetBrains Mono', monospace;
    background: rgba(15, 23, 42, 0.78);
    border: 1px solid rgba(148, 163, 184, 0.3);
    color: #e2e8f0;
    padding: 0.5rem 0.8rem;
    border-radius: 0.65rem;
    font-size: 0.8rem;
    display: block;
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: thin;
}

.chart-wrap {
    position: relative;
    width: 100%;
    height: 230px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.36rem;
    padding: 0.24rem 0.62rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}
.status-pill .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* Clean Icon-Only Table Actions */
.action-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    padding: 0;
    font-size: 0.9rem;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.12s ease;
}
.action-icon:hover {
    transform: translateY(-1px);
}
.action-icon.icon-success { color: #059669; background: rgba(16, 185, 129, 0.12); }
.action-icon.icon-success:hover { background: rgba(16, 185, 129, 0.22); }
.action-icon.icon-primary { color: #4f46e5; background: rgba(79, 70, 229, 0.1); }
.action-icon.icon-primary:hover { background: rgba(79, 70, 229, 0.2); }
.action-icon.icon-danger { color: #dc2626; background: rgba(239, 68, 68, 0.1); }
.action-icon.icon-danger:hover { background: rgba(239, 68, 68, 0.2); }

/* Terminal / Code / JSON Viewer */
.terminal-card {
    background: #0b1120;
    border-radius: 1rem;
    border: 1px solid #1e293b;
    overflow: hidden;
    box-shadow: 0 12px 30px -12px rgba(2, 6, 23, 0.5);
    min-width: 0;
}

.terminal-header {
    background: #111827;
    padding: 0.6rem 0.95rem;
    border-bottom: 1px solid #1e293b;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.terminal-dots {
    display: inline-flex;
    gap: 6px;
}
.terminal-dots span {
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

.code-block {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 0.8rem;
    padding: 0.9rem 1rem;
    font-size: 0.79rem;
    overflow-x: auto;
    border: 1px solid #1e293b;
    max-width: 100%;
}

.json-viewer {
    background: #0b1120;
    color: #cbd5e1;
    border-radius: 0.8rem;
    padding: 0.95rem;
    font-size: 0.79rem;
    line-height: 1.55;
    max-height: 460px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.json-key { color: #7dd3fc; }
.json-str { color: #86efac; }
.json-num { color: #fca5a5; }
.json-bool { color: #fde047; }
.json-null { color: #94a3b8; }

/* Tables */
.table {
    --bs-table-hover-bg: rgba(79, 70, 229, 0.03);
}
.table thead th {
    font-size: 0.71rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    font-weight: 700;
    background-color: #f8fafc !important;
    border-bottom: 1px solid var(--ap-border);
    padding: 0.68rem 0.72rem;
    white-space: nowrap;
}
.table tbody td {
    padding: 0.7rem 0.72rem;
    border-color: #f1f5f9;
}

/* Forms & Buttons */
.form-control, .form-select {
    border-radius: 0.65rem;
    border-color: #cbd5e1;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--ap-primary);
    box-shadow: 0 0 0 3px var(--ap-primary-soft);
}
.btn {
    border-radius: 0.65rem;
    font-weight: 600;
    transition: all 0.15s ease;
}
.btn-primary {
    background-color: var(--ap-primary);
    border-color: var(--ap-primary);
}
.btn-primary:hover, .btn-primary:focus {
    background-color: var(--ap-primary-hover);
    border-color: var(--ap-primary-hover);
}

/* Auth / Hero Background */
.hero-gradient {
    background:
        radial-gradient(circle at 15% 20%, rgba(79, 70, 229, 0.32), transparent 45%),
        radial-gradient(circle at 85% 15%, rgba(14, 165, 233, 0.28), transparent 45%),
        radial-gradient(circle at 50% 90%, rgba(16, 185, 129, 0.14), transparent 45%),
        #0b1120;
}
.auth-glass {
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(16px);
    border-radius: 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 25px 60px -15px rgba(2, 6, 23, 0.55);
}

.ap-mobile-nav {
    display: none;
}

/* Toast Notification */
#apToastContainer {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ap-toast {
    background: #0f172a;
    color: #fff;
    padding: 0.6rem 0.95rem;
    border-radius: 0.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: apSlideIn 0.2s ease;
}
@keyframes apSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Mobile & Tablet Overrides (< 992px) */
@media (max-width: 991.98px) {
    .ap-sidebar {
        width: 270px;
        max-width: 84vw;
        transform: translateX(-105%);
    }
    .ap-sidebar.show {
        transform: translateX(0);
    }
    .ap-sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(2, 6, 23, 0.65);
        backdrop-filter: blur(3px);
        z-index: 1045;
    }
    .ap-sidebar-backdrop.show {
        display: block;
    }
    .ap-main {
        margin-left: 0;
        width: 100%;
    }
    .ap-topbar {
        padding: 0.68rem 0.95rem;
    }
    .ap-content {
        padding: 0.9rem 0.85rem calc(76px + env(safe-area-inset-bottom));
    }
    .ap-mobile-nav {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1030;
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
        border-top: 1px solid var(--ap-border);
        padding: 0.38rem 0.2rem calc(0.42rem + env(safe-area-inset-bottom));
        justify-content: space-around;
        align-items: center;
        box-shadow: 0 -6px 20px rgba(15, 23, 42, 0.06);
    }
    .ap-mobile-nav a {
        flex: 1;
        text-decoration: none;
        color: #64748b;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        font-size: 10px;
        font-weight: 600;
        padding: 0.25rem 0.1rem;
        border-radius: 10px;
    }
    .ap-mobile-nav a i {
        font-size: 0.98rem;
    }
    .ap-mobile-nav a.active {
        color: var(--ap-primary);
    }
    #apToastContainer {
        bottom: 76px;
        right: 12px;
        left: 12px;
    }
}

/* Compact Mobile Typography (< 576px) */
@media (max-width: 575.98px) {
    body {
        font-size: 12.8px;
    }
    h4, .fs-4 { font-size: 1.08rem !important; }
    h5, .fs-5 { font-size: 0.96rem !important; }
    h6, .fs-6 { font-size: 0.86rem !important; }
    .ap-page-title { font-size: 0.92rem; }
    .small, small { font-size: 0.76rem !important; }
    .btn { font-size: 0.79rem; padding: 0.42rem 0.75rem; }
    .btn-sm { font-size: 0.74rem; padding: 0.32rem 0.6rem; }
    .form-control, .form-select { font-size: 0.82rem; padding: 0.44rem 0.7rem; }
    .stat-card {
        padding: 0.78rem 0.82rem;
        border-radius: 13px;
    }
    .stat-value {
        font-size: 1.15rem;
    }
    .stat-icon {
        width: 30px;
        height: 30px;
        border-radius: 9px;
        font-size: 0.82rem;
    }
    .ap-card {
        border-radius: 13px;
    }
    .welcome-banner {
        padding: 0.9rem 0.95rem;
        border-radius: 13px;
    }
    .api-hero-card {
        border-radius: 14px;
    }
    .api-key-pill {
        font-size: 0.72rem;
        padding: 0.42rem 0.65rem;
    }
    .code-block, .json-viewer {
        font-size: 0.72rem;
        padding: 0.75rem;
    }
    .table thead th {
        font-size: 0.65rem;
        padding: 0.55rem 0.55rem;
    }
    .table tbody td {
        font-size: 0.76rem;
        padding: 0.58rem 0.55rem;
    }
    .status-pill {
        font-size: 0.67rem;
        padding: 0.2rem 0.52rem;
    }
    .chart-wrap {
        height: 185px;
    }
}

/* =========================================================
   Sidebar-Free User Top-Navbar Layout (.user-topnav)
   ========================================================= */
.user-topnav .ap-main {
    margin-left: 0;
    width: 100%;
}

.user-topnav .ap-content {
    max-width: 1320px;
}

.ap-usertop {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--ap-border);
    position: sticky;
    top: 0;
    z-index: 1030;
}

.ap-usertop-inner {
    max-width: 1320px;
    margin: 0 auto;
    padding: 0.68rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.ap-usertop .brand {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    text-decoration: none;
    color: var(--ap-text);
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    flex-shrink: 0;
}

.ap-usertop .brand-badge {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, #4f46e5, #0ea5e9);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.9rem;
    box-shadow: 0 6px 14px rgba(79, 70, 229, 0.32);
}

.ap-usertop .brand-sub {
    display: block;
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--ap-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.1;
}

.ap-topnav-pills {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: #f1f5f9;
    padding: 0.26rem;
    border-radius: 999px;
    border: 1px solid var(--ap-border);
}

.ap-topnav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.42rem;
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    font-size: 0.81rem;
    font-weight: 600;
    color: #475569;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.16s ease;
}

.ap-topnav-link:hover {
    color: var(--ap-primary);
    background: rgba(255, 255, 255, 0.75);
}

.ap-topnav-link.active {
    background: var(--ap-primary);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.ap-theme-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.36rem 0.72rem;
    border-radius: 999px;
    border: 1px solid var(--ap-border);
    background: #f8fafc;
    color: var(--ap-text);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.16s ease;
}

.ap-theme-btn:hover {
    border-color: var(--ap-primary);
    color: var(--ap-primary);
}

.ap-theme-icon-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
}

.ap-theme-switch-icons {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.14);
    border: 1px solid var(--ap-border);
}

.ap-theme-switch-icons > span {
    width: 26px;
    height: 26px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    opacity: 0.5;
    transition: all 0.16s ease;
}

.ap-theme-switch-icons > span.active {
    opacity: 1;
    background: var(--ap-surface);
    color: var(--ap-primary);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.16);
}

[data-theme="dark"] .ap-theme-switch-icons {
    background: #000000;
    border-color: #27272a;
}

[data-theme="dark"] .ap-theme-switch-icons > span {
    color: #ffffff;
}

[data-theme="dark"] .ap-theme-switch-icons > span.active {
    background: #ffffff;
    color: #000000;
}

.ap-user-menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.48rem;
    padding: 0.2rem 0.55rem 0.2rem 0.22rem;
    border-radius: 999px;
    border: 1px solid var(--ap-border);
    background: var(--ap-surface);
    color: var(--ap-text);
    font-size: 0.8rem;
    font-weight: 600;
}

.ap-user-toggle-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--ap-border);
    background: var(--ap-surface);
    color: var(--ap-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    transition: all 0.16s ease;
}
.ap-user-toggle-btn:hover {
    border-color: var(--ap-primary);
    color: var(--ap-primary);
}

/* Mobile Slide-Over Sidebar for User Panel */
.ap-user-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1045;
}
.ap-user-sidebar-backdrop.show {
    display: block;
}

.ap-user-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 290px;
    max-width: 85vw;
    background: var(--ap-surface);
    border-left: 1px solid var(--ap-border);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    transform: translateX(105%);
    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: -12px 0 36px rgba(0, 0, 0, 0.25);
}
.ap-user-sidebar.show {
    transform: translateX(0);
}

.ap-user-sidebar-head {
    padding: 0.95rem 1.1rem;
    border-bottom: 1px solid var(--ap-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
}

.ap-user-sidebar-body {
    padding: 1rem 0.9rem;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.ap-user-sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.72rem;
    padding: 0.72rem 0.85rem;
    border-radius: 10px;
    color: var(--ap-text);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    border: 1px solid transparent;
    transition: all 0.16s ease;
}

.ap-user-sidebar-link:hover {
    background: rgba(99, 102, 241, 0.08);
    color: var(--ap-primary);
}

.ap-user-sidebar-link.active {
    background: var(--ap-primary-soft);
    color: var(--ap-primary);
    border-color: rgba(99, 102, 241, 0.22);
}

.ap-user-sidebar-theme {
    margin-top: 0.75rem;
    padding: 0.72rem 0.85rem;
    border-radius: 12px;
    border: 1px solid var(--ap-border);
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    cursor: pointer;
    width: 100%;
    text-align: left;
    color: var(--ap-text);
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.16s ease;
}

.ap-user-sidebar-foot {
    padding: 0.95rem 1rem calc(0.95rem + env(safe-area-inset-bottom));
    border-top: 1px solid var(--ap-border);
}

.citizen-summary-card {
    background: linear-gradient(135deg, #eff6ff, #f8fafc);
    border: 1px solid #bfdbfe;
}

@media (max-width: 991.98px) {
    .ap-usertop-inner {
        padding: 0.65rem 0.95rem;
    }
    .user-topnav .ap-content {
        padding: 1rem 0.9rem 2.25rem;
    }
}

/* =========================================================
   Dark Mode Theme ([data-theme="dark"]) — Obsidian Black
   ========================================================= */
.btn-contrast {
    background-color: #09090b;
    color: #ffffff;
    border: 1px solid #09090b;
}
.btn-contrast:hover {
    background-color: #18181b;
    color: #ffffff;
}
[data-theme="dark"] .btn-contrast {
    background-color: #ffffff;
    color: #000000;
    border-color: #ffffff;
}
[data-theme="dark"] .btn-contrast:hover {
    background-color: #e4e4e7;
    color: #000000;
}

[data-theme="dark"] {
    --ap-bg: #000000;
    --ap-surface: #09090b;
    --ap-text: #ffffff;
    --ap-muted: #d4d4d8;
    --ap-border: #27272a;
    --ap-primary: #ffffff;
    --ap-primary-hover: #e4e4e7;
    --ap-primary-soft: #18181b;
    --ap-accent: #ffffff;
    --ap-shadow: 0 2px 12px rgba(0, 0, 0, 0.7);
    --ap-shadow-lg: 0 18px 40px -12px rgba(0, 0, 0, 0.85);
    --bs-body-color: #ffffff;
    --bs-body-bg: #000000;
    --bs-heading-color: #ffffff;
    --bs-link-color: #ffffff;
    --bs-link-hover-color: #e4e4e7;
    --bs-primary: #ffffff;
    --bs-border-color: #27272a;
}

[data-theme="dark"] body {
    background-color: #000000;
    color: #ffffff;
}

[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4,
[data-theme="dark"] h5,
[data-theme="dark"] h6,
[data-theme="dark"] .stat-value,
[data-theme="dark"] .form-label {
    color: #ffffff;
}

[data-theme="dark"] a:not(.btn):not(.btn-contrast) {
    color: #ffffff;
}

[data-theme="dark"] .ap-usertop {
    background: rgba(0, 0, 0, 0.94);
    border-bottom-color: #1f1f23;
}

[data-theme="dark"] .ap-usertop .brand {
    color: #ffffff;
}

[data-theme="dark"] .ap-usertop .brand-badge {
    background: #18181b;
    border: 1px solid #27272a;
    color: #ffffff;
    box-shadow: none;
}

[data-theme="dark"] .ap-user-toggle-btn {
    background: #09090b;
    border-color: #27272a;
    color: #ffffff;
}

[data-theme="dark"] .ap-user-toggle-btn:hover {
    background: #18181b;
    border-color: #3f3f46;
    color: #ffffff;
}

[data-theme="dark"] .ap-user-sidebar {
    background: #09090b;
    border-left-color: #1f1f23;
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.88);
}

[data-theme="dark"] .ap-user-sidebar-head,
[data-theme="dark"] .ap-user-sidebar-foot {
    border-color: #1f1f23;
}

[data-theme="dark"] .ap-user-sidebar-link {
    color: #ffffff;
}

[data-theme="dark"] .ap-user-sidebar-link:hover {
    background: #141417;
    color: #ffffff;
}

[data-theme="dark"] .ap-user-sidebar-link.active {
    background: #18181b;
    color: #ffffff;
    border-color: #27272a;
}

[data-theme="dark"] .ap-user-sidebar-theme {
    background: #111114;
    border-color: #27272a;
    color: #ffffff;
}

[data-theme="dark"] .ap-topnav-pills {
    background: #09090b;
    border-color: #1f1f23;
}

[data-theme="dark"] .ap-topnav-link {
    color: #d4d4d8;
}

[data-theme="dark"] .ap-topnav-link:hover {
    background: #141417;
    color: #ffffff;
}

[data-theme="dark"] .ap-topnav-link.active {
    background: #18181b;
    color: #ffffff;
    border: 1px solid #27272a;
    box-shadow: none;
}

[data-theme="dark"] .ap-theme-btn,
[data-theme="dark"] .ap-user-menu-btn {
    background: #09090b;
    border-color: #27272a;
    color: #ffffff;
}

[data-theme="dark"] .ap-card,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .api-hero-card,
[data-theme="dark"] .terminal-card,
[data-theme="dark"] .welcome-banner,
[data-theme="dark"] .citizen-summary-card {
    background: #09090b !important;
    background-image: none !important;
    border-color: #1f1f23 !important;
    color: #ffffff !important;
    box-shadow: none !important;
}

[data-theme="dark"] .api-hero-card::after,
[data-theme="dark"] .user-topnav .stat-card::before,
[data-theme="dark"] .stat-card::before {
    opacity: 0;
}

[data-theme="dark"] .key-box-item,
[data-theme="dark"] .api-key-pill,
[data-theme="dark"] .code-block,
[data-theme="dark"] .json-viewer,
[data-theme="dark"] .terminal-header {
    background: #09090b !important;
    border-color: #27272a !important;
    color: #ffffff !important;
}

[data-theme="dark"] .stat-icon,
[data-theme="dark"] .ap-avatar {
    background: #18181b !important;
    border: 1px solid #27272a !important;
    color: #ffffff !important;
}

[data-theme="dark"] .text-primary,
[data-theme="dark"] .text-success,
[data-theme="dark"] .text-danger,
[data-theme="dark"] .text-warning,
[data-theme="dark"] .text-info,
[data-theme="dark"] .text-secondary,
[data-theme="dark"] .text-dark,
[data-theme="dark"] .text-body,
[data-theme="dark"] .text-body-secondary,
[data-theme="dark"] .text-emphasis {
    color: #ffffff !important;
}

[data-theme="dark"] .text-muted,
[data-theme="dark"] .form-text,
[data-theme="dark"] .stat-label,
[data-theme="dark"] .brand-sub {
    color: #d4d4d8 !important;
}

[data-theme="dark"] .bg-primary,
[data-theme="dark"] .bg-success,
[data-theme="dark"] .bg-danger,
[data-theme="dark"] .bg-warning,
[data-theme="dark"] .bg-info,
[data-theme="dark"] .bg-primary-subtle,
[data-theme="dark"] .bg-success-subtle,
[data-theme="dark"] .bg-danger-subtle,
[data-theme="dark"] .bg-warning-subtle,
[data-theme="dark"] .bg-info-subtle,
[data-theme="dark"] .bg-secondary-subtle,
[data-theme="dark"] .status-pill,
[data-theme="dark"] .badge:not(.bg-light) {
    background: #18181b !important;
    color: #ffffff !important;
    border-color: #27272a !important;
}

[data-theme="dark"] .badge.bg-light {
    background: #ffffff !important;
    color: #000000 !important;
    border-color: #ffffff !important;
}

[data-theme="dark"] .border-primary,
[data-theme="dark"] .border-success,
[data-theme="dark"] .border-danger,
[data-theme="dark"] .border-warning,
[data-theme="dark"] .border-info,
[data-theme="dark"] .border-primary-subtle,
[data-theme="dark"] .border-success-subtle,
[data-theme="dark"] .border-danger-subtle,
[data-theme="dark"] .border-warning-subtle,
[data-theme="dark"] .border-info-subtle,
[data-theme="dark"] .border {
    border-color: #27272a !important;
}

[data-theme="dark"] .btn-primary,
[data-theme="dark"] .btn-success,
[data-theme="dark"] .btn-info,
[data-theme="dark"] .btn-warning {
    background: #ffffff !important;
    border-color: #ffffff !important;
    color: #000000 !important;
}

[data-theme="dark"] .btn-primary:hover,
[data-theme="dark"] .btn-success:hover,
[data-theme="dark"] .btn-info:hover,
[data-theme="dark"] .btn-warning:hover {
    background: #e4e4e7 !important;
    border-color: #e4e4e7 !important;
    color: #000000 !important;
}

[data-theme="dark"] .btn-danger,
[data-theme="dark"] .btn-outline-primary,
[data-theme="dark"] .btn-outline-success,
[data-theme="dark"] .btn-outline-danger,
[data-theme="dark"] .btn-outline-warning,
[data-theme="dark"] .btn-outline-info,
[data-theme="dark"] .btn-outline-secondary,
[data-theme="dark"] .btn-outline-dark {
    color: #ffffff !important;
    border-color: #27272a !important;
    background-color: #09090b !important;
}

[data-theme="dark"] .btn-danger:hover,
[data-theme="dark"] .btn-outline-primary:hover,
[data-theme="dark"] .btn-outline-success:hover,
[data-theme="dark"] .btn-outline-danger:hover,
[data-theme="dark"] .btn-outline-warning:hover,
[data-theme="dark"] .btn-outline-info:hover,
[data-theme="dark"] .btn-outline-secondary:hover,
[data-theme="dark"] .btn-outline-dark:hover {
    background-color: #18181b !important;
    color: #ffffff !important;
    border-color: #3f3f46 !important;
}

[data-theme="dark"] .action-icon {
    background: #18181b !important;
    border: 1px solid #27272a !important;
    color: #ffffff !important;
}

[data-theme="dark"] .action-icon:hover {
    background: #ffffff !important;
    border-color: #ffffff !important;
    color: #000000 !important;
}

[data-theme="dark"] .alert {
    background: #09090b !important;
    border-color: #27272a !important;
    color: #ffffff !important;
}

[data-theme="dark"] .progress {
    background-color: #18181b !important;
}

[data-theme="dark"] .progress-bar {
    background-color: #ffffff !important;
}

[data-theme="dark"] .ap-toast {
    background: #09090b;
    border: 1px solid #27272a;
    color: #ffffff;
}

[data-theme="dark"] .ap-mobile-nav {
    background: rgba(9, 9, 11, 0.96);
    border-top-color: #1f1f23;
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.75);
}

[data-theme="dark"] .ap-mobile-nav a {
    color: #d4d4d8;
}

[data-theme="dark"] .ap-mobile-nav a.active {
    color: #ffffff;
}

[data-theme="dark"] .table {
    --bs-table-color: #ffffff;
    --bs-table-bg: transparent;
    --bs-table-hover-color: #ffffff;
    --bs-table-hover-bg: #111114;
    --bs-table-border-color: #1f1f23;
}

[data-theme="dark"] .table thead th {
    background-color: #111114 !important;
    color: #ffffff !important;
    border-bottom-color: #1f1f23;
}

[data-theme="dark"] .table tbody td {
    border-color: #1f1f23;
    color: #ffffff;
}

[data-theme="dark"] .bg-light {
    background-color: #111114 !important;
    color: #ffffff !important;
}

[data-theme="dark"] .bg-white {
    background-color: #09090b !important;
    color: #ffffff !important;
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] .input-group-text {
    background-color: #09090b;
    border-color: #27272a;
    color: #ffffff;
}

[data-theme="dark"] .form-control::placeholder {
    color: #a1a1aa;
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background-color: #09090b;
    border-color: #52525b;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

[data-theme="dark"] .form-control:disabled,
[data-theme="dark"] .form-control[readonly] {
    background-color: #111114;
    color: #ffffff;
}

[data-theme="dark"] .modal-content,
[data-theme="dark"] .dropdown-menu {
    background-color: #09090b;
    border-color: #27272a;
    color: #ffffff;
}

[data-theme="dark"] .dropdown-item {
    color: #ffffff;
}

[data-theme="dark"] .dropdown-item:hover {
    background-color: #18181b;
    color: #ffffff;
}

[data-theme="dark"] .docs-toc-link {
    color: #ffffff;
}

[data-theme="dark"] .docs-toc-link:hover,
[data-theme="dark"] .docs-toc-link.active {
    background: #18181b;
    color: #ffffff;
}

[data-theme="dark"] .docs-mobile-pills a {
    background: #09090b;
    border-color: #27272a;
    color: #ffffff;
}

[data-theme="dark"] code {
    color: #ffffff;
    background: #18181b;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
}

[data-theme="dark"] .page-link {
    background-color: #09090b;
    border-color: #27272a;
    color: #ffffff;
}

[data-theme="dark"] .page-item.active .page-link {
    background-color: #ffffff;
    border-color: #ffffff;
    color: #000000;
}

[data-theme="dark"] .page-item.disabled .page-link {
    background-color: #000000;
    border-color: #18181b;
    color: #71717a;
}
