/**
 * @fileoverview Core Structural Layout & Grid
 */
#app-container { 
    width: 100%; 
    height: 100vh; 
    position: relative; 
    display: flex; 
    flex-direction: column; 
}

.hidden {
    display: none !important;
}

.screen { 
    height: 100%; 
    width: 100%; 
    display: flex; 
    flex-direction: column; 
}

/* Fixed Header */
.main-header {
    height: 64px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    z-index: 100;
    border-bottom: 1px solid var(--border);
    background: var(--surface-elevated);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* Scrollable Main Area */
.content-viewport {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Smooth iOS scrolling */
        padding-bottom: 24px; /* Small bottom padding to separate content from footer when footer is static */
}

/* Footer: static in document flow (not fixed) */
.app-footer {
    position: static !important; /* ensure it flows with the page and does not overlay content */
    width: 100%;
    z-index: auto;
    border-top: 1px solid var(--border);
    background: var(--surface-elevated-strong);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.bottom-nav {
    display: flex;
    justify-content: space-around;
    padding: 10px 10px var(--safe-area-bottom) 10px;
}

/* Responsive footer adjustments */
@media (max-width: 480px) {
    .bottom-nav {
        padding: 8px 8px 16px 8px;
        gap: 6px;
    }
    .nav-label { font-size: 0.65rem; }
    .nav-icon { font-size: 1.3rem; }
}

@media (min-width: 1200px) {
    /* On large screens the bottom nav should center its items and increase spacing */
    .bottom-nav { justify-content: center; gap: 28px; padding: 12px 24px; }
}

/* Sidebar Standard Panel Position Configuration */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 300px;
    height: 100vh;
    background: var(--card-bg, #1c1c1e);
    border-right: 1px solid var(--border, rgba(255,255,255,0.08));
    z-index: 5000;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transform: translateX(0); /* Fully open when visible */
    will-change: transform;
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Ensure the hidden utility completely slides the container back off-screen */
.sidebar.hidden {
    transform: translateX(-100%) !important;
    box-shadow: none;
}

/* Background Dimmer for Sidebar */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: opacity 0.28s ease, visibility 0.28s ease;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.overlay.hidden { 
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.sidebar-header { 
    padding: 16px 20px 12px 20px; 
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    flex-shrink: 0;
}

.user-profile-brief { 
    display: flex; 
    align-items: center; 
    gap: 16px; 
}

.sidebar-links { 
    padding: 8px 0 16px 0; 
    flex: 1; 
    display: flex; 
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}


/* --- ADMIN SIDEBAR OPTIMIZATION --- */
#admin-screen {
    display: flex;
    height: 100vh; /* Locks the main screen height so the sidebar can scroll */
    overflow: hidden;
}

/* Two-column admin layout: sidebar (1) / main content (3) */
#admin-screen > div {
    display: flex;
    gap: 24px;
    align-items: stretch;
    width: 100%;
    flex: 1 1 auto; /* fill remaining vertical space under header */
    overflow: hidden;
}

#admin-screen aside {
    flex: 1 0 260px; /* sidebar column: flexible but with sensible min */
    max-width: 320px;
    min-width: 220px;
    display: flex;
    flex-direction: column !important;
    position: relative !important;
    left: auto !important;
    top: auto !important;
    width: auto !important;
}

#admin-main-viewport, #admin-screen main, .admin-view {
    flex: 3 1 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Ensure the exit button container sits at the bottom of the sidebar column */
#admin-screen aside > div[style],
#admin-screen aside .logout-row {
    margin-top: auto !important;
    width: 100%;
}

#exit-admin-btn { width: 100%; }

/* --- BULLETPROOF ADMIN SIDEBAR SIZING --- */
#admin-screen aside {
    /* Sidebar default sizing: flexible but constrained */
    flex: 0 0 260px;
    min-width: 220px;
    max-width: 320px;

    transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    background: rgba(255, 255, 255, 0.03);
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    overflow-x: hidden;
    white-space: nowrap;
    position: relative;
    z-index: 100;

    /* Preserved Layout Properties */
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
}

/* The Collapsed 'Icon-Only' State */
#admin-screen aside.collapsed {
    /* Force the shrink */
    width: 76px !important;
    min-width: 76px !important;
    max-width: 76px !important;
    flex: 0 0 76px !important;
}

/* CSS Magic: Hides the text aggressively */
#admin-screen aside.collapsed .admin-tab {
    font-size: 0 !important; 
    justify-content: center !important;
    padding: 14px 0 !important;
}

#admin-screen aside.collapsed .admin-tab i {
    font-size: 1.4rem !important; 
    margin: 0 !important;
}

/* Optimized Admin Tabs */
.admin-tab {
    display: flex;
    align-items: center;
    gap: 10px; /* Closer icon-to-text spacing */
    width: 100%;
    padding: 10px 14px; /* Reduced internal padding */
    font-size: 0.85rem; /* Smaller, cleaner text */
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: 8px;
    text-align: left;
    cursor: pointer;
    
    /* Premium Hover Dynamics */
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) !important;
    border: 1px solid transparent;
    margin-bottom: 4px;
}

.admin-tab i {
    font-size: 1.15rem;
}

.admin-tab:hover {
    background: rgba(0, 0, 0, 0.03) !important;
    color: var(--text-main) !important;
    transform: translateX(4px); /* Premium nudge right */
}

#admin-screen aside.collapsed .admin-tab:hover {
    transform: translateY(-2px); /* Vertical nudge when collapsed */
}

.admin-tab.active {
    background: var(--text-main) !important;
    color: white !important;
    box-shadow: 0 8px 20px rgba(0,0,0,0.12) !important;
    transform: none !important;
}

/* Hamburger Toggle Button Styling */
.sidebar-toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 10px 14px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    transition: color 0.3s, background 0.3s;
    border-radius: 8px;
}

.sidebar-toggle-btn:hover {
    color: var(--text-main);
    background: rgba(0,0,0,0.03);
}

#admin-screen aside.collapsed .sidebar-toggle-btn {
    justify-content: center !important;
    padding: 10px 0 !important;
}

/* --- MOBILE RESPONSIVENESS (Admin & Global) --- */
@media (max-width: 768px) {
    /* Ensure any globally fixed sidebars become part of the document flow on small screens
       This prevents overlap with the header and makes the nav touch-friendly. */
    /* Removed global override that forced sidebar into a horizontal row; see media queries for responsive behavior. */
    /* Stack the Admin Layout vertically on mobile so header/nav behave naturally */
    /* Keep the admin screen full viewport height on mobile so inner flex children can size correctly */
    #admin-screen {
        flex-direction: column;
        height: 100vh !important;
        min-height: 100vh !important;
        overflow: hidden !important;
    }

    /* Override inline row on the admin content wrapper so the sidebar stacks above main */
    #admin-screen > div {
        flex-direction: column !important;
        display: flex !important;
        align-items: stretch !important;
        overflow: visible !important;
        /* Reserve space below header for the main container so internal viewport height works */
        height: calc(100vh - 64px) !important;
    }

    /* Convert Sidebar to a horizontal, touch-friendly nav on mobile */
    #admin-screen aside {
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        flex: 0 0 auto !important;
        height: auto !important;
        flex-direction: row !important;
        flex-wrap: wrap;
        overflow-x: hidden !important;
        overflow-y: hidden !important;
        padding: 8px 10px !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border) !important;
        white-space: normal !important;
    }

    /* Make sure the main header remains on top and content doesn't get hidden behind a fixed sidebar */
    .main-header { position: sticky; top: 0; z-index: 110; }

    /* Make nav items touch large and horizontally aligned */
    #admin-screen aside nav {
        display: flex !important;
        flex-direction: row !important;
        gap: 8px !important;
        flex-wrap: wrap;
        align-items: center !important;
    }

    .admin-tab {
        width: auto !important;
        padding: 10px 14px !important;
        white-space: nowrap !important;
        display: inline-flex !important;
        align-items: center !important;
        gap: 8px !important;
        font-size: 0.95rem !important;
    }

    /* Ensure main view expands to full width and reduces padding for small screens */
    .admin-view {
        padding: 16px !important;
        max-width: 100% !important;
        margin: 0 !important;
        box-sizing: border-box !important;
    }
    /* Also adjust the inline-styled main admin viewport used in index.html */
    #admin-main-viewport {
        padding: 16px !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Modals should take up the full screen on mobile */
    .modal-content, .glass-sheet {
        width: 100% !important;
        height: 100% !important;
        border-radius: 0 !important;
        max-height: 100vh !important;
    }

    /* Stack Bento Boxes and Grids into single column */
    .bento-grid, .stats-grid {
        grid-template-columns: 1fr !important;
    }

    /* Ensure admin header titles wrap and scale down when necessary */
    #admin-header-title {
        font-size: 1.4rem !important;
        line-height: 1.15 !important;
    }
    #admin-header-subtitle {
        font-size: 0.95rem !important;
    }
}

/* Tablet: admin aside nav goes horizontal — the app .sidebar stays as a fixed off-canvas panel */
@media (max-width: 1024px) and (min-width: 769px) {
    /* IMPORTANT: Do NOT touch .sidebar here — it must remain fixed/off-canvas for the app menu.
       Only the #admin-screen aside (which is an in-page nav, not an off-canvas drawer) is changed. */

    #admin-screen aside {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        height: auto !important;
        padding: 10px 12px !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border) !important;
    }

    #admin-screen aside nav {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        align-items: center !important;
    }

    #admin-screen > div { padding-top: 0 !important; }

    /* Slightly reduce tab spacing on tablets so more items fit in one row */
    .admin-tab { padding: 8px 10px !important; font-size: 0.92rem !important; }
}

/* Mobile: minimized horizontal sidebar that sits above the content */
@media (max-width: 767px) {
    /* Place the admin nav as a horizontal bar below the header */
    #admin-screen aside {
        position: static !important;
        width: 100% !important;
        height: auto !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        padding: 8px 10px !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border) !important;
        background: var(--saas-sidebar-bg) !important;
        box-shadow: none !important;
        z-index: 100;
        white-space: nowrap !important;
    }

    /* Horizontal, non-wrapping, scrollable single-row nav */
    #admin-screen { overflow: visible !important; height: auto !important; }
    #admin-screen aside {
        position: sticky !important;
        top: 64px !important;
        z-index: 150 !important;
    }
    #admin-screen aside nav {
        display: flex !important;
        flex-direction: row !important;
        gap: 8px !important;
        align-items: center !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 6px 8px !important;
        flex: 1 1 auto !important;
        flex-wrap: nowrap !important; /* ensure single row */
        white-space: nowrap !important;
        scroll-snap-type: x proximity;
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE 10+ */
    }
    #admin-screen aside nav::-webkit-scrollbar { display: none; height: 6px; }

    /* Uniform pill buttons: centered content and equal size */
    .admin-tab {
        flex: 0 0 auto !important;
        min-width: 96px !important;
        height: 44px !important;
        padding: 8px 12px !important;
        border-radius: 999px !important;
        white-space: nowrap !important;
        margin-bottom: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important; /* middle-middle aligned */
        gap: 8px !important;
        text-align: center !important;
    }
    .admin-tab .tab-text {
        display: inline-block !important;
        max-width: 120px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }
    /* Show labels even if a 'compact' class is present (server may render compact by default) */
    .admin-tab.compact .tab-text { opacity: 1 !important; max-width: 120px !important; margin-left: 6px !important; pointer-events: auto !important; }
    .admin-tab { scroll-snap-align: center; }
    .admin-tab:focus {
        outline: 3px solid color-mix(in srgb, var(--accent-color, #007AFF) 40%, transparent);
        outline-offset: 4px;
    }

    /* Move the exit button into the horizontal bar on mobile (visually inline) */
    #admin-screen aside > div[style] {
        order: 2 !important;
        margin-left: 8px !important;
        margin-top: 0 !important;
        border-top: none !important;
        padding: 0 !important;
    }
    #admin-screen aside > div[style] #exit-admin-btn {
        width: auto !important;
        padding: 8px 12px !important;
        border-radius: 999px !important;
        font-size: 0.9rem !important;
    }

    /* Ensure main content flows below the nav bar */
    #admin-main-viewport, .admin-view { margin-top: 0 !important; }

    /* Scroll shadow indicators (left/right) */
    .admin-nav-shadow {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        height: 56px;
        width: 48px;
        pointer-events: none;
        z-index: 160;
        opacity: 0;
        transition: opacity 180ms ease;
        border-radius: 999px;
        display: block;
    }
    .admin-nav-shadow.left {
        left: 8px;
        background: linear-gradient(90deg, rgba(20,25,35,0.9) 0%, rgba(20,25,35,0.6) 30%, rgba(20,25,35,0) 100%);
    }
    .admin-nav-shadow.right {
        right: 8px;
        background: linear-gradient(270deg, rgba(20,25,35,0.9) 0%, rgba(20,25,35,0.6) 30%, rgba(20,25,35,0) 100%);
    }
    .admin-nav-shadow.show { opacity: 1; }

    /* Hide any overlay or off-canvas UI on mobile horizontal layout */
    .sidebar-overlay { display: none !important; }
}

/* Mobile-specific toggle visibility */
.sidebar-toggle-btn.mobile-toggle { display: none; align-items: center; justify-content: center; margin-right: 12px; background: transparent; border: none; color: var(--saas-text); font-size: 1.2rem; padding: 8px; border-radius: 8px; }
.sidebar-toggle-btn.mobile-toggle:focus { outline: 2px solid color-mix(in srgb, var(--accent-color) 30%, transparent); }
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar-toggle-btn.mobile-toggle { display: inline-flex !important; }
    .main-header { padding-left: 12px; }
}

/* Extra small screens: collapse labels to icons and increase touch targets */
@media (max-width: 480px) {
    /* Reduce sidebar (now horizontal) density by showing icon-first compact pills */
    .admin-tab {
        padding: 10px 12px !important;
        font-size: 0.85rem !important;
    }

    /* If icon fonts are present, allow hiding text to save space while keeping accessible labels */

    /* Make main content padding minimal on very small devices */
    .admin-view { padding: 12px !important; }
    #admin-main-viewport { padding: 12px !important; }

    /* Hide the textual label when compact to keep icons visible and tappable */
    /* Animated hide/show for tab labels: use max-width + opacity to animate smoothly */
    .admin-tab .tab-text {
        display: inline-block;
        max-width: 240px;
        opacity: 1;
        overflow: hidden;
        vertical-align: middle;
        transition: opacity 180ms ease, max-width 200ms ease, margin 180ms ease;
        margin-left: 6px;
    }
    .admin-tab.compact .tab-text {
        opacity: 0 !important;
        max-width: 0 !important;
        margin-left: 0 !important;
        pointer-events: none !important;
    }
    .admin-tab i { transition: margin-right 180ms ease, font-size 180ms ease, opacity 150ms ease; }
    .admin-tab.compact i { margin-right: 0 !important; }

    /* Ensure any full-width cards collapse nicely */
    .bento-card, .card { padding: 12px !important; }

    /* Make bottom navigation and controls comfortably tappable */
    .bottom-nav { padding-bottom: calc(var(--safe-area-bottom) + 12px); }
}

/* --- RIGHT PROFILE DRAWER --- */
/* Sidebar Drawer Overlay */
.profile-drawer {
    position: fixed;
    top: 0;
    right: -320px; /* Hidden off-screen to the right */
    width: 320px;
    height: 100vh;
    background: var(--card-bg, #1c1c1e);
    border-left: 1px solid var(--border, #333);
    z-index: 6000;
    transition: right 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: -10px 0 30px rgba(0,0,0,0.3);
}

.profile-drawer.active {
    right: 0; /* Slide into view */
}

.drawer-header {
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.drawer-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 800;
}

.drawer-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
}

.drawer-close-btn:hover {
    color: var(--text-main);
}

.drawer-content {
    padding: 24px;
    flex: 1;
    overflow-y: auto;
}

.drawer-footer {
    padding: 24px;
    border-top: 1px solid var(--border);
}

/* Drawer Activity Items */
.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 0 -10px; /* Offset the padding to keep icons aligned with the header */
}

.activity-item:hover {
    background: var(--saas-hover, rgba(0, 0, 0, 0.04));
    transform: translateX(4px);
}

/* Ensure the left sidebar flexbox utilizes the freed-up space */
#admin-screen aside nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* =========================================================
   PREMIUM CONTROL CENTER OVERHAUL (MAC-OS / STRIPE AESTHETIC)
   ========================================================= */

:root {
    /* Ultra-Clean SaaS Color Palette */
    --saas-sidebar-bg: var(--admin-sidebar-bg);
    --saas-canvas-bg: var(--admin-canvas-bg);
    --saas-border: var(--admin-border);
    --saas-hover: var(--admin-hover);
    --saas-text: var(--admin-text);
    --saas-muted: var(--admin-muted);
    --saas-active: var(--admin-active);
}

/* 1. The Master Canvas */
#admin-screen {
    background: var(--saas-canvas-bg) !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
}

/* 2. The Clean Sidebar */
#admin-screen aside {
    background: var(--saas-sidebar-bg) !important;
    border-right: 1px solid var(--saas-border) !important;
    padding: 24px 16px !important;
    backdrop-filter: none !important; /* Kills the muddy glass */
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;
}

/* 3. The Navigation Tabs (No more bouncy animations) */
.admin-tab {
    background: transparent !important;
    color: var(--saas-muted) !important;
    border-radius: 8px !important;
    padding: 10px 14px !important;
    font-weight: 500 !important;
    font-size: 0.9rem !important;
    letter-spacing: -0.2px !important;
    border: none !important;
    margin-bottom: 4px !important;
    transition: background 0.15s ease, color 0.15s ease !important;
    transform: none !important; /* Kills the cheap hover bounce */
}
/* Improve legibility and accessibility */
.admin-tab { min-height: 44px; display: flex; align-items: center; }
.admin-tab:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent-color) 30%, transparent); outline-offset: 2px; border-radius: 8px; }
.admin-tab { color: var(--saas-text) !important; }

.admin-tab i {
    font-size: 1.25rem !important;
    margin-right: 12px !important;
    color: inherit;
    opacity: 0.7;
    transition: opacity 0.15s ease;
}

.admin-tab:hover {
    background: var(--saas-hover) !important;
    color: var(--saas-text) !important;
}

.admin-tab.active {
    background: var(--saas-active) !important;
    color: var(--saas-canvas-bg) !important;
    font-weight: 600 !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important; /* Very subtle shadow */
}
.admin-tab[title] { cursor: pointer; }

.admin-tab.active i {
    opacity: 1 !important;
}

/* 4. The Main Dashboard Area */
.admin-view {
    padding: 40px !important;
    background: var(--saas-canvas-bg) !important;
    max-width: 1400px; /* Keeps wide screens from looking too stretched */
    margin: 0 auto;
}

/* Make admin main viewport scrollable: reserve header height and allow internal scrolling */
#admin-main-viewport {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    height: calc(100vh - 64px) !important; /* header is 64px */
    box-sizing: border-box !important;
}

/* Ensure admin-view sections also can scroll when used in alternate layouts */
.admin-view, .admin-module-runtime-view {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
}

.admin-view h1, .admin-view h2 {
    color: var(--saas-text) !important;
    font-weight: 800 !important;
    letter-spacing: -0.5px !important;
}

/* 5. Structural Bento Boxes & Tables */
.data-table-container, .bento-box {
    background: var(--card-bg) !important;
    border: 1px solid var(--saas-border) !important;
    border-radius: 12px !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03) !important;
    overflow: hidden !important;
    backdrop-filter: none !important;
}

/* Sidebar theme toggle row */
.theme-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 8px 16px 0 16px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--bg-color);
    border: 1px solid var(--border);
}

.theme-toggle-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.theme-toggle-btn {
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text-main);
    border-radius: 999px;
    min-width: 122px;
    padding: 8px 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 700;
    transition: transform 0.14s ease, border-color 0.2s ease, background 0.2s ease;
}

.theme-toggle-btn:hover {
    border-color: var(--accent-color);
}

.theme-toggle-btn:active {
    transform: scale(0.98);
}

.theme-toggle-btn:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent-color) 22%, transparent);
    outline-offset: 2px;
}

/* 6. Crisp Data Tables */
.data-table-container table {
    width: 100% !important;
    border-collapse: collapse !important;
}

.data-table-container table th {
    background: var(--saas-sidebar-bg) !important;
    color: var(--saas-muted) !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    font-size: 0.75rem !important;
    letter-spacing: 0.05em !important;
    border-bottom: 1px solid var(--saas-border) !important;
    padding: 14px 16px !important;
}

.data-table-container table td {
    border-bottom: 1px solid var(--saas-border) !important;
    color: var(--saas-text) !important;
    padding: 14px 16px !important;
    font-size: 0.9rem !important;
}

/* Maintain Collapsed Sidebar integrity */
#admin-screen aside.collapsed .admin-tab i {
    margin-right: 0 !important;
}

/* Tooltip for long-press on admin tabs */
.admin-tab-tooltip {
    background: rgba(0,0,0,0.85);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    box-shadow: 0 8px 30px rgba(0,0,0,0.25);
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease;
    opacity: 0.98;
}

/* Enforce two-column split on wider screens: sidebar 25%, content 75% */
@media (min-width: 769px) {
    #admin-screen > div { display: flex !important; }
    #admin-screen aside {
        position: relative !important;
        width: 25% !important;
        flex: 0 0 25% !important;
        max-width: 360px !important;
        min-width: 220px !important;
    }
    #admin-main-viewport, #admin-screen main, .admin-view {
        width: 75% !important;
        flex: 1 1 75% !important;
        overflow-y: auto !important;
    }
}