/* --- 1. SYSTEM VARIABLES --- */
:root { 
    --cyan: #00f2ff; 
    --bg: #000; 
    --card: #0a0a0a; 
    --gold: #d4af37; 
    --text-main: #e0f7fa;
}

/* --- 2. GLOBAL ARCHITECTURE --- */
body { 
    background: var(--bg); 
    color: #fff; 
    font-family: 'Inter', sans-serif; 
    margin: 0; 
    padding-bottom: 140px !important; 
    overflow-x: hidden;
}

.master-layout {
    display: grid;
    grid-template-columns: 260px 1fr 340px;
    gap: 30px;
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
    align-items: flex-start;
}

.left-reserve { min-width: 0; }
.container-main { min-width: 0; }
.authority-sidebar { min-width: 0; }

.authority-sidebar iframe, 
.authority-sidebar video {
    width: 100% !important;
    border: 1px solid #222;
}

/* --- 3. HEADER & NAVIGATION (TRIPLE-ZONE LOCK) --- */
.main-header { 
    background: #000; 
    border-bottom: 2px solid var(--cyan); 
    padding: 10px 2%; 
    display: grid;
    grid-template-columns: 260px 1fr 340px; 
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
}

/* ZONE 1: LOGO (col 1) */
.logo-container { grid-column: 1; justify-self: start; transition: 0.4s; display: flex; align-items: center; }
.logo-shine { height: 35px; width: auto; }
.logo-container:hover .logo-shine { filter: drop-shadow(0 0 12px var(--cyan)) brightness(1.2); transform: scale(1.02); }

/* ZONE 2: NAV LINKS (col 2) */
.nav-links { 
    grid-column: 2;
    display: flex !important; 
    gap: 15px; 
    align-items: center; 
    justify-self: center; 
}
.nav-links a { 
    color: #888; 
    text-decoration: none; 
    font-weight: bold; 
    font-size: 0.75rem; 
    text-transform: uppercase; 
    letter-spacing: 1px; 
    transition: 0.3s;
    white-space: nowrap;
}
.nav-links a:hover, .nav-links a.active { color: var(--cyan); }

/* ZONE 3: CREDITS + HAMBURGER GROUP (col 3) */
.header-right-group {
    grid-column: 3;
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Credits box */
.credits-box {
    border: 1px solid var(--cyan);
    padding: 5px 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8em;
    background: rgba(0,242,255,0.05);
    white-space: nowrap;
    display: inline-block;
    width: fit-content;
}

/* Hamburger — hidden on desktop */
.menu-toggle { 
    display: none; 
    flex-direction: column; 
    gap: 5px; 
    cursor: pointer;
    flex-shrink: 0;
}
.menu-toggle span { width: 25px; height: 2px; background: var(--cyan); display: block; }

/* --- 4. MOBILE OVERRIDES (<=992px) --- */
@media (max-width: 992px) {

    /* Header: single tight row, logo left, group right */
    .main-header { 
        display: flex !important;
        flex-direction: row !important;
        justify-content: flex-start !important;
        align-items: center !important;
        padding: 8px 15px !important;
        gap: 0;
        height: auto !important;
    }

    /* Logo stays left, no grid column needed */
    .logo-container { 
        grid-column: unset; 
        flex-shrink: 0;
    }
    .logo-shine { height: 28px; }

    /* Nav drawer: slides in from right, compact top padding */
    .nav-links {
        grid-column: unset !important;
        display: none !important; 
        position: fixed; top: 0; right: -100%; 
        width: 75vw; max-width: 300px; height: 100vh;
        background: #050505; border-left: 2px solid var(--cyan);
        flex-direction: column !important; align-items: flex-start !important;
        padding: 20px 25px 30px !important; /* was 70px — reduced to remove dead space */
        transition: right 0.4s ease;
        z-index: 1050; box-shadow: -10px 0 30px rgba(0,0,0,0.8); overflow-y: auto;
    }
    .nav-links.mobile-active { display: flex !important; right: 0; }
    .nav-links a { 
        width: 100%; padding: 14px 0; 
        border-bottom: 1px solid #111 !important; 
        border-left: none !important; border-right: none !important; border-top: none !important;
        border-radius: 0 !important; display: block; font-size: 0.85em !important;
    }
    .nav-links.mobile-active::before {
        content: ''; position: fixed; top: 0; left: 0;
        width: 100vw; height: 100vh; background: rgba(0,0,0,0.6); z-index: -1;
    }

    /* Right group: margin-left: auto pushes it all the way right */
    .header-right-group {
        grid-column: unset;
        margin-left: auto;
        display: flex;
        align-items: center;
        gap: 10px;
        flex-shrink: 0;
    }

    /* Credits box: slightly smaller on mobile */
    .credits-box {
        font-size: 0.7em;
        padding: 4px 8px;
    }

    /* Hamburger: visible on mobile */
    .menu-toggle { 
        display: flex; 
        z-index: 1100; 
    }

    /* Layout stacking */
    .master-layout { display: flex !important; flex-direction: column !important; align-items: stretch !important; padding: 10px !important; }
    .left-reserve { display: none; }
    .authority-sidebar { width: 100% !important; order: 2; margin-top: 20px; }
}

/* --- 4. BUTTONS & INPUTS --- */
.btn-glow { 
    background: var(--cyan); 
    color: #000; 
    border: none; 
    padding: 12px 24px; 
    font-weight: bold; 
    cursor: pointer; 
    text-transform: uppercase; 
    font-family: 'JetBrains Mono', monospace;
    transition: 0.4s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}
.btn-glow:hover { background: #fff; box-shadow: 0 0 20px var(--cyan); }

.engine-input {
    width: 100%; padding: 12px; background: #000; border: 1px solid #333;
    color: #fff; box-sizing: border-box; font-family: 'JetBrains Mono', monospace;
}

/* --- 5. ARMY / REFERRAL CENTER --- */
.army-card { 
    background: #050505; 
    border: 1px solid #111; 
    border-top: 3px solid var(--cyan);
    padding: 40px; 
    margin-top: 20px; 
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.army-card h1 { letter-spacing: 4px; color: #fff; margin-top: 0; }

.ref-box { 
    background: #000; border: 1px solid #222; padding: 20px; margin: 25px 0; 
    font-family: 'JetBrains Mono', monospace; font-size: 1.1em;
    color: var(--cyan); word-break: break-all; letter-spacing: 1px;
}

.stats-grid { display: flex; justify-content: center; gap: 40px; margin-top: 30px; }
.stat-item { border-left: 2px solid var(--cyan); padding-left: 20px; text-align: left; }
.stat-val { font-size: 2.2em; font-weight: bold; display: block; color: #fff; }
.stat-label { font-size: 0.7em; color: #444; text-transform: uppercase; letter-spacing: 2px; }

/* --- 6. TOAST NOTIFICATIONS --- */
#copy-toast {
    visibility: hidden;
    min-width: 250px;
    background-color: #000;
    color: var(--cyan);
    text-align: center;
    border: 1px solid var(--cyan);
    padding: 16px;
    position: fixed;
    z-index: 9999;
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8em;
    letter-spacing: 2px;
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.2);
}

#copy-toast.show {
    visibility: visible;
    animation: fadein 0.5s, fadeout 0.5s 2.5s;
}

@keyframes fadein { from {bottom: 0; opacity: 0;} to {bottom: 30px; opacity: 1;} }
@keyframes fadeout { from {bottom: 30px; opacity: 1;} to {bottom: 0; opacity: 0;} }

/* ==========================================================================
   --- 7. FOOTER & TICKER (RESTORING ANIMATION) ---
   ========================================================================== */
.banner-footer { 
    position: fixed; 
    bottom: 0; 
    left: 0; 
    width: 100%; 
    background: #000; 
    border-top: 1px solid #111; 
    z-index: 999; 
    box-shadow: 0 -5px 25px rgba(0,0,0,0.9); 
}

.ticker-wrap { 
    width: 100%; 
    overflow: hidden; 
    padding: 10px 0; 
    white-space: nowrap; 
    border-bottom: 1px solid #111; 
    background: #000;
}

.ticker { 
    display: flex;
    align-items: center;
    padding-left: 100%; 
    animation: ticker-move 50s linear infinite;
    min-width: max-content; 
}

@keyframes ticker-move { 
    0% { transform: translateX(0); } 
    100% { transform: translateX(-100%); } 
}

.ticker-item {
    display: inline-block;
    flex-shrink: 0;
    margin-right: 40px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85em;
    color: #eee;
}

.ticker-ad-unit {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0; 
    margin-right: 50px;
    transition: transform 0.3s ease;
    cursor: pointer;
}

.ticker-ad-unit:hover {
    transform: scale(1.05);
}

.copyright-bar { padding: 10px 0; text-align: center; font-family: 'JetBrains Mono', monospace; font-size: 0.6em; color: #444; background: #050505; }

/* --- 8. VIDEO VAULT GRID --- */
.video-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; padding: 10px; box-sizing: border-box; }
.video-card { background: var(--card); border: 1px solid #222; border-radius: 4px; overflow: hidden; transition: 0.3s; }
.video-container { position: relative; padding-bottom: 56.25%; height: 0; background: #000; }
.video-container iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; }
.video-info { padding: 15px; text-align: left; }
.video-title { font-weight: bold; color: #fff; margin-bottom: 8px; font-size: 0.95em; line-height: 1.4; display: block; }
.video-leader { font-size: 0.75em; color: var(--cyan); text-transform: uppercase; letter-spacing: 1px; }

/* --- 9. RESPONSIVE QUERIES --- */
@media (max-width: 1400px) { .master-layout { grid-template-columns: 1fr 320px; } .left-reserve { display: none; } }
@media (max-width: 1100px) {
    /* NOTE: .main-header and .nav-links are intentionally NOT overridden here.
       The <=992px block above fully controls mobile header to avoid flex-direction conflicts. */
    .master-layout { display: flex !important; flex-direction: column !important; align-items: center !important; padding: 10px !important; }
    .authority-sidebar { width: 100% !important; order: -1; margin-bottom: 20px; }
    .container-main { width: 100% !important; }
    body { padding-bottom: 180px !important; }
}

/* ==========================================================================
   --- 5. ARMY / REFERRAL CENTER (MODERNIZED & OPTIMIZED) ---
   ========================================================================== */

.ref-dashboard-head { 
    display: block;
    width: 100%;
    margin-bottom: 30px; 
    box-sizing: border-box;
}

/* --- 5a. Referral Link Card --- */
.ref-link-card { 
    width: 100%;
    border: 1px solid #111; 
    background: #080808; 
    padding: 30px; 
    border-radius: 4px; 
    border-left: 3px solid var(--cyan); 
    box-sizing: border-box;
    margin-bottom: 20px;
}

.ref-card-prefix {
    color: var(--cyan); 
    font-family: 'JetBrains Mono', monospace; 
    font-size: 0.7em; 
    text-transform: uppercase; 
    letter-spacing: 2px;
}

.ref-link-card h1 { 
    font-family: 'JetBrains Mono', monospace; 
    font-size: 1.4rem; 
    color: #eee; 
    margin: 10px 0; 
}

.ref-card-slogan {
    color: #888; 
    font-size: 0.85em; 
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.ref-link-row { 
    display: flex; 
    align-items: stretch;
    width: 100%;
    max-width: 100%;
    margin-top: 15px; 
    border: 1px solid #222;
    background: #000;
}

.ref-link-box { 
    font-family: 'JetBrains Mono', monospace; 
    background: transparent; 
    color: var(--cyan); 
    padding: 14px; 
    flex-grow: 1; 
    font-size: 0.85em;
    border: none;
    overflow: hidden;
    white-space: nowrap; 
    text-overflow: ellipsis;
    min-width: 0;
}

.share-btn {
    padding: 0 25px; 
    border-radius: 0; 
    text-transform: uppercase; 
    font-size: 0.75em;
    font-family: 'JetBrains Mono', monospace;
    background: var(--cyan);
    color: #000;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    transition: 0.3s;
}

.share-btn:hover {
    background: #fff;
    box-shadow: 0 0 15px var(--cyan);
}

@media (max-width: 1200px) {
    .ref-link-row {
        flex-direction: column;
    }
    .share-btn {
        width: 100%;
        padding: 12px;
        justify-content: center;
    }
}

/* --- 5b. Stats Bar Pills --- */
.stat-bar { 
    display: flex; 
    gap: 20px; 
}

.stat-pill { 
    border: 1px solid #222; 
    background: #0f0f0f; 
    padding: 15px 25px; 
    border-radius: 4px; 
    text-align: center; 
    font-family: 'JetBrains Mono', monospace; 
}

.stat-pill .label { 
    color: #888; 
    font-size: 0.75em; 
    text-transform: uppercase; 
    letter-spacing: 2px; 
    margin-bottom: 5px; 
}

.stat-pill .value { 
    color: #fff; 
    font-size: 1.8em; 
    font-weight: bold; 
}

.architect-gold { color: var(--gold) !important; }
.commission-green { color: #00ff88 !important; }

.stat-pill .value .suffix { 
    font-size: 0.6em; 
    color: var(--gold); 
}

/* --- 5c. Main Referral List Section --- */
.referral-list-section { 
    border: 1px solid #111; 
    background: #080808; 
    border-radius: 4px; 
}

.referral-list-section .section-header { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    padding: 15px 25px; 
    border-bottom: 1px solid #111; 
}

.referral-list-section .section-header h2 { 
    font-family: 'Inter', sans-serif; 
    font-size: 1.1rem; 
    color: #fff; 
    margin: 0; 
}

.referral-count { 
    color: var(--cyan); 
    font-family: 'JetBrains Mono', monospace; 
    font-weight: bold; 
}

.ref-header-counts {
    font-size: 0.85em; 
    color: #888; 
    font-family: 'JetBrains Mono', monospace;
}

/* --- 5d. The Referrals Table --- */
.ref-table-wrapper { 
    width: 100%; 
    overflow-x: auto; 
}

.ref-table { 
    width: 100%; 
    border-collapse: collapse; 
    min-width: 600px; 
}

.ref-table th { 
    text-align: left; 
    padding: 15px 25px; 
    border-bottom: 1px solid #1a1a1a; 
    color: #888; 
    font-size: 0.8em; 
    text-transform: uppercase; 
    letter-spacing: 1px; 
}

.ref-table td { 
    padding: 15px 25px; 
    border-bottom: 1px solid #0f0f0f; 
    color: #ccc; 
    font-size: 0.9em; 
}

.ref-table tr:last-child td { 
    border-bottom: none; 
}

.ref-table tr:hover td { 
    background-color: rgba(0, 242, 255, 0.02); 
}

/* --- 5e. Custom Cell Rendering --- */
.user-cell { 
    display: flex; 
    align-items: center; 
    gap: 12px; 
}

.user-avatar { 
    width: 32px; 
    height: 32px; 
    border-radius: 50%; 
    border: 2px solid #333; 
    object-fit: cover; 
}

.user-avatar.upgraded { 
    border-color: var(--gold); 
}

.user-name { 
    color: #fff; 
    font-weight: bold; 
}

.status-cell { 
    font-family: 'JetBrains Mono', monospace; 
    font-size: 0.85em; 
    display: inline-flex; 
    align-items: center; 
    gap: 6px; 
    padding: 4px 8px; 
    border-radius: 2px; 
}

.status-active-ref { 
    color: #00ff88; 
    background: rgba(0, 255, 136, 0.05); 
    border: 1px solid rgba(0, 255, 136, 0.2); 
}

.status-member-ref { 
    color: #888; 
    background: rgba(136, 136, 136, 0.05); 
    border: 1px solid rgba(136, 136, 136, 0.2); 
}

.tier-cell { 
    font-size: 0.8em; 
    text-transform: uppercase; 
    color: #aaa; 
    letter-spacing: 1px; 
    font-weight: bold; 
}

/* --- 5f. Table Empty State --- */
.ref-empty-state {
    text-align:center; 
    padding: 60px; 
    color: #444; 
    border-top: 1px solid #111;
}

.ref-empty-state i {
    margin-bottom: 20px; 
    display: block;
}

.ref-offline-title {
    font-size: 0.9em; 
    text-transform: uppercase; 
    letter-spacing: 2px;
}

.ref-offline-slogan {
    color: #666; 
    font-size: 0.8em; 
    margin-bottom: 15px;
}

.ref-empty-state .btn-glow {
    text-decoration:none; 
    padding: 10px 20px; 
    font-size: 0.7em;
}

/* ==========================================================================
   --- 9. RESPONSIVE QUERIES (INTEGRATED CORRECTIONS) ---
   ========================================================================== */

@media (max-width: 1100px) {
    .master-layout { 
        display: flex !important; 
        flex-direction: column !important; 
        align-items: center !important; 
        padding: 10px !important; 
    }
    
    .ref-dashboard-head {
        flex-direction: column;
        gap: 20px;
    }
    
    .stat-bar { 
        width: 100%;
        display: flex !important;
        justify-content: center !important;
        flex-wrap: wrap !important;
        gap: 20px !important;
        align-items: center; 
    }

    .stat-pill {
        flex-grow: 0; 
    }
}

/* --- 10. ARCHITECT FRAME BUSTER (PREVENTS DOUBLE MENU) --- */
body.in-surf-frame .main-header,
body.in-surf-frame .authority-sidebar,
body.in-surf-frame .left-reserve,
body.in-surf-frame .banner-footer {
    display: none !important;
}

body.in-surf-frame .master-layout {
    display: block !important;
    padding: 0 !important;
    max-width: 100% !important;
}

body.in-surf-frame {
    padding-bottom: 0 !important;
}