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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 20px 30px;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

header h1 {
    color: white;
    font-size: 2rem;
    font-weight: 600;
}

.refresh-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    font-size: 0.9rem;
}

.dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.device-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

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

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

.device-id {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2d3748;
    word-break: break-all;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-active {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.status-offline {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.device-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-size: 0.9rem;
    color: #64748b;
    font-weight: 500;
}

.info-value {
    font-size: 0.9rem;
    color: #334155;
    font-weight: 600;
}

.last-active {
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 10px;
    text-align: center;
    padding: 8px;
    background: #f8fafc;
    border-radius: 8px;
}

.no-devices {
    text-align: center;
    padding: 60px 20px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
}

.no-devices h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    opacity: 0.9;
}

.no-devices p {
    opacity: 0.7;
    font-size: 1rem;
}

.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    color: white;
    font-size: 1.1rem;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
        padding: 20px;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .devices-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .device-card {
        padding: 20px;
    }
    
    .device-id {
        font-size: 1rem;
    }
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 15px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #e2e8f0;
}

.modal-header h2 {
    margin: 0;
    color: #1e293b;
    font-size: 1.5rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    color: #64748b;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: #f1f5f9;
    color: #334155;
}

.modal-body {
    padding: 25px;
}

.device-detail {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.detail-section {
    background: #f8fafc;
    border-radius: 10px;
    padding: 20px;
}

.detail-section h3 {
    margin: 0 0 15px 0;
    color: #334155;
    font-size: 1.2rem;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 8px;
}

.sensor-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.sensor-item {
    background: white;
    border-radius: 8px;
    padding: 15px;
    border-left: 4px solid #3b82f6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.sensor-key {
    font-weight: 600;
    color: #1e293b;
    font-size: 0.9rem;
    margin-bottom: 5px;
    text-transform: capitalize;
}

.sensor-value {
    font-size: 1.1rem;
    color: #059669;
    font-weight: 700;
}

.control-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.servo-container {
    grid-column: 1 / -1;
    min-width: 300px;
}

.control-item {
    background: white;
    border-radius: 8px;
    padding: 12px;
    border-left: 4px solid #f59e0b;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    text-align: center;
}

.control-key {
    font-weight: 600;
    color: #1e293b;
    font-size: 0.8rem;
    margin-bottom: 3px;
    text-transform: capitalize;
}

.control-value {
    font-size: 1rem;
    color: #dc2626;
    font-weight: 700;
}

/* Interactive Controls */
.control-interactive {
    background: white;
    border-radius: 8px;
    padding: 15px;
    border-left: 4px solid #f59e0b;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.led-button {
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.led-button.on {
    background: #22c55e;
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.3);
}

.led-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.led-button:active {
    transform: translateY(0);
}

.servo-control {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.servo-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e2e8f0;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.servo-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.servo-slider::-webkit-slider-thumb:hover {
    background: #2563eb;
    transform: scale(1.1);
}

.servo-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.servo-value {
    text-align: center;
    font-weight: 600;
    color: #3b82f6;
    font-size: 1.1rem;
}

.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.loading-spinner .spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #e2e8f0;
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }
    
    .device-card {
        padding: 15px;
    }
    
    .device-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .status-badge {
        align-self: flex-end;
    }
    
    .modal-content {
        width: 95%;
        margin: 10px;
    }
    
    .modal-header {
        padding: 15px 20px;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .sensor-list {
        grid-template-columns: 1fr;
    }
    
    .control-list {
        grid-template-columns: repeat(2, 1fr);
    }
}
