/* ============================================================
   AfriSound Design System — Global Stylesheet
   Brand: Navy #0A2342 · Accent Orange #FF6B00 · Charcoal surfaces
   Bootstrap 5 consumed via pinned CDN + this brand layer.
   No Node.js build pipeline.
   ============================================================ */

:root,
[data-theme='dark'] {
    --af-navy: #0A2342;
    --af-navy-deep: #061a33;
    --af-charcoal: #14161a;
    --af-charcoal-soft: #1d2026;
    --af-surface: #191c22;
    --af-surface-raised: #20242c;
    --af-border: #2b303b;
    --af-border-soft: #23272f;
    --af-text: #f4f6f9;
    --af-text-muted: #9aa3b0;
    --af-accent: #FF6B00;
    --af-accent-hover: #ff8429;
    --af-accent-soft: rgba(255, 107, 0, 0.14);
    --af-danger: #e5484d;
    --af-success: #30a46c;
    --af-warning: #f5a623;
    --af-info: #3e63dd;
    --af-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
    --af-radius: 14px;
    --af-radius-sm: 10px;
}

[data-theme='light'] {
    --af-charcoal: #f6f7f9;
    --af-charcoal-soft: #eef0f3;
    --af-surface: #ffffff;
    --af-surface-raised: #ffffff;
    --af-border: #e2e6eb;
    --af-border-soft: #e9edf1;
    --af-text: #101828;
    --af-text-muted: #5b6472;
    --af-navy-deep: #f6f7f9;
    --af-shadow: 0 8px 24px rgba(16, 24, 40, 0.08);
}

/* ---------- Base ---------- */
html { scroll-behavior: smooth; }

body.af-body {
    background: var(--af-charcoal);
    color: var(--af-text);
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.af-main { padding-bottom: 120px; /* room for mini-player */ }
@media (min-width: 992px) { .af-main { padding-bottom: 100px; } }

.skip-link {
    position: absolute; left: -9999px; top: 0;
    background: var(--af-accent); color: #fff;
    padding: .6rem 1rem; z-index: 2000; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* Visible focus for accessibility */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
    outline: 2px solid var(--af-accent);
    outline-offset: 2px;
    border-radius: 4px;
}

.text-muted, .af-muted { color: var(--af-text-muted) !important; }
.af-text-accent { color: var(--af-accent); }

.bg-af-surface { background: var(--af-surface); }
.border-af { border-color: var(--af-border) !important; }

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 { font-weight: 700; letter-spacing: -0.02em; color: var(--af-text); }

.af-hero-title {
    font-size: clamp(2rem, 4.5vw, 3.2rem);
    font-weight: 800;
    line-height: 1.1;
}
.af-section-title { font-size: clamp(1.15rem, 2vw, 1.4rem); font-weight: 700; }
.af-eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: .72rem;
    font-weight: 700;
    color: var(--af-accent);
}

/* ---------- Buttons ---------- */
.btn-af {
    --bs-btn-bg: var(--af-accent);
    --bs-btn-border-color: var(--af-accent);
    --bs-btn-color: #fff;
    --bs-btn-hover-bg: var(--af-accent-hover);
    --bs-btn-hover-border-color: var(--af-accent-hover);
    --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: var(--af-accent-hover);
    --bs-btn-active-color: #fff;
    font-weight: 600;
    border-radius: var(--af-radius-sm);
    padding: .55rem 1.25rem;
}
.btn-af-outline {
    --bs-btn-color: var(--af-text);
    --bs-btn-border-color: var(--af-border);
    --bs-btn-hover-bg: var(--af-surface-raised);
    --bs-btn-hover-color: var(--af-text);
    --bs-btn-hover-border-color: var(--af-accent);
    font-weight: 600;
    border-radius: var(--af-radius-sm);
    padding: .55rem 1.25rem;
}
.btn-af-ghost {
    --bs-btn-color: var(--af-text-muted);
    --bs-btn-hover-color: var(--af-text);
    --bs-btn-hover-bg: var(--af-surface-raised);
    border-radius: var(--af-radius-sm);
}
.btn-af-danger {
    --bs-btn-bg: var(--af-danger);
    --bs-btn-border-color: var(--af-danger);
    --bs-btn-color: #fff;
    --bs-btn-hover-bg: #c43a3f;
    --bs-btn-hover-border-color: #c43a3f;
    --bs-btn-hover-color: #fff;
    font-weight: 600;
    border-radius: var(--af-radius-sm);
    padding: .55rem 1.25rem;
}
.btn-af-success {
    --bs-btn-bg: var(--af-success);
    --bs-btn-border-color: var(--af-success);
    --bs-btn-color: #fff;
    --bs-btn-hover-bg: #2a8d5f;
    --bs-btn-hover-border-color: #2a8d5f;
    --bs-btn-hover-color: #fff;
    font-weight: 600;
    border-radius: var(--af-radius-sm);
    padding: .55rem 1.25rem;
}

/* ---------- Cards ---------- */
.af-card {
    background: var(--af-surface);
    border: 1px solid var(--af-border-soft);
    border-radius: var(--af-radius);
    overflow: hidden;
}
.af-card-hover { transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
.af-card-hover:hover {
    transform: translateY(-3px);
    border-color: var(--af-border);
    box-shadow: var(--af-shadow);
}

.af-artwork {
    position: relative;
    aspect-ratio: 1 / 1;
    background: linear-gradient(135deg, var(--af-navy) 0%, var(--af-charcoal-soft) 100%);
    border-radius: var(--af-radius-sm);
    overflow: hidden;
}
.af-artwork img { width: 100%; height: 100%; object-fit: cover; display: block; }
.af-artwork .af-artwork-placeholder {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    color: var(--af-text-muted);
    font-size: 2rem;
}

.af-artwork-play {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(6, 26, 51, 0.55);
    opacity: 0;
    transition: opacity .18s ease;
    border: none;
    color: #fff;
}
.af-artwork-play svg, .af-artwork-play .af-icon { width: 44px; height: 44px; fill: currentColor; }
@media (hover: hover) {
    .af-card-hover:hover .af-artwork-play { opacity: 1; }
}
.af-artwork-play:focus-visible { opacity: 1; }

.af-badge-premium {
    position: absolute; top: .5rem; left: .5rem;
    background: var(--af-accent); color: #fff;
    font-size: .68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .06em;
    padding: .2rem .5rem; border-radius: 6px;
}

.af-card-title {
    font-weight: 600; font-size: .95rem;
    color: var(--af-text);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: .15rem;
}
.af-card-meta { font-size: .8rem; color: var(--af-text-muted); }

/* Horizontal scroll rail for home rails */
.af-rail {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    padding-bottom: .5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--af-border) transparent;
}
.af-rail > * { flex: 0 0 clamp(150px, 42vw, 200px); scroll-snap-align: start; }
@media (min-width: 768px) { .af-rail > * { flex: 0 0 200px; } }
.af-rail::-webkit-scrollbar { height: 6px; }
.af-rail::-webkit-scrollbar-thumb { background: var(--af-border); border-radius: 3px; }

/* ---------- Header / Nav ---------- */
.af-header {
    background: var(--af-navy-deep);
    border-bottom: 1px solid var(--af-border-soft);
    position: sticky; top: 0; z-index: 1030;
}
.af-header .navbar-brand { color: var(--af-text); font-weight: 800; letter-spacing: -0.03em; }
.af-header .af-brand-accent { color: var(--af-accent); }
.af-header .nav-link { color: var(--af-text-muted); font-weight: 500; }
.af-header .nav-link:hover, .af-header .nav-link.active { color: var(--af-text); }
.af-header .nav-link.active::after {
    content: '';
    display: block; height: 2px; margin-top: .15rem;
    background: var(--af-accent); border-radius: 2px;
}

.af-nav-search {
    background: var(--af-surface);
    border: 1px solid var(--af-border);
    color: var(--af-text);
    border-radius: 999px;
    padding: .45rem 1rem .45rem 2.4rem;
    font-size: .9rem;
    width: 220px;
}
.af-nav-search::placeholder { color: var(--af-text-muted); }
.af-nav-search:focus {
    background: var(--af-surface-raised);
    border-color: var(--af-accent);
    box-shadow: none;
    outline: none;
    width: 280px;
    color: var(--af-text);
}
.af-search-wrap { position: relative; }
.af-search-wrap .af-icon-search {
    position: absolute; left: .9rem; top: 50%;
    transform: translateY(-50%);
    width: 16px; height: 16px;
    fill: var(--af-text-muted);
    pointer-events: none;
}

/* ---------- Forms ---------- */
.form-control, .form-select {
    background: var(--af-surface);
    border: 1px solid var(--af-border);
    color: var(--af-text);
    border-radius: var(--af-radius-sm);
    padding: .55rem .8rem;
}
.form-control:focus, .form-select:focus {
    background: var(--af-surface-raised);
    border-color: var(--af-accent);
    box-shadow: none;
    color: var(--af-text);
}
.form-control::placeholder { color: var(--af-text-muted); }
.form-label { font-weight: 600; font-size: .88rem; color: var(--af-text); }
.form-text { color: var(--af-text-muted); }
.invalid-feedback { color: var(--af-danger); }
.is-invalid { border-color: var(--af-danger) !important; }

/* ---------- Alerts / States ---------- */
.af-alert {
    border-radius: var(--af-radius-sm);
    border: 1px solid var(--af-border);
    padding: .75rem 1rem;
    font-size: .9rem;
}
.af-alert-danger { background: rgba(229, 72, 77, .12); border-color: rgba(229, 72, 77, .35); color: #ff8f92; }
[data-theme='light'] .af-alert-danger { color: #b52b2f; }
.af-alert-success { background: rgba(48, 164, 108, .12); border-color: rgba(48, 164, 108, .35); color: #6fd8a4; }
[data-theme='light'] .af-alert-success { color: #1d7a4d; }
.af-alert-warning { background: rgba(245, 166, 35, .12); border-color: rgba(245, 166, 35, .35); color: #ffca70; }
[data-theme='light'] .af-alert-warning { color: #9a6a10; }
.af-alert-info { background: rgba(62, 99, 221, .12); border-color: rgba(62, 99, 221, .35); color: #9db4f5; }
[data-theme='light'] .af-alert-info { color: #2a4bb0; }

.af-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--af-text-muted);
}
.af-empty .af-icon { width: 48px; height: 48px; fill: var(--af-border); margin-bottom: .75rem; }
.af-empty h3 { font-size: 1.05rem; color: var(--af-text); }

.af-loading-spinner {
    width: 28px; height: 28px;
    border: 3px solid var(--af-border);
    border-top-color: var(--af-accent);
    border-radius: 50%;
    animation: af-spin .7s linear infinite;
    display: inline-block;
}
@keyframes af-spin { to { transform: rotate(360deg); } }

/* ---------- Episode rows ---------- */
.af-episode-row {
    display: flex; gap: .9rem; align-items: center;
    padding: .8rem 1rem;
    background: var(--af-surface);
    border: 1px solid var(--af-border-soft);
    border-radius: var(--af-radius-sm);
    transition: border-color .15s ease, background .15s ease;
}
.af-episode-row:hover { border-color: var(--af-border); }
.af-episode-row.is-playing { border-color: var(--af-accent); background: var(--af-accent-soft); }
.af-episode-num {
    flex: 0 0 auto;
    font-weight: 700; font-size: .85rem;
    color: var(--af-text-muted);
    width: 2.2rem; text-align: center;
}
.af-equalizer { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.af-equalizer span {
    width: 3px; background: var(--af-accent); border-radius: 2px;
    animation: af-eq .9s ease-in-out infinite;
}
.af-equalizer span:nth-child(2) { animation-delay: .25s; }
.af-equalizer span:nth-child(3) { animation-delay: .5s; }
@keyframes af-eq { 0%, 100% { height: 30%; } 50% { height: 100%; } }

/* ---------- Player ---------- */
.af-mini-player {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--af-navy-deep);
    border-top: 1px solid var(--af-border);
    z-index: 1040;
    display: none; /* shown by JS when active */
    box-shadow: 0 -8px 24px rgba(0, 0, 0, .3);
}
.af-mini-player.is-active { display: block; }

.af-progress-bar {
    height: 4px;
    background: var(--af-border);
    border-radius: 2px;
    position: relative;
    cursor: pointer;
    touch-action: none;
}
.af-progress-fill {
    position: absolute; inset: 0 auto 0 0;
    background: var(--af-accent);
    border-radius: 2px;
    width: 0%;
}
.af-progress-bar .af-progress-thumb {
    position: absolute; top: 50%;
    transform: translate(-50%, -50%);
    width: 12px; height: 12px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .4);
    opacity: 0;
    transition: opacity .15s ease;
    pointer-events: none;
}
.af-progress-bar:hover .af-progress-thumb,
.af-progress-bar.is-scrubbing .af-progress-thumb { opacity: 1; }

.af-player-btn {
    background: transparent; border: none;
    color: var(--af-text); cursor: pointer;
    width: 40px; height: 40px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
    transition: background .15s ease;
}
.af-player-btn:hover { background: var(--af-surface-raised); }
.af-player-btn .af-icon { width: 20px; height: 20px; fill: currentColor; }
.af-player-btn.is-primary {
    width: 48px; height: 48px;
    background: var(--af-accent); color: #fff;
}
.af-player-btn.is-primary:hover { background: var(--af-accent-hover); }
.af-player-btn.is-primary .af-icon { width: 22px; height: 22px; }
.af-player-btn:disabled { opacity: .45; cursor: not-allowed; }

.af-expanded-player {
    background: var(--af-navy-deep);
    border-bottom: 1px solid var(--af-border);
    display: none;
}
.af-expanded-player.is-open { display: block; }

.af-player-queue {
    display: none;
    background: var(--af-navy-deep);
    border: 1px solid var(--af-border);
}
.af-player-queue.is-open { display: block; }
.af-player-queue [data-player-queue-list] li a {
    display: block;
    padding: .5rem .75rem;
    border-radius: .375rem;
    color: var(--af-text);
    text-decoration: none;
}
.af-player-queue [data-player-queue-list] li a:hover {
    background: var(--af-surface-raised);
}
.af-player-queue [data-player-queue-list] li a.is-active {
    color: var(--af-accent);
    font-weight: 600;
}

.af-volume-slider {
    -webkit-appearance: none; appearance: none;
    width: 90px; height: 4px;
    background: var(--af-border); border-radius: 2px;
    cursor: pointer;
}
.af-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px; height: 12px;
    background: #fff; border-radius: 50%;
}
.af-volume-slider::-moz-range-thumb {
    width: 12px; height: 12px;
    background: #fff; border: none; border-radius: 50%;
}

/* ---------- Pagination ---------- */
.af-pagination .page-link {
    background: var(--af-surface);
    border-color: var(--af-border);
    color: var(--af-text);
}
.af-pagination .page-item.active .page-link {
    background: var(--af-accent);
    border-color: var(--af-accent);
    color: #fff;
}
.af-pagination .page-item.disabled .page-link { color: var(--af-text-muted); }
.af-pagination .page-link:hover { background: var(--af-surface-raised); color: var(--af-text); }

/* ---------- Modals ---------- */
.modal-content {
    background: var(--af-surface);
    border: 1px solid var(--af-border);
    border-radius: var(--af-radius);
    color: var(--af-text);
}
.modal-header, .modal-footer { border-color: var(--af-border); }
.btn-close { filter: invert(1) grayscale(100%); }
[data-theme='light'] .btn-close { filter: none; }

/* ---------- Creator / Staff layouts ---------- */
.af-sidebar {
    background: var(--af-navy-deep);
    border-right: 1px solid var(--af-border-soft);
    min-height: calc(100vh - 56px);
    padding: 1.25rem .75rem;
}
.af-sidebar .af-sidebar-link {
    display: flex; align-items: center; gap: .6rem;
    padding: .55rem .75rem;
    color: var(--af-text-muted);
    text-decoration: none;
    border-radius: var(--af-radius-sm);
    font-weight: 500; font-size: .92rem;
    transition: background .15s ease, color .15s ease;
}
.af-sidebar .af-sidebar-link:hover { background: var(--af-surface-raised); color: var(--af-text); }
.af-sidebar .af-sidebar-link.active {
    background: var(--af-accent-soft);
    color: var(--af-accent);
    font-weight: 600;
}
@media (max-width: 991px) {
    .af-sidebar {
        min-height: auto;
        border-right: none;
        border-bottom: 1px solid var(--af-border-soft);
    }
}

/* ---------- Stat cards (dashboard) ---------- */
.af-stat {
    background: var(--af-surface);
    border: 1px solid var(--af-border-soft);
    border-radius: var(--af-radius);
    padding: 1.1rem 1.25rem;
}
.af-stat .af-stat-value { font-size: 1.7rem; font-weight: 800; color: var(--af-text); }
.af-stat .af-stat-label { font-size: .8rem; color: var(--af-text-muted); text-transform: uppercase; letter-spacing: .08em; }

/* ---------- Tables ---------- */
.table { color: var(--af-text); }
.table > :not(caption) > * > * {
    background: transparent;
    color: var(--af-text);
    border-color: var(--af-border-soft);
}
.table thead th {
    color: var(--af-text-muted);
    font-size: .75rem; text-transform: uppercase; letter-spacing: .07em;
    border-bottom: 1px solid var(--af-border) !important;
}

/* ---------- Status pills ---------- */
.af-pill {
    display: inline-block;
    font-size: .72rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .05em;
    padding: .22rem .6rem; border-radius: 999px;
}
.af-pill-success { background: rgba(48, 164, 108, .15); color: #6fd8a4; }
.af-pill-warning { background: rgba(245, 166, 35, .15); color: #ffca70; }
.af-pill-danger { background: rgba(229, 72, 77, .15); color: #ff8f92; }
.af-pill-info { background: rgba(62, 99, 221, .15); color: #9db4f5; }
.af-pill-muted { background: var(--af-surface-raised); color: var(--af-text-muted); }
[data-theme='light'] .af-pill-success { color: #1d7a4d; }
[data-theme='light'] .af-pill-warning { color: #9a6a10; }
[data-theme='light'] .af-pill-danger { color: #b52b2f; }
[data-theme='light'] .af-pill-info { color: #2a4bb0; }

/* ---------- Footer ---------- */
.af-footer {
    background: var(--af-navy-deep);
    border-top: 1px solid var(--af-border-soft);
    color: var(--af-text-muted);
    margin-top: 3rem;
}
.af-footer h6 { color: var(--af-text); font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; }
.af-footer a { color: var(--af-text-muted); text-decoration: none; }
.af-footer a:hover { color: var(--af-accent); }

/* ---------- Utilities ---------- */
.af-clamp-1, .af-clamp-2, .af-clamp-3 {
    display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden;
}
.af-clamp-1 { -webkit-line-clamp: 1; }
.af-clamp-2 { -webkit-line-clamp: 2; }
.af-clamp-3 { -webkit-line-clamp: 3; }

.af-safe-desc { word-break: break-word; overflow-wrap: anywhere; }

/* Offline / offline banner */
.af-offline-banner {
    background: var(--af-warning);
    color: #402d00;
    text-align: center;
    font-size: .85rem; font-weight: 600;
    padding: .4rem 1rem;
    display: none;
}
.af-offline-banner.is-visible { display: block; }

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

/* ============================================================
   Admin / Creator Panel — Left Nav Dashboard
   ============================================================ */

body.af-admin { display: flex; flex-direction: column; min-height: 100vh; }

.af-topbar {
    background: var(--af-surface);
    border-bottom: 1px solid var(--af-border-soft);
    position: sticky;
    top: 0;
    z-index: 100;
}
.af-topbar-inner { min-height: 64px; }
.af-admin-brand { gap: 10px; }
.af-admin-brand-text { font-size: 1.25rem; letter-spacing: -0.01em; }
.af-admin-logo { width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; }
.af-topbar-search { max-width: 560px; }
.af-topbar-search-input { background: var(--af-surface-raised); border: 1px solid var(--af-border-soft); color: var(--af-text); padding-left: 2.5rem; border-radius: var(--af-radius-sm); }
.af-topbar-search-input::placeholder { color: var(--af-text-muted); }
.af-topbar-search-input:focus { background: var(--af-surface); border-color: var(--af-accent); box-shadow: none; }
.af-topbar-actions { min-width: 220px; justify-content: flex-end; }

.btn-af-icon { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; padding: 0; border-radius: var(--af-radius-sm); background: var(--af-surface-raised); color: var(--af-text); border: 1px solid var(--af-border-soft); }
.btn-af-icon:hover { background: var(--af-surface); border-color: var(--af-border); }
.af-icon { width: 20px; height: 20px; }
.af-icon-sm { width: 16px; height: 16px; }
.af-notify-badge {
    position: absolute; top: 2px; right: 2px;
    width: 10px; height: 10px; background: var(--af-danger); color: #fff;
    border-radius: 50%; font-size: 8px; font-weight: 700; display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--af-surface);
}
.af-topbar-avatar { width: 34px; height: 34px; }
.af-avatar { object-fit: cover; width: 100%; height: 100%; }
.af-dropdown { border: 1px solid var(--af-border); background: var(--af-surface); }
.af-dropdown .dropdown-item { color: var(--af-text); padding: .55rem 1.25rem; }
.af-dropdown .dropdown-item:hover { background: var(--af-surface-raised); color: var(--af-text); }
.af-dropdown .dropdown-item.text-danger:hover { background: rgba(229, 72, 77, .1); color: var(--af-danger); }
.af-dropdown .dropdown-divider { border-color: var(--af-border-soft); margin: .5rem 0; }

.af-admin-wrap { display: flex; flex: 1; min-height: 0; }
.af-admin-main { flex: 1; min-width: 0; overflow: hidden; background: var(--af-charcoal); padding-bottom: 100px; }

.af-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--af-surface);
    border-right: 1px solid var(--af-border-soft);
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 64px);
}
.af-sidebar-inner { display: flex; flex-direction: column; height: 100%; overflow-y: auto; }
.af-sidebar-list { padding: 1rem 0; }
.af-sidebar-group { margin: 0; }
.af-sidebar-label { color: var(--af-text-muted); padding: 0 1.25rem .5rem; display: block; }
.af-sidebar-link {
    display: flex; align-items: center; gap: 10px;
    padding: .6rem 1.25rem; color: var(--af-text-muted); text-decoration: none;
    font-size: .92rem; font-weight: 500; border-radius: 0 var(--af-radius) var(--af-radius) 0;
    margin: 0 1rem; transition: all .15s ease;
    position: relative;
}
.af-sidebar-link svg { flex-shrink: 0; width: 18px; height: 18px; }
.af-sidebar-link:hover { background: var(--af-surface-raised); color: var(--af-text); }
.af-sidebar-link.active { background: var(--af-accent-soft); color: var(--af-accent); font-weight: 600; }
.af-sidebar-brand { display: none; }
.btn-af-sidebar-toggle { padding: .4rem .8rem; }

@media (max-width: 991px) {
    .af-sidebar { position: fixed; left: 0; top: 64px; bottom: 0; z-index: 200; transform: translatex(-100%); transition: transform .25s ease; border-right: none; border-bottom: none; max-height: none; }
    .af-sidebar.open { transform: translatex(0); }
    .af-admin-main { padding-top: 0; }
    .btn-af-sidebar-toggle { display: inline-flex !important; }
}

.af-dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.af-dash-stat {
    background: var(--af-surface);
    border: 1px solid var(--af-border-soft);
    border-radius: var(--af-radius);
    padding: 1.25rem 1.5rem;
    display: flex; align-items: center; justify-content: space-between;
}
.af-dash-stat .af-dash-value { font-size: 1.75rem; font-weight: 800; color: var(--af-text); line-height: 1.2; }
.af-dash-stat .af-dash-label { font-size: .8rem; color: var(--af-text-muted); text-transform: uppercase; letter-spacing: .08em; display: block; margin-top: .25rem; }
.af-dash-stat .af-dash-icon {
    width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem;
}
.af-dash-stat .af-dash-trend { font-size: .8rem; font-weight: 600; margin-top: .25rem; display: block; }
.af-dash-trend.up { color: var(--af-success); }
.af-dash-trend.down { color: var(--af-danger); }
.af-dash-trend.neutral { color: var(--af-text-muted); }

.af-sparkline { height: 32px; display: flex; align-items: flex-end; gap: 3px; margin-top: .5rem; }
.af-sparkline .af-spark-bar {
    flex: 1; height: 100%; background: var(--af-accent-soft); border-radius: 2px 2px 0 0;
}
.af-sparkline .af-spark-bar.fill-accent { background: var(--af-accent); }
.af-sparkline .af-spark-bar.fill-success { background: var(--af-success); }

.af-donut { position: relative; width: 120px; height: 120px; }
.af-donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.af-donut .af-donut-ring { fill: none; stroke-width: 10; stroke-linecap: round; }
.af-donut-center {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    font-size: 1.1rem; font-weight: 800; color: var(--af-text);
}
.af-donut-center small { font-size: .7rem; font-weight: 500; color: var(--af-text-muted); margin-top: 2px; }

.af-section-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.af-section-header .af-section-title { margin: 0; }

.af-dash-card { background: var(--af-surface); border: 1px solid var(--af-border-soft); border-radius: var(--af-radius); overflow: hidden; }
.af-dash-card .af-card-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--af-border-soft); display: flex; justify-content: space-between; align-items: center; }

/* ============================================================
   Admin Console — fixed left rail + analytics dashboard
   ============================================================ */

.af-admin-rail {
    --af-rail-width: 272px;
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--af-rail-width);
    background: var(--af-surface);
    border-right: 1px solid var(--af-border-soft);
    display: flex;
    flex-direction: column;
    z-index: 300;
    transition: transform .25s ease;
}
.af-admin-rail-inner { flex: 1; overflow-y: auto; overflow-x: hidden; padding: .5rem 0 1rem; }
.af-admin-rail-brand {
    display: flex; align-items: center; gap: .65rem;
    padding: 1.15rem 1.35rem 1.15rem;
    border-bottom: 1px solid var(--af-border-soft);
    text-decoration: none;
    flex-shrink: 0;
}
.af-admin-rail-brand .af-admin-brand-text { font-size: 1.3rem; font-weight: 800; color: var(--af-text); }
.af-admin-rail-footer { border-top: 1px solid var(--af-border-soft); padding: .85rem 1rem; flex-shrink: 0; }

.af-rail-group { padding: .35rem 0 .85rem; }
.af-rail-label {
    display: block;
    font-size: .68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .12em;
    color: var(--af-text-muted);
    padding: .9rem 1.5rem .45rem;
    opacity: .8;
}
.af-rail-link {
    display: flex; align-items: center; gap: .7rem;
    margin: .1rem .75rem;
    padding: .6rem .85rem;
    border-radius: var(--af-radius-sm);
    color: var(--af-text-muted);
    font-size: .92rem; font-weight: 500;
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
}
.af-rail-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.af-rail-link:hover { background: var(--af-surface-raised); color: var(--af-text); }
.af-rail-link.active {
    background: var(--af-accent-soft);
    color: var(--af-accent);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--af-accent);
}
.af-rail-link .af-rail-count {
    margin-left: auto;
    font-size: .68rem; font-weight: 700;
    background: var(--af-danger); color: #fff;
    border-radius: 999px; padding: .1rem .42rem;
    line-height: 1.4;
}
.af-rail-link .af-rail-chip {
    margin-left: auto;
    font-size: .66rem; font-weight: 700;
    background: var(--af-surface-raised); color: var(--af-text-muted);
    border-radius: 999px; padding: .1rem .45rem;
}

/* Shell offset so the fixed rail never covers content */
body.af-admin { padding-left: 272px; }
body.af-admin .af-topbar { margin-left: 0; }
.af-admin-shell { min-height: 100vh; display: flex; flex-direction: column; }
.af-admin-main { flex: 1; padding: 1.75rem 2rem 3rem; background: var(--af-charcoal); }

.af-admin-topbar {
    background: var(--af-surface);
    border-bottom: 1px solid var(--af-border-soft);
    position: sticky; top: 0; z-index: 200;
}
.af-admin-topbar-inner { min-height: 68px; display: flex; align-items: center; gap: 1rem; padding: 0 2rem; }
.af-admin-crumbs { display: flex; align-items: center; gap: .5rem; color: var(--af-text-muted); font-size: .85rem; flex-wrap: wrap; }
.af-admin-crumbs a { color: var(--af-text-muted); text-decoration: none; }
.af-admin-crumbs a:hover { color: var(--af-accent); }
.af-admin-crumbs .af-crumb-current { color: var(--af-text); font-weight: 600; }
.af-admin-search { flex: 1; max-width: 520px; }
.af-admin-search .form-control,
.af-admin-search .input-group-text {
    background: var(--af-charcoal-soft);
    border-color: var(--af-border-soft);
    color: var(--af-text);
}
.af-admin-search .form-control::placeholder { color: var(--af-text-muted); }
.af-admin-search .form-control:focus { background: var(--af-charcoal-soft); border-color: var(--af-accent); box-shadow: none; }
.af-admin-profile { display: flex; align-items: center; gap: .65rem; text-decoration: none; }
.af-admin-profile-name { color: var(--af-text); font-weight: 600; font-size: .88rem; line-height: 1.15; }
.af-admin-profile-role { color: var(--af-text-muted); font-size: .74rem; line-height: 1.15; }
.af-admin-profile img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 2px solid var(--af-border); }

/* KPI cards */
.af-kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.15rem; }
.af-kpi {
    background: var(--af-surface);
    border: 1px solid var(--af-border-soft);
    border-left: 3px solid var(--af-accent);
    border-radius: var(--af-radius);
    padding: 1.25rem 1.35rem;
    display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
}
.af-kpi.is-info { border-left-color: var(--af-info); }
.af-kpi.is-danger { border-left-color: var(--af-danger); }
.af-kpi.is-success { border-left-color: var(--af-success); }
.af-kpi.is-warning { border-left-color: var(--af-warning); }
.af-kpi-label { font-size: .82rem; color: var(--af-text-muted); font-weight: 500; display: block; }
.af-kpi-value { font-size: 1.75rem; font-weight: 800; line-height: 1.15; margin: .35rem 0 .4rem; color: var(--af-text); letter-spacing: -.02em; }
.af-kpi.is-info .af-kpi-value { color: #5aa9f5; }
.af-kpi.is-danger .af-kpi-value { color: #ff8f92; }
.af-kpi.is-success .af-kpi-value { color: #4cd08a; }
.af-kpi.is-warning .af-kpi-value { color: #ffc45c; }
.af-kpi-trend { font-size: .78rem; font-weight: 600; color: var(--af-text-muted); }
.af-kpi-trend.up { color: var(--af-success); }
.af-kpi-trend.down { color: var(--af-danger); }
.af-kpi-icon {
    width: 52px; height: 52px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; color: #fff;
}
.af-kpi-icon svg { width: 24px; height: 24px; }
.af-kpi-icon.is-info { background: linear-gradient(140deg, #4fc3f7, #2f7fe0); }
.af-kpi-icon.is-danger { background: linear-gradient(140deg, #ff8a9b, #e5484d); }
.af-kpi-icon.is-success { background: linear-gradient(140deg, #5ee2a0, #2e9e63); }
.af-kpi-icon.is-warning { background: linear-gradient(140deg, #ffc46b, #f5a623); }

/* Panels */
.af-panel {
    background: var(--af-surface);
    border: 1px solid var(--af-border-soft);
    border-radius: var(--af-radius);
    overflow: hidden;
    height: 100%;
    display: flex; flex-direction: column;
}
.af-panel-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; padding: 1.25rem 1.4rem 1rem;
}
.af-panel-title { font-size: 1.02rem; font-weight: 700; margin: 0; color: var(--af-text); }
.af-panel-body { padding: 0 1.4rem 1.4rem; flex: 1; }
.af-panel-menu {
    border: 0; background: transparent; color: var(--af-text-muted);
    padding: .15rem .35rem; border-radius: 6px; line-height: 1;
}
.af-panel-menu:hover { background: var(--af-surface-raised); color: var(--af-text); }

/* Legend chips */
.af-legend { display: flex; gap: .5rem; flex-wrap: wrap; }
.af-legend-item {
    display: inline-flex; align-items: center; gap: .4rem;
    background: var(--af-surface-raised);
    border: 1px solid var(--af-border-soft);
    border-radius: 999px;
    padding: .18rem .65rem;
    font-size: .76rem; font-weight: 600; color: var(--af-text-muted);
}
.af-legend-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* Bar chart */
.af-chart {
    position: relative;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    align-items: end;
    gap: .35rem;
    height: 260px;
    padding: 0 .25rem 0 2.6rem;
}
.af-chart-grid {
    position: absolute; inset: 0 0 26px 2.6rem;
    display: flex; flex-direction: column; justify-content: space-between;
    pointer-events: none;
}
.af-chart-grid span {
    border-top: 1px dashed var(--af-border-soft);
    font-size: .68rem; color: var(--af-text-muted);
    position: relative;
    top: -.45rem;
}
.af-chart-group { display: flex; align-items: flex-end; justify-content: center; gap: 4px; height: 100%; position: relative; z-index: 1; }
.af-chart-bar {
    width: 12px; border-radius: 6px 6px 0 0;
    min-height: 4px;
    transition: filter .15s ease;
}
.af-chart-bar:hover { filter: brightness(1.25); }
.af-chart-bar.is-primary { background: linear-gradient(180deg, #6aa8ff, #3e7ef0); }
.af-chart-bar.is-secondary { background: linear-gradient(180deg, #ffd166, #f5a623); }
.af-chart-label {
    position: absolute; bottom: -22px; left: 50%; transform: translateX(-50%);
    font-size: .7rem; color: var(--af-text-muted); white-space: nowrap;
}
.af-chart-foot {
    display: grid; grid-template-columns: repeat(3, 1fr);
    border-top: 1px solid var(--af-border-soft);
    margin-top: 1.75rem;
}
.af-chart-foot > div { padding: 1rem .5rem; text-align: center; border-right: 1px solid var(--af-border-soft); }
.af-chart-foot > div:last-child { border-right: 0; }
.af-chart-foot strong { display: block; font-size: 1.05rem; font-weight: 800; color: var(--af-text); }
.af-chart-foot span { font-size: .76rem; color: var(--af-text-muted); }

/* Donut + product list */
.af-donut-wrap { display: flex; justify-content: center; padding: .5rem 0 1.25rem; }
.af-donut-lg { position: relative; width: 210px; height: 210px; }
.af-donut-lg svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.af-donut-lg .af-donut-seg { fill: none; stroke-width: 34; }
.af-product-list { list-style: none; margin: 0; padding: 0; }
.af-product-list li {
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    padding: .7rem 0;
    border-bottom: 1px solid var(--af-border-soft);
    font-size: .88rem; color: var(--af-text);
}
.af-product-list li:last-child { border-bottom: 0; }
.af-count-badge {
    min-width: 34px; text-align: center;
    font-size: .72rem; font-weight: 700;
    padding: .18rem .5rem; border-radius: 999px; color: #fff;
}
.af-count-badge.is-green { background: #22a55c; }
.af-count-badge.is-red { background: #e5484d; }
.af-count-badge.is-blue { background: #3e7ef0; }
.af-count-badge.is-yellow { background: #f5a623; }

/* Admin data tables */
.af-admin-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.af-admin-table thead th {
    background: var(--af-surface-raised);
    color: var(--af-text-muted);
    font-size: .72rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .07em;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--af-border-soft);
    white-space: nowrap;
}
.af-admin-table thead th:first-child { border-top-left-radius: var(--af-radius-sm); }
.af-admin-table thead th:last-child { border-top-right-radius: var(--af-radius-sm); }
.af-admin-table tbody td {
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--af-border-soft);
    font-size: .88rem; color: var(--af-text);
    vertical-align: middle;
}
.af-admin-table tbody tr:hover { background: var(--af-surface-raised); }
.af-admin-table tbody tr:last-child td { border-bottom: 0; }
.af-admin-thumb {
    width: 40px; height: 40px; border-radius: 8px;
    object-fit: cover; background: var(--af-surface-raised);
    display: block;
}
.af-admin-thumb-placeholder {
    width: 40px; height: 40px; border-radius: 8px;
    background: linear-gradient(135deg, var(--af-navy) 0%, var(--af-charcoal-soft) 100%);
    display: flex; align-items: center; justify-content: center;
    color: var(--af-text-muted);
}
.af-admin-thumb-placeholder svg { width: 18px; height: 18px; }
.af-admin-cell-strong { font-weight: 600; }

/* Page heading block */
.af-page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.af-page-head h1 { font-size: clamp(1.25rem, 2vw, 1.6rem); margin: 0; }
.af-page-head p { margin: .25rem 0 0; color: var(--af-text-muted); font-size: .88rem; }

/* Mobile: rail collapses into an off-canvas drawer */
@media (max-width: 1199px) {
    body.af-admin { padding-left: 0; }
    .af-admin-rail { transform: translateX(-100%); box-shadow: var(--af-shadow); }
    .af-admin-rail.open { transform: translateX(0); }
    .af-admin-main { padding: 1.25rem 1rem 3rem; }
    .af-admin-topbar-inner { padding: 0 1rem; }
}
@media (max-width: 767px) {
    .af-chart { height: 200px; padding-left: 2.2rem; }
    .af-chart-grid { left: 2.2rem; }
    .af-chart-bar { width: 8px; }
    .af-donut-lg { width: 170px; height: 170px; }
}
.af-rail-backdrop {
    position: fixed; inset: 0; background: rgba(6, 26, 51, .55);
    z-index: 290; display: none;
}
.af-rail-backdrop.is-visible { display: block; }
