* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: #0057b7;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.75rem;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 87, 183, 0.3);
    transition: all 0.3s ease;
}

.mobile-menu-btn:hover {
    background: #228b22;
    transform: translateY(-2px);
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: block;
    }
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0057b7 0%, #ffd700 50%, #228b22 100%);
    color: #333;
    min-height: 100vh;
}

.container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 280px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.1);
    padding: 2rem 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.logo {
    text-align: center;
    margin-bottom: 2rem;
    padding: 0 1.5rem;
}

.logo h1 {
    background: linear-gradient(45deg, #0057b7, #228b22, #ff8c00);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.5rem;
    font-weight: 700;
}

.nav-menu {
    list-style: none;
}

.nav-item {
    margin: 0.5rem 0;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    color: #666;
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
}

.nav-link:hover,
.nav-link.active {
    background: linear-gradient(90deg, rgba(34, 139, 34, 0.1) 0%, transparent 100%);
    color: #228b22;
    border-left-color: #228b22;
}

.nav-link i {
    margin-right: 0.75rem;
    width: 20px;
    text-align: center;
}

.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 2rem;
}

.page {
    display: none;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    /* Performance optimizations */
    contain: layout style paint;
    will-change: scroll-position;
}

.page.active {
    display: block;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    /* Performance optimizations */
    contain: layout style paint;
    will-change: scroll-position;
}

.page-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 2rem;
    border-radius: 20px;
    margin-bottom: 2rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.page-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 0.5rem;
}

.page-subtitle {
    color: #666;
    font-size: 1.1rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    text-align: center;
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #0057b7, #228b22, #ff8c00);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 0.5rem;
}

.stat-label {
    color: #666;
    font-size: 1rem;
}

.chart-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.chart-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
}

.chart-controls {
    display: flex;
    gap: 1rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, #0057b7, #228b22);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(34, 139, 34, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.8);
    color: #666;
    border: 2px solid #e0e0e0;
}

.btn-secondary:hover {
    background: white;
    border-color: #228b22;
    color: #228b22;
}

/* Improved Table Styles with Strict Height Constraints */
.table-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    /* Ultra strict height constraint - prevent any vertical expansion */
    height: 400px !important;
    max-height: 400px !important;
    min-height: 300px !important;
    overflow-y: auto !important;
    overflow-x: auto !important;
    position: relative;
    display: flex !important;
    flex-direction: column;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    /* Performance optimizations */
    will-change: scroll-position;
    contain: layout style paint;
    transform: translateZ(0);
    /* Prevent any stretching */
    resize: none !important;
}

.table-container.scrollable {
    /* Even stricter constraints for scrollable tables */
    height: 350px !important;
    max-height: 350px !important;
    min-height: 350px !important;
    overflow-y: scroll !important;
    overflow-x: auto !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    /* Smooth scrolling performance */
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    will-change: scroll-position;
    resize: none !important;
}

/* Prevent table from growing beyond container */
.table-container > div {
    flex: 1 1 0 !important;
    overflow: auto !important;
    max-height: 100% !important;
    height: 100% !important;
}

.table-wrapper {
    flex-shrink: 0;
    background: white;
    border-bottom: 1px solid #e0e0e0;
    z-index: 10;
    height: auto !important;
    max-height: none !important;
    overflow: visible;
}

/* Fixed table header */
.table-container .table {
    width: 100% !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
    position: relative !important;
    max-height: 100% !important;
    table-layout: fixed !important;
}

.table-container .table thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: linear-gradient(135deg, #0057b7, #228b22);
}

.table {
    width: 100% !important;
    border-collapse: collapse !important;
    table-layout: fixed !important;
    max-height: 100% !important;
    height: auto !important;
}

/* Improved table structure with proper wrapper */
.table-wrapper {
    height: 100% !important;
    max-height: 100% !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
}

.table-wrapper > .table {
    flex-shrink: 0 !important;
    margin-bottom: 0 !important;
}

.table-body-wrapper {
    flex: 1;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    height: calc(100% - 50px) !important;
    max-height: 350px !important;
    min-height: 250px !important;
    contain: layout style paint;
    will-change: scroll-position;
}

.table-body-wrapper .table {
    margin-bottom: 0 !important;
}

.table th,
.table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: top;
    word-wrap: break-word;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9rem;
}

/* Allow text wrapping for content cells */
.table td {
    white-space: normal !important;
    word-break: break-word !important;
    hyphens: auto;
    height: auto !important;
    max-height: 60px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.table th {
    background: linear-gradient(135deg, #0057b7, #228b22);
    color: white;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 5;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    height: 50px !important;
    max-height: 50px !important;
    min-height: 50px !important;
}

.table tbody tr:hover {
    background: rgba(34, 139, 34, 0.05);
}

.status-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.status-online {
    background: #4CAF50;
}

.status-offline {
    background: #f44336;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #333;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
}

.alert {
    padding: 1rem 1.5rem;
    border-radius: 10px;
    margin-bottom: 1rem;
}

.alert-success {
    background: rgba(76, 175, 80, 0.1);
    color: #4CAF50;
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.alert-error {
    background: rgba(244, 67, 54, 0.1);
    color: #f44336;
    border: 1px solid rgba(244, 67, 54, 0.3);
}

.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 3rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 20px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    margin-left: 10px;
    color: #666;
    font-size: 14px;
    font-weight: 500;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.export-buttons {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.metric-selector {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.metric-btn {
    padding: 0.5rem 1rem;
    border: 2px solid #e0e0e0;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.metric-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* Mobile and Tablet Responsive Styles */
@media (max-width: 1024px) {
    .sidebar {
        width: 250px;
    }
    
    .main-content {
        margin-left: 250px;
        padding: 1rem;
        overflow-x: hidden;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 1rem;
    }
    
    .table-container {
        height: 300px !important;
        max-height: 300px !important;
        min-height: 250px !important;
    }
    
    .table-container.scrollable {
        height: 280px !important;
        max-height: 280px !important;
        min-height: 230px !important;
    }
    
    .table-body-wrapper {
        max-height: 250px !important;
        min-height: 200px !important;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
        width: 280px;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .page-title {
        font-size: 2rem;
    }
    
    .table-container {
        overflow-x: auto;
        overflow-y: hidden !important;
        height: 250px !important;
        max-height: 250px !important;
        min-height: 200px !important;
        -webkit-overflow-scrolling: touch;
    }
    
    .table-container.scrollable {
        height: 220px !important;
        max-height: 220px !important;
        min-height: 180px !important;
    }
    
    .table-body-wrapper {
        max-height: 200px !important;
        min-height: 150px !important;
    }
    
    .table {
        min-width: 600px;
    }
    
    .table th,
    .table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.9rem;
        white-space: nowrap;
        max-width: 150px;
    }
    
    .chart-controls {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .export-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    .page-header {
        padding: 1.5rem;
    }
    
    .page-title {
        font-size: 1.75rem;
    }
    
    .stat-card {
        padding: 1.5rem;
    }
    
    .stat-value {
        font-size: 2rem;
    }
    
    .chart-container {
        padding: 1.5rem;
    }
    
    .table th,
    .table td {
        padding: 0.5rem 0.25rem;
        font-size: 0.8rem;
        max-width: 120px;
    }
    
    .table-container {
        height: 200px !important;
        max-height: 200px !important;
        min-height: 150px !important;
    }
    
    .table-container.scrollable {
        height: 180px !important;
        max-height: 180px !important;
        min-height: 130px !important;
    }
    
    .table-body-wrapper {
        max-height: 150px !important;
        min-height: 100px !important;
    }
    
    /* Prevent horizontal overflow */
    .main-content {
        overflow-x: hidden;
    }
    
    /* Improve form controls on mobile */
    .form-control {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Better spacing for mobile */
    .chart-container {
        margin-bottom: 1rem;
    }
}

/* Additional strict table constraints */
.table-wrapper {
    height: 100%;
    overflow: hidden;
    position: relative;
}

.table-body-wrapper {
    height: calc(100% - 60px); /* Account for header height */
    overflow-y: auto;
    overflow-x: auto;
}

/* Ensure tables never exceed container bounds */
.table-container * {
    max-height: inherit;
    overflow: hidden;
}

/* Scrollbar styling */
.table-body-wrapper::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.table-body-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-body-wrapper::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.table-body-wrapper::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.table-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Smooth scrolling */
.table-body-wrapper {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.table-container {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}