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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    color: white;
    padding: 40px 30px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(102, 126, 234, 0.2) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(118, 75, 162, 0.15) 0%, transparent 50%);
    pointer-events: none;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 12px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    position: relative;
    z-index: 1;
    background: linear-gradient(90deg, #ffffff 0%, #a8b7ff 50%, #ffffff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px rgba(168, 183, 255, 0.5);
}

.subtitle {
    opacity: 0.85;
    font-size: 1.1rem;
    position: relative;
    z-index: 1;
    letter-spacing: 1px;
    color: #a8b7ff;
    font-weight: 300;
}

.main-content {
    display: flex;
    min-height: calc(100vh - 180px);
}

/* Sidebar Styles */
.sidebar {
    width: 280px;
    background: #f8f9fa;
    border-right: 1px solid #e0e0e0;
    padding: 20px;
    height: calc(100vh - 80px); /* fill page below header */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar h2 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: #333;
}

.sensor-count-display {
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 100%);
    color: #a8b7ff;
    padding: 10px 15px;
    border-radius: 6px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 15px;
    border: 1px solid rgba(168, 183, 255, 0.3);
}

.search-box {
    margin-bottom: 15px;
}

.search-box input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border-color 0.3s;
}

.search-box input:focus {
    outline: none;
    border-color: #302b63;
}

/* Sort Controls */
.sort-controls {
    margin-bottom: 15px;
    padding: 10px;
    background: white;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.sort-label {
    font-size: 0.85rem;
    color: #666;
    font-weight: 600;
    margin-right: 8px;
}

.sort-btn {
    padding: 6px 12px;
    margin: 2px;
    background: #f8f9fa;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    color: #333;
    font-weight: 500;
}

.sort-btn:hover {
    background: #e8ecf1;
    border-color: #302b63;
    transform: translateY(-1px);
}

.sort-btn.active {
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 100%);
    color: white;
    border-color: transparent;
    font-weight: 600;
}

.sort-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(48, 43, 99, 0.2);
}

.sensor-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1 1 auto;
    overflow-y: auto;
    padding-right: 5px;
    min-height: 0;
}

.sensor-list::-webkit-scrollbar {
    width: 8px;
}

.sensor-list::-webkit-scrollbar-track {
    background: #e0e0e0;
    border-radius: 4px;
}

.sensor-list::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #302b63 0%, #0f0c29 100%);
    border-radius: 4px;
}

.sensor-list::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 100%);
}

.sensor-item {
    padding: 12px 15px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9rem;
}

.sensor-item:hover {
    border-color: #302b63;
    background: #f0f4ff;
    transform: translateX(5px);
}

.sensor-item.active {
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 100%);
    color: white;
    border-color: transparent;
    font-weight: 600;
}

.sensor-item .sensor-name {
    font-weight: 600;
    margin-bottom: 4px;
}

.sensor-item .sensor-count {
    font-size: 0.8rem;
    opacity: 0.7;
}

.sensor-item .sensor-mean {
    font-size: 0.85rem;
    margin-top: 4px;
    font-weight: 500;
    color: #302b63;
}

.sensor-item.active .sensor-mean {
    color: rgba(255, 255, 255, 0.9);
}

/* Chart Container Styles */
.chart-container {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

.chart-header {
    margin-bottom: 25px;
}

.chart-header h2 {
    color: #333;
    margin-bottom: 10px;
}

.chart-info {
    display: flex;
    gap: 20px;
    font-size: 0.9rem;
    color: #666;
}

.chart-wrapper {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
    min-height: 400px;
}

/* Stats Container */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.stat-label {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Table Styles */
.table-container {
    margin-top: 30px;
}

.table-container h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.table-wrapper {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

#observationsTable {
    width: 100%;
    border-collapse: collapse;
}

#observationsTable thead {
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 100%);
    color: white;
}

#observationsTable th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#observationsTable tbody tr {
    border-bottom: 1px solid #e0e0e0;
    transition: background-color 0.2s;
}

#observationsTable tbody tr:hover {
    background-color: #f8f9fa;
}

#observationsTable tbody tr:last-child {
    border-bottom: none;
}

#observationsTable td {
    padding: 12px 15px;
    font-size: 0.9rem;
    color: #333;
}

#observationsTable td:first-child {
    font-weight: 600;
    color: #302b63;
    width: 60px;
}

#observationsTable td:last-child {
    font-weight: 600;
    color: #0f0c29;
}

.table-wrapper {
    max-height: 500px;
    overflow-y: auto;
}

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

.table-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #302b63 0%, #0f0c29 100%);
    border-radius: 4px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 100%);
}

/* Responsive Design */
@media (max-width: 968px) {
    .main-content {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
        max-height: 300px;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .stats-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    body {
        padding: 10px;
    }
    
    .container {
        border-radius: 8px;
    }
    
    header {
        padding: 20px;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .chart-container {
        padding: 15px;
    }
    
    .sidebar {
        padding: 15px;
    }
    
    .stats-container {
        grid-template-columns: 1fr;
    }
    
    /* Make table scrollable horizontally on mobile */
    .table-wrapper {
        overflow-x: auto;
    }
    
    #observationsTable {
        font-size: 0.85rem;
    }
    
    #observationsTable th,
    #observationsTable td {
        padding: 10px 8px;
        white-space: nowrap;
    }
}

/* Loading State */
.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

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