:root{--bg:#f6f8fc;--card:#fff;--text:#111827;--muted:#6b7280;--brand:#ff3b30;--line:#e5e7eb}

*{box-sizing:border-box}
html,body{min-height:100%}
body{margin:0;font-family:Inter,Arial,sans-serif;background:var(--bg);color:var(--text)}
a{text-decoration:none;color:inherit}

.topbar{height:68px;background:#fff;border-bottom:1px solid var(--line);display:flex;align-items:center;gap:20px;padding:0 28px;position:sticky;top:0;z-index:10}
.logo{font-size:24px;font-weight:800;color:var(--brand);display:flex;align-items:center;min-width:176px;min-height:60px}
.logo img{width:176px;height:60px;object-fit:contain}
.topbar .logo{white-space:nowrap}
.search{flex:1;max-width:680px}
.search input{width:100%;padding:13px 18px;border:1px solid var(--line);border-radius:999px;background:#f9fafb}

.btn{display:inline-block;padding:11px 17px;border-radius:12px;background:var(--brand);color:#fff;font-weight:700;border:0;cursor:pointer}
.btn-light{background:#fff;color:var(--text);border:1px solid var(--line)}

.layout{display:grid;grid-template-columns:240px 1fr;gap:24px;padding:24px;width:100%}
.sidebar{background:#fff;border:1px solid var(--line);border-radius:22px;padding:18px;height:max-content;position:sticky;top:92px;max-height:calc(100vh - 110px);overflow:auto}
.sidebar a{display:block;padding:12px 14px;border-radius:14px;color:#374151;font-weight:600}
.sidebar a:hover{background:#f3f4f6}

.card{background:#fff;border:1px solid var(--line);border-radius:24px;padding:20px;box-shadow:0 10px 30px rgba(17,24,39,.05)}
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(250px,1fr));gap:18px}
.video-thumb{aspect-ratio:16/9;border-radius:18px;background:linear-gradient(135deg,#eef2ff,#fff1f2);overflow:hidden}
.video-title{font-weight:800;margin:10px 0 5px}
.muted{color:var(--muted);font-size:14px}
.form{display:grid;gap:14px;max-width:760px}
.input,textarea,select{width:100%;padding:13px 14px;border:1px solid var(--line);border-radius:14px;background:#fff}
.table{width:100%;border-collapse:collapse;background:#fff;border-radius:18px;overflow:hidden}
.table th,.table td{padding:13px;border-bottom:1px solid var(--line);text-align:left}
.badge{display:inline-block;padding:5px 9px;border-radius:999px;background:#eef2ff;font-size:12px;font-weight:700}
.player{background:#111827;border-radius:22px;aspect-ratio:16/9;display:flex;align-items:center;justify-content:center;color:#fff}
.ad-slot{border:1px dashed #cbd5e1;background:#fff;border-radius:18px;padding:18px;text-align:center;color:#64748b}
.alert{padding:12px 14px;border-radius:14px;background:#ecfdf5;border:1px solid #bbf7d0;margin-bottom:14px}

.action-row{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
.stat-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:18px}
.page-title{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:18px}
.page-title h1{margin:0}

/* FOOTER FINAL FIX
   Note: body display:flex/order CSS removed because it was pushing footer above header.
   Footer will style correctly wherever site_footer() is printed. For perfect position, call site_footer() after .layout in PHP. */
.site-footer{
    clear:both;
    display:block;
    position:relative;
    z-index:1;
    width:calc(100% - 48px);
    margin:30px 24px 0 24px;
    background:#0f172a;
    color:#fff;
    border:1px solid rgba(255,255,255,.08);
    border-radius:24px;
    padding:28px 24px 18px;
    box-shadow:0 10px 30px rgba(17,24,39,.08);
    text-align:center;
    overflow:hidden;
}
.layout .site-footer{
    grid-column:1/-1;
    width:100%;
    margin:30px 0 0 0;
}
.footer-brand{text-align:center;max-width:850px;margin:0 auto 20px}
.footer-logo{width:176px;height:60px;object-fit:contain;display:block;margin:0 auto 12px}
.footer-title{font-size:26px;font-weight:800;color:#fff;margin:0 0 8px 0;line-height:1.2}
.footer-desc{color:#cbd5e1;font-size:14px;line-height:1.6;margin:0 auto;max-width:760px}

.footer-buttons,.footer-menu{
    display:flex;
    flex-wrap:wrap;
    justify-content:center;
    align-items:center;
    gap:10px;
    margin:24px auto;
    max-width:1120px;
}
.footer-btn,.footer-buttons a,.footer-menu a{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    padding:10px 17px;
    background:#1e293b;
    color:#fff !important;
    text-decoration:none !important;
    border-radius:999px;
    font-size:14px;
    font-weight:700;
    border:1px solid rgba(255,255,255,.10);
    line-height:1;
    transition:.25s ease;
    white-space:nowrap;
}
.footer-btn:hover,.footer-buttons a:hover,.footer-menu a:hover{
    background:var(--brand);
    color:#fff !important;
    transform:translateY(-2px);
    box-shadow:0 8px 20px rgba(255,59,48,.28);
}

.footer-contact,.footer-info{
    display:flex;
    flex-wrap:wrap;
    justify-content:center;
    align-items:center;
    gap:10px 22px;
    font-size:14px;
    color:#cbd5e1;
    margin:0 0 18px;
    text-align:center;
}
.footer-contact a,.footer-info a{color:#93c5fd !important;text-decoration:none !important;font-weight:700}
.footer-contact a:hover,.footer-info a:hover{color:#fff !important}

.footer-bottom,.footer-copy{
    border-top:1px solid rgba(255,255,255,.10);
    margin-top:16px;
    padding-top:15px;
    color:#94a3b8;
    display:flex;
    justify-content:center;
    align-items:center;
    gap:8px 18px;
    flex-wrap:wrap;
    text-align:center;
    font-size:13px;
}
.footer-grid{display:block}
.footer-links{display:none}

/* Legal pages */
.legal-page{max-width:1000px;margin:auto}
.legal-page h1{font-size:38px;margin-top:0}
.legal-page h2{margin-top:28px}
.legal-page p,.legal-page li{line-height:1.75;color:#374151}
.contact-box{display:grid;grid-template-columns:1fr 1fr;gap:18px}

/* v18 analytics dashboard */
.analytics-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:18px;margin-bottom:18px}
.analytics-card{background:#fff;border:1px solid var(--line);border-radius:24px;padding:20px;box-shadow:0 10px 30px rgba(17,24,39,.05)}
.analytics-card h3{margin:0 0 8px;color:#6b7280;font-size:14px}
.analytics-card h1{margin:0;font-size:34px}
.chart-card{background:#fff;border:1px solid var(--line);border-radius:24px;padding:20px;margin-bottom:18px;box-shadow:0 10px 30px rgba(17,24,39,.05)}
.chart-bars{display:flex;align-items:flex-end;gap:10px;height:220px;border-left:1px solid #e5e7eb;border-bottom:1px solid #e5e7eb;padding:10px}
.chart-bar{flex:1;min-width:18px;background:linear-gradient(180deg,#ff6b5f,#ff3b30);border-radius:10px 10px 0 0;position:relative}
.chart-bar span{position:absolute;bottom:-28px;left:50%;transform:translateX(-50%);font-size:11px;color:#6b7280;white-space:nowrap}
.chart-bar strong{position:absolute;top:-24px;left:50%;transform:translateX(-50%);font-size:11px;color:#111827}
.split-grid{display:grid;grid-template-columns:1.3fr .7fr;gap:18px}
.mini-list{display:grid;gap:12px}
.mini-item{display:flex;align-items:center;gap:12px;border-bottom:1px solid #eef2f7;padding-bottom:12px}
.mini-thumb{width:96px;aspect-ratio:16/9;background:#eef2ff;border-radius:12px;background-size:cover;background-position:center;flex-shrink:0}
.progress{height:10px;background:#f3f4f6;border-radius:99px;overflow:hidden}
.progress div{height:100%;background:#ff3b30;border-radius:99px}

@media(max-width:1000px){
    .split-grid{grid-template-columns:1fr}
    .chart-bars{overflow-x:auto}
}
@media(max-width:900px){
    .contact-box{grid-template-columns:1fr}
    .site-footer{width:calc(100% - 24px);margin:18px 12px 0;padding:26px 14px 16px}
    .layout .site-footer{width:100%;margin:18px 0 0}
    .footer-title{font-size:22px}
}
@media(max-width:800px){
    .layout{grid-template-columns:1fr}
    .sidebar{position:relative;top:auto}
    .topbar{padding:0 14px}
    .search{display:none}
}
@media(max-width:600px){
    .footer-buttons,.footer-menu{gap:8px;margin:18px auto}
    .footer-btn,.footer-buttons a,.footer-menu a{padding:9px 13px;font-size:13px}
    .footer-contact,.footer-info{flex-direction:column;gap:8px}
}
