/* 
 * HQ Dashboard - Glass-Morphism Dark Theme
 * Deep navy with glowing accents
 */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&display=swap');

/* iOS Safari safe areas and toolbar color fix */
html {
    background-color: #020617;
}

:root {
    /* Deep Dark Navy Backgrounds */
    --bg-primary: #020617;
    --bg-secondary: #040a19;
    --bg-tertiary: #0f172a;
    --bg-card: rgba(15, 23, 42, 0.6);
    --bg-hover: rgba(30, 41, 59, 0.8);
    --bg-glass: rgba(15, 23, 42, 0.4);
    
    /* Safe area insets for iOS */
    --safe-area-inset-top: env(safe-area-inset-top);
    --safe-area-inset-bottom: env(safe-area-inset-bottom);
    --safe-area-inset-left: env(safe-area-inset-left);
    --safe-area-inset-right: env(safe-area-inset-right);
    
    /* Accent colors */
    --accent-primary: #4f8bff;
    --accent-gold: #ffc955;
    --accent-hot: #ff9d4d;
    --accent-amber: #ffb347;
    --accent-mint: #7efad1;
    --accent-success: #7efad1;
    --accent-warning: #ffc955;
    --accent-danger: #ef4444;
    
    /* Text colors */
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* Border colors */
    --border-color: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.12);
    --border-glow: rgba(79, 139, 255, 0.3);
    
    /* Gradients */
    --gradient-bg: linear-gradient(180deg, #020617 0%, #040a19 50%, #030712 100%);
    --gradient-gold: linear-gradient(130deg, #ffd86b, #ffb347);
    --gradient-glow: radial-gradient(ellipse at 50% 0%, rgba(79, 139, 255, 0.15) 0%, transparent 50%);
    
    /* Shadows */
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 30px 60px rgba(0, 0, 0, 0.55);
    --shadow-glow-blue: 0 0 40px rgba(79, 139, 255, 0.2);
    --shadow-glow-mint: 0 0 30px rgba(126, 250, 209, 0.15);
    --shadow-glow-gold: 0 0 30px rgba(255, 201, 85, 0.2);
    
    /* Spacing */
    --sidebar-width: 260px;
    --header-height: 70px;
    
    /* Border Radius */
    --radius-sm: 12px;
    --radius-md: 18px;
    --radius-lg: 28px;
    
    /* Transitions */
    --transition-fast: 240ms cubic-bezier(0.19, 1, 0.22, 1);
    --transition-normal: 400ms cubic-bezier(0.19, 1, 0.22, 1);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    background: var(--gradient-bg);
    background-color: #020617;
    color: var(--text-primary);
    overflow-x: hidden;
}

body {
    display: flex;
    position: relative;
    /* iOS safe area padding */
    padding-bottom: env(safe-area-inset-bottom);
}

/* Ambient glow effects */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse 80% 50% at 20% 20%, rgba(79, 139, 255, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse 60% 40% at 80% 30%, rgba(126, 250, 209, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse 50% 50% at 50% 80%, rgba(255, 183, 110, 0.06) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.logo-icon {
    font-size: 28px;
}

.logo-text {
    font-size: 24px;
    font-weight: 700;
    background: var(--gradient-gold);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px rgba(255, 201, 85, 0.3);
}

.nav-menu {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition-fast);
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(79, 139, 255, 0.2), rgba(126, 250, 209, 0.1));
    color: var(--accent-gold);
    border: 1px solid rgba(255, 201, 85, 0.3);
    box-shadow: var(--shadow-glow-gold);
}

.nav-icon {
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-icon svg {
    width: 20px;
    height: 20px;
}

.nav-text {
    font-weight: 500;
}

.nav-divider {
    height: 1px;
    background: var(--border-color);
    margin: 12px 12px;
}

.nav-section-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 4px 24px 8px;
}

.nav-logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: cover;
}

/* Sidebar Apps Section */
.sidebar-apps {
    padding: 16px 12px;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.sidebar-section-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-item.app-link {
    position: relative;
}

.nav-item.app-link .nav-icon svg {
    color: var(--app-color, var(--accent-mint));
}

.nav-item.app-link:hover {
    background: color-mix(in srgb, var(--app-color, var(--accent-mint)) 15%, transparent);
}

.external-link-icon {
    margin-left: auto;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.external-link-icon svg {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
}

.nav-item.app-link:hover .external-link-icon {
    opacity: 1;
}

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

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-success);
}

.status-dot.live {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(126, 250, 209, 0.7); }
    50% { opacity: 0.8; box-shadow: 0 0 0 8px rgba(126, 250, 209, 0); }
}

.status-text {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: 24px;
    overflow-y: auto;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.last-updated {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.live-count {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(126, 250, 209, 0.1);
    border: 1px solid rgba(126, 250, 209, 0.3);
    border-radius: 20px;
    color: var(--accent-mint);
    font-weight: 500;
    box-shadow: var(--shadow-glow-mint);
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-mint);
    animation: pulse 2s infinite;
    box-shadow: 0 0 10px var(--accent-mint);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition-normal);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg), var(--shadow-glow-blue);
    border-color: var(--border-light);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-icon svg {
    width: 28px;
    height: 28px;
}

.stat-icon.visitors { background: rgba(79, 139, 255, 0.2); box-shadow: var(--shadow-glow-blue); }
.stat-icon.today { background: rgba(126, 250, 209, 0.2); box-shadow: var(--shadow-glow-mint); }
.stat-icon.revenue { background: rgba(255, 201, 85, 0.2); box-shadow: var(--shadow-glow-gold); }
.stat-icon.apps { background: rgba(255, 157, 77, 0.2); box-shadow: 0 0 30px rgba(255, 157, 77, 0.15); }

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 24px;
    margin-bottom: 24px;
}

/* Panel Header */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.panel-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.badge {
    background: var(--gradient-gold);
    color: #020617;
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    box-shadow: var(--shadow-glow-gold);
}

/* Map Container */
.map-container {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

#map {
    height: 450px;
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
}

.map-controls {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    background: var(--bg-glass);
    backdrop-filter: blur(8px);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 16px;
    transition: var(--transition-fast);
}

.btn-icon:hover {
    background: var(--bg-hover);
    border-color: var(--accent-gold);
    box-shadow: var(--shadow-glow-gold);
}

/* Visitors Panel */
.visitors-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    max-height: 530px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.visitors-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at 0% 0%, rgba(79, 139, 255, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 100% 100%, rgba(126, 250, 209, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(255, 183, 110, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.visitors-panel > * {
    position: relative;
    z-index: 1;
}

.visitors-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.visitor-item {
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 14px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.visitor-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent-gold);
    box-shadow: var(--shadow-glow-gold);
}

.visitor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.visitor-app {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-secondary);
}

.visitor-time {
    font-size: 11px;
    color: var(--text-muted);
}

.visitor-location {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.visitor-page {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.visitor-ip {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-primary);
    padding: 2px 8px;
    border-radius: 4px;
    margin-top: 8px;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-icon svg {
    width: 48px;
    height: 48px;
}

/* Apps Section */
.apps-section {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-lg);
}

.apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.app-card {
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.app-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--app-color);
    box-shadow: 0 0 20px var(--app-color);
}

.app-card:hover {
    transform: translateY(-4px);
    border-color: var(--app-color);
    box-shadow: var(--shadow-lg), 0 0 30px color-mix(in srgb, var(--app-color) 30%, transparent);
}

.app-icon {
    font-size: 32px;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
}

.app-icon svg {
    width: 28px;
    height: 28px;
}

.app-info h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.app-visitors {
    font-size: 13px;
    color: var(--text-secondary);
}

.app-link-btn {
    position: absolute;
    top: 12px;
    right: 32px;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
    opacity: 0;
    transition: all 0.2s ease;
}

.app-link-btn svg {
    width: 14px;
    height: 14px;
}

.app-card:hover .app-link-btn {
    opacity: 1;
}

.app-link-btn:hover {
    background: var(--app-color);
    color: var(--bg-primary);
    border-color: var(--app-color);
}

.app-status {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.app-status.online {
    background: var(--accent-success);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.app-status.offline {
    background: var(--text-muted);
}

/* Activity Section */
.activity-section {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-lg);
}

.activity-list {
    max-height: 300px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    transition: var(--transition-fast);
}

.activity-item:hover {
    background: var(--bg-tertiary);
}

.activity-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    background: var(--bg-tertiary);
}

.activity-icon svg {
    width: 18px;
    height: 18px;
}

.activity-content {
    flex: 1;
}

.activity-text {
    font-size: 13px;
    color: var(--text-primary);
}

.activity-time {
    font-size: 11px;
    color: var(--text-muted);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(2, 6, 23, 0.85);
    backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg), var(--shadow-glow-blue);
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.modal-close:hover {
    background: var(--accent-danger);
    color: white;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

/* Scrollbar Styles */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--gradient-gold);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(130deg, #ffe599, #ffc955);
}

/* Leaflet Map Custom Styles */
.leaflet-container {
    background: var(--bg-tertiary);
}

.leaflet-popup-content-wrapper {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(12px);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
}

.leaflet-popup-tip {
    background: rgba(15, 23, 42, 0.9);
}

.visitor-marker {
    background: var(--accent-primary);
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 12px rgba(79, 139, 255, 0.6);
}

.marker-pulse {
    animation: markerPulse 2s infinite;
}

@keyframes markerPulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

/* Responsive */
@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .visitors-panel {
        max-height: 400px;
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 280px;
        --header-height: 60px;
    }
    
    /* Sidebar Drawer */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
        box-shadow: none;
    }
    
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 30px rgba(0, 0, 0, 0.5);
    }
    
    /* Sidebar Overlay */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(4px);
        z-index: 999;
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }
    
    /* Hamburger Button */
    .hamburger-btn {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 5px;
        position: fixed;
        top: 16px;
        left: 16px;
        width: 44px;
        height: 44px;
        background: var(--bg-glass);
        backdrop-filter: blur(12px);
        border: 1px solid var(--border-color);
        border-radius: 12px;
        z-index: 998;
        cursor: pointer;
        transition: var(--transition-fast);
    }
    
    .hamburger-btn:hover {
        background: var(--bg-hover);
        border-color: var(--border-light);
    }
    
    .hamburger-line {
        width: 20px;
        height: 2px;
        background: var(--text-primary);
        border-radius: 2px;
        transition: 0.3s ease;
    }
    
    .hamburger-btn.active .hamburger-line:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    
    .hamburger-btn.active .hamburger-line:nth-child(2) {
        opacity: 0;
    }
    
    .hamburger-btn.active .hamburger-line:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -5px);
    }
    
    /* Close button in sidebar */
    .sidebar-close {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        margin-left: auto;
        background: var(--bg-hover);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        color: var(--text-secondary);
        font-size: 24px;
        cursor: pointer;
        transition: var(--transition-fast);
    }
    
    .sidebar-close:hover {
        background: var(--bg-tertiary);
        color: var(--text-primary);
    }
    
    /* Main Content */
    .main-content {
        margin-left: 0;
        padding: 70px 16px 16px 16px;
        width: 100%;
    }
    
    /* Header */
    .header {
        padding: 0 8px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        min-height: auto;
        padding-top: 8px;
        padding-bottom: 12px;
    }
    
    .header-left {
        padding-left: 44px;
    }
    
    .page-title {
        font-size: 22px;
    }
    
    .header-right {
        width: 100%;
    }
    
    .live-count {
        font-size: 13px;
        padding: 8px 14px;
        width: 100%;
        justify-content: center;
    }
    
    /* Stats Grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .stat-card {
        padding: 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .stat-icon {
        width: 40px;
        height: 40px;
    }
    
    .stat-value {
        font-size: 24px;
    }
    
    .stat-label {
        font-size: 11px;
    }
    
    /* Map Container */
    .map-container {
        border-radius: var(--radius-sm);
    }
    
    #visitorMap {
        height: 300px;
    }
    
    .panel-header h2 {
        font-size: 14px;
    }
    
    /* Visitors Panel */
    .visitors-panel {
        max-height: 350px;
    }
    
    .visitor-item {
        padding: 12px;
    }
    
    .visitor-location {
        font-size: 12px;
    }
    
    .visitor-page {
        font-size: 10px;
    }
    
    /* Apps Grid */
    .apps-grid {
        grid-template-columns: 1fr;
    }
    
    /* Nav items */
    .nav-item {
        padding: 14px 16px;
    }
    
    .nav-text {
        font-size: 14px;
    }
}

/* Extra small screens */
@media (max-width: 400px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        flex-direction: row;
        align-items: center;
    }
    
    #visitorMap {
        height: 250px;
    }
    
    .header-left {
        padding-left: 50px;
    }
    
    .page-title {
        font-size: 18px;
    }
}

/* Hide hamburger on desktop */
@media (min-width: 769px) {
    .hamburger-btn {
        display: none;
    }
    
    .sidebar-close {
        display: none;
    }
    
    .sidebar-overlay {
        display: none !important;
    }
}

/* ========================================
   VISITOR HISTORY SECTION
   ======================================== */

.history-section {
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    padding: 24px;
    margin-top: 24px;
}

.history-section .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
}

.history-filters {
    display: flex;
    gap: 12px;
    align-items: center;
}

.filter-select {
    background: var(--bg-darker);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-select:hover {
    border-color: var(--primary);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 139, 255, 0.2);
}

.btn-refresh {
    background: var(--bg-darker);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-refresh:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.history-stats {
    display: flex;
    gap: 24px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.history-stat {
    background: var(--bg-darker);
    padding: 16px 24px;
    border-radius: 12px;
    border-left: 4px solid var(--primary);
    min-width: 120px;
}

.history-stat.trilakes {
    border-left-color: #ff9d4d;
}

.history-stat.foreman {
    border-left-color: #7efad1;
}

.history-stat .stat-num {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.history-stat .stat-desc {
    font-size: 13px;
    color: var(--text-secondary);
}

.history-table-wrap {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.history-table thead {
    background: var(--bg-darker);
}

.history-table th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.history-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.history-table tbody tr:hover {
    background: rgba(79, 139, 255, 0.05);
}

.history-table tbody tr:last-child td {
    border-bottom: none;
}

.history-table .app-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

.history-table .app-badge.trilakes {
    background: rgba(255, 157, 77, 0.15);
    color: #ff9d4d;
}

.history-table .app-badge.foreman-ai {
    background: rgba(126, 250, 209, 0.15);
    color: #7efad1;
}

.history-table .location-cell {
    display: flex;
    flex-direction: column;
}

.history-table .location-city {
    font-weight: 500;
}

.history-table .location-region {
    font-size: 12px;
    color: var(--text-secondary);
}

.history-table .page-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-table .time-cell {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
}

@media (max-width: 768px) {
    .history-section .panel-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .history-filters {
        width: 100%;
        flex-wrap: wrap;
    }
    
    .filter-select {
        flex: 1;
        min-width: 100px;
    }
    
    .history-stats {
        flex-direction: column;
        gap: 12px;
    }
    
    .history-stat {
        width: 100%;
    }
}
