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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #8BC34A 0%, #689F38 100%);
    min-height: 100vh;
}

/* Login Screen */
.login-container {
    max-width: 400px;
    margin: 100px auto;
    background: white;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}

.login-container h1 {
    text-align: center;
    color: #2E7D32;
    margin-bottom: 10px;
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
}

.login-container input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

.login-container input:focus {
    outline: none;
    border-color: #4CAF50;
}

.login-container button {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #4CAF50, #66BB6A);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

.login-container button:hover {
    transform: translateY(-2px);
}

.switch-form {
    text-align: center;
    margin-top: 15px;
    font-size: 14px;
    color: #666;
}

.switch-form a {
    color: #4CAF50;
    text-decoration: none;
    font-weight: 600;
}

.error {
    background: #ffebee;
    color: #c62828;
    padding: 10px;
    border-radius: 8px;
    margin-top: 15px;
    text-align: center;
}

/* Dashboard */
header {
    background: white;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    color: #2E7D32;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.btn-logout {
    padding: 8px 16px;
    background: #f44336;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

/* Devices Section */
.devices-section {
    max-width: 1200px;
    margin: 30px auto;
    padding: 20px;
}

.devices-section h2 {
    color: white;
    margin-bottom: 20px;
}

#devicesList {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.device-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.2s;
}

.device-card:hover {
    transform: translateY(-4px);
}

.device-card h3 {
    color: #2E7D32;
    margin-bottom: 8px;
}

.device-card .status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    margin-top: 10px;
}

.device-card .status.active {
    background: #e8f5e9;
    color: #2e7d32;
}

.device-card .status.inactive {
    background: #ffebee;
    color: #c62828;
}

.last-seen {
    font-size: 12px;
    color: #999;
    margin-top: 8px;
}

.btn-add {
    padding: 12px 24px;
    background: linear-gradient(135deg, #4CAF50, #66BB6A);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
}

.modal-content h3 {
    color: #2E7D32;
    margin-bottom: 20px;
}

.modal-content input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
}

.modal-buttons button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.modal-buttons button:first-child {
    background: #4CAF50;
    color: white;
}

.btn-secondary {
    background: #ddd !important;
    color: #333 !important;
}

/* Device Details */
#deviceDetails {
    max-width: 1200px;
    margin: 30px auto;
    padding: 20px;
}

.device-header {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.device-header h2 {
    color: #2E7D32;
}

.device-header button {
    padding: 8px 16px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

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

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

.sensor-icon {
    font-size: 2em;
    margin-bottom: 10px;
}

.sensor-card h4 {
    color: #2E7D32;
    margin-bottom: 10px;
    font-size: 14px;
}

.sensor-value {
    font-size: 2em;
    font-weight: 700;
    color: #2E7D32;
    margin-bottom: 5px;
}

.sensor-time {
    font-size: 11px;
    color: #999;
}

/* Control Section */
.control-section {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 30px;
}

.control-section h3 {
    color: #2E7D32;
    margin-bottom: 15px;
}

.control-buttons {
    display: flex;
    gap: 15px;
}

.btn-control {
    flex: 1;
    padding: 15px;
    background: linear-gradient(135deg, #2196F3, #42A5F5);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-control:hover {
    transform: translateY(-2px);
}

/* Charts */
.charts-section {
    background: white;
    padding: 20px;
    border-radius: 12px;
}

.charts-section canvas {
    max-height: 300px;
    margin-bottom: 20px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .device-header {
        flex-direction: column;
        gap: 15px;
    }

    .sensor-grid {
        grid-template-columns: 1fr;
    }

    .control-buttons {
        flex-direction: column;
    }
}
