* {
    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, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

.container {
    max-width: 500px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.container-wide {
    max-width: 1200px;
    padding: 40px;
}

h1 {
    color: #333;
    text-align: center;
    margin-bottom: 30px;
    font-size: 24px;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
    font-size: 14px;
}

input[type="datetime-local"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    transition: border-color 0.3s;
}

input[type="datetime-local"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #667eea;
}

textarea {
    resize: vertical;
    min-height: 60px;
    font-family: inherit;
}

/* iPhone-Style Toggle */
.toggle-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 15px 20px;
    margin-bottom: 10px;
}

.toggle-container label[for="notAtHome"] {
    color: #333;
    font-weight: 500;
    font-size: 16px;
    margin: 0;
}

.iphone-toggle {
    position: relative;
}

.iphone-toggle input[type="checkbox"] {
    opacity: 0;
    position: absolute;
    width: 0;
    height: 0;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 51px;
    height: 31px;
    background-color: #e0e0e0;
    border-radius: 31px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.toggle-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 27px;
    height: 27px;
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 
        0 2px 4px rgba(0,0,0,0.2),
        0 1px 2px rgba(0,0,0,0.1);
    border: 1px solid rgba(255,255,255,0.8);
}

/* Checked state */
.iphone-toggle input:checked + .toggle-switch {
    background: linear-gradient(135deg, #34c759, #30d158);
    box-shadow: 
        inset 0 2px 4px rgba(0,0,0,0.1),
        0 0 0 1px rgba(52,199,89,0.2);
}

.iphone-toggle input:checked + .toggle-switch .toggle-slider {
    transform: translateX(20px);
    background: linear-gradient(145deg, #ffffff, #f8f8f8);
}

/* Hover effects */
.toggle-switch:hover {
    transform: scale(1.02);
}

.iphone-toggle input:checked + .toggle-switch:hover {
    background: linear-gradient(135deg, #30d158, #32d760);
}

/* Active/pressed state */
.toggle-switch:active .toggle-slider {
    width: 30px;
}

.iphone-toggle input:checked + .toggle-switch:active .toggle-slider {
    transform: translateX(17px);
}

/* Focus state for accessibility */
.iphone-toggle input:focus + .toggle-switch {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Collapsible section */
.collapsible-section {
    transition: all 0.3s ease-in-out;
    opacity: 1;
    max-height: 2000px;
    overflow: hidden;
}

.collapsible-section.collapsed {
    opacity: 0.3;
    max-height: 0;
    padding: 0;
    margin: 0;
}

/* Slider styling */
.slider-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 10px;
}

.slider-label {
    font-size: 12px;
    color: #666;
    text-align: center;
    min-width: 40px;
}

input[type="range"] {
    flex: 1;
    height: 40px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
}

input[type="range"]::-webkit-slider-track {
    width: 100%;
    height: 8px;
    background: linear-gradient(to right, #4CAF50 0%, #FFC107 50%, #F44336 100%);
    border-radius: 4px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 28px;
    height: 28px;
    background: white;
    border: 3px solid #667eea;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

input[type="range"]::-moz-range-track {
    width: 100%;
    height: 8px;
    background: linear-gradient(to right, #4CAF50 0%, #FFC107 50%, #F44336 100%);
    border-radius: 4px;
}

input[type="range"]::-moz-range-thumb {
    width: 28px;
    height: 28px;
    background: white;
    border: 3px solid #667eea;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Radio buttons */
.radio-group {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.radio-label {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    flex: 1;
    justify-content: center;
}

.radio-label:hover {
    border-color: #667eea;
    background: #f5f5ff;
}

.radio-label input[type="radio"] {
    display: none;
}

.radio-label input[type="radio"]:checked + span {
    color: #667eea;
    font-weight: 600;
}

.radio-label input[type="radio"]:checked ~ * {
    color: #667eea;
}

.radio-label:has(input[type="radio"]:checked) {
    border-color: #667eea;
    background: #f5f5ff;
}

/* Temperature container */
.temp-container {
    display: flex;
    gap: 10px;
}

.temp-container input {
    flex: 1;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-top: 20px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
    width: auto;
    padding: 10px 20px;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

/* Navigation links */
.nav-links {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: center;
    gap: 15px;
}

.nav-links a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

.nav-links a:hover {
    text-decoration: underline;
}

/* Messages */
#message {
    margin-top: 20px;
}

.success,
.error {
    padding: 15px 20px;
    border-radius: 12px;
    text-align: center;
    font-weight: 500;
    font-size: 15px;
    animation: fadeIn 0.3s ease-in-out;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.success {
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    color: #155724;
    border: 1px solid #b8dcc5;
}

.error {
    background: linear-gradient(135deg, #f8d7da, #f5c6cb);
    color: #721c24;
    border: 1px solid #f1b0b7;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* View page styles */
.filter-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.filter-section .form-group {
    margin-bottom: 0;
}

.filter-section button {
    margin-top: 24px;
}

.stats {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px 30px;
    border-radius: 15px;
    margin-bottom: 30px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.stats h3 {
    margin-bottom: 15px;
    font-size: 20px;
}

.stats p {
    margin: 0;
    font-size: 16px;
    text-align: center;
}

.stats p:first-child {
    font-size: 18px;
    font-weight: 600;
}

/* Not at home table row styling */
.not-at-home {
    background-color: #f8f9fa !important;
    opacity: 0.7;
    color: #6c757d;
}

.not-at-home td {
    font-style: italic;
}

.not-at-home:hover {
    background-color: #e9ecef !important;
}

/* Dashboard Styling */
.dashboard-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    background: transparent;
}

/* Dashboard Header */
.dashboard-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.dashboard-header h1 {
    font-size: 2.5rem;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
}

.header-actions {
    display: flex;
    gap: 15px;
    align-items: center;
}

/* Time Filter */
.time-filter {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 12px 24px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.filter-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

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

/* Dashboard Cards */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 20px;
    margin-bottom: 40px;
}

.card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.metric-card {
    padding: 30px;
    text-align: center;
}

.card-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    display: block;
}

.card-content h3 {
    font-size: 0.9rem;
    color: #666;
    font-weight: 600;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
}

.metric-subtitle {
    font-size: 0.85rem;
    color: #999;
    line-height: 1.4;
}

/* Weather Stats */
.weather-stats {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin-top: 15px;
}

.weather-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.weather-icon {
    font-size: 1.5rem;
}

.weather-item span:last-child {
    font-size: 1.2rem;
    font-weight: bold;
    color: #333;
}

/* Charts Section */
.charts-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

.chart-card {
    padding: 0;
    overflow: hidden;
}

.card-header {
    padding: 25px 30px;
    border-bottom: 1px solid #f0f0f0;
    background: #fafafa;
}

.card-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #333;
    font-weight: 600;
}

.chart-wrapper {
    padding: 20px 30px 30px;
    height: 300px;
    position: relative;
}

/* Table Card */
.table-card {
    padding: 0;
    overflow: hidden;
    margin-bottom: 40px;
}

.table-container {
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
}

/* Status Badges */
.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-block;
}

.status-badge.at-home {
    background: rgba(40, 167, 69, 0.1);
    color: #28a745;
    border: 1px solid rgba(40, 167, 69, 0.2);
}

.status-badge.not-home {
    background: rgba(108, 117, 125, 0.1);
    color: #6c757d;
    border: 1px solid rgba(108, 117, 125, 0.2);
}

/* Enhanced Data Table */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 0;
}

.data-table th {
    background: #f8f9fa;
    padding: 15px 20px;
    text-align: left;
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
    border-bottom: 2px solid #e9ecef;
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table td {
    padding: 15px 20px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: #f8f9fa;
}

/* Responsive Design */
@media (max-width: 768px) {
    .dashboard-container {
        padding: 15px;
    }
    
    .dashboard-header {
        padding: 20px;
        margin-bottom: 20px;
    }
    
    .dashboard-header h1 {
        font-size: 2rem;
    }
    
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    .dashboard-cards {
        grid-template-columns: repeat(5, 1fr);
        gap: 10px;
        margin-bottom: 30px;
    }
    
    .metric-card {
        padding: 20px;
    }
    
    .charts-section {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .chart-wrapper {
        height: 250px;
        padding: 15px 20px 20px;
    }
    
    .time-filter {
        margin-bottom: 20px;
    }
    
    .filter-btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 12px 15px;
        font-size: 0.9rem;
    }
    
    .table-container {
        max-height: 400px;
    }
}

@media (max-width: 480px) {
    .dashboard-container {
        padding: 10px;
    }

    .dashboard-header {
        padding: 15px;
    }

    .dashboard-header h1 {
        font-size: 1.8rem;
    }

    .header-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .header-actions a,
    .header-actions button {
        width: 100%;
        text-align: center;
    }
    
    .dashboard-cards {
        grid-template-columns: repeat(5, 1fr);
        gap: 5px;
    }

    .metric-card {
        padding: 15px;
    }

    .metric-value {
        font-size: 2rem;
    }
    
    .card-icon {
        font-size: 2.5rem;
    }
    
    .weather-stats {
        margin-top: 10px;
    }
    
    .chart-wrapper {
        height: 200px;
        padding: 10px 15px 15px;
    }
}

.entries-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.entry-card {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 15px;
    border: 1px solid #e0e0e0;
    transition: transform 0.3s, box-shadow 0.3s;
}

.entry-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #dee2e6;
}

.entry-date {
    font-weight: 600;
    color: #495057;
}

.noise-badge {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: white;
}

.noise-0,
.noise-1,
.noise-2,
.noise-3 {
    background: #4CAF50;
}

.noise-4,
.noise-5,
.noise-6 {
    background: #FFC107;
}

.noise-7,
.noise-8,
.noise-9,
.noise-10 {
    background: #F44336;
}

.entry-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-row {
    display: flex;
    font-size: 14px;
}

.detail-label {
    font-weight: 500;
    color: #6c757d;
    min-width: 100px;
}

.detail-value {
    color: #495057;
}

.no-entries {
    text-align: center;
    padding: 40px;
    color: #6c757d;
}

/* Table styles */
.table-container {
    overflow-x: auto;
    margin: 30px 0;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
    font-size: 15px;
}

.data-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.data-table th {
    padding: 18px 20px;
    text-align: left;
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    letter-spacing: 0.5px;
}

.data-table th:first-child {
    border-top-left-radius: 15px;
}

.data-table th:last-child {
    border-top-right-radius: 15px;
}

.data-table tbody tr {
    border-bottom: 1px solid #f0f0f0;
    transition: all 0.2s ease;
}

.data-table tbody tr:hover {
    background-color: #f8f9ff;
    transform: scale(1.01);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

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

.data-table tbody tr:last-child td:first-child {
    border-bottom-left-radius: 15px;
}

.data-table tbody tr:last-child td:last-child {
    border-bottom-right-radius: 15px;
}

.data-table td {
    padding: 15px 20px;
    font-size: 15px;
    color: #495057;
}

.data-table .noise-level-0,
.data-table .noise-level-1,
.data-table .noise-level-2,
.data-table .noise-level-3 {
    color: #4CAF50;
    font-weight: 600;
}

.data-table .noise-level-4,
.data-table .noise-level-5,
.data-table .noise-level-6 {
    color: #FFC107;
    font-weight: 600;
}

.data-table .noise-level-7,
.data-table .noise-level-8,
.data-table .noise-level-9,
.data-table .noise-level-10 {
    color: #F44336;
    font-weight: 600;
}

.data-table .notes-cell {
    max-width: 350px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-style: italic;
    color: #6c757d;
}

/* Grouped day styles */
.day-summary {
    background: linear-gradient(135deg, #f5f7ff 0%, #f0f2ff 100%);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.day-summary:hover {
    background: linear-gradient(135deg, #e8ebff 0%, #e0e4ff 100%);
    transform: none;
}

.day-summary td {
    padding: 18px 20px;
    border-top: 1px solid #e5e7eb;
}

.expand-icon {
    display: inline-block;
    width: 20px;
    margin-right: 10px;
    transition: transform 0.2s ease;
    color: #667eea;
    font-size: 12px;
}

.day-detail {
    background-color: #fafbff;
}

.day-detail:hover {
    background-color: #f5f7ff;
    transform: none;
    box-shadow: none;
}

.day-detail td {
    border-bottom: 1px solid #e8e8f0;
    font-size: 14px;
}

/* Mobile optimizations */
@media (max-width: 480px) {
    .container {
        padding: 20px;
        border-radius: 15px;
    }
    
    h1 {
        font-size: 20px;
    }
    
    .filter-section {
        grid-template-columns: 1fr;
    }
    
    .filter-section button {
        margin-top: 10px;
    }
    
    .radio-group {
        flex-direction: column;
    }
    
    .entry-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .data-table {
        font-size: 12px;
    }
    
    .data-table th,
    .data-table td {
        padding: 8px 6px;
    }
    
    .data-table .notes-cell {
        max-width: 100px;
    }
}