* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

header h1 {
    color: #333;
    font-size: 24px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #e74c3c;
    transition: background 0.3s;
}

.status-dot.connected {
    background: #2ecc71;
}

.status-text {
    color: #666;
    font-size: 14px;
}

.config-panel {
    background: white;
    padding: 30px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.config-panel h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 20px;
}

.config-info {
    margin-bottom: 20px;
}

.config-info p {
    color: #666;
    font-size: 14px;
    margin-bottom: 10px;
}

.config-info span {
    font-weight: 600;
    color: #333;
}

.config-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    align-items: end;
}

.connect-btn {
    width: auto;
    white-space: nowrap;
}

.form-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
}

.form-row .form-group {
    flex: 1;
}

.form-group label {
    color: #000;
    font-size: 14px;
    font-weight: 500;
    min-width: 80px;
    white-space: nowrap;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="time"],
.form-group select {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.3s;
    flex: 1;
    min-width: 0;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
}

.btn-success {
    background: #2ecc71;
    color: white;
}

.btn-success:hover {
    background: #27ae60;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.device-id-container {
    display: flex;
    gap: 10px;
    align-items: center;
    flex: 1;
}

.device-id-container input {
    flex: 1;
    min-width: 300px;
}

/* 密码框样式 */
.form-group.password-group {
    flex: 1;
}

.form-group.password-group input[type="password"] {
    width: 100%;
    min-width: 150px;
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 20px;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.modal-content h3 {
    margin-bottom: 20px;
    color: #333;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

.qr-scanner {
    margin: 20px 0;
    position: relative;
}

.qr-scanner video {
    border: 2px solid #ddd;
    border-radius: 5px;
}

.scanner-status {
    text-align: center;
    margin-top: 15px;
    color: #666;
    font-size: 14px;
}

.dashboard {
    display: grid;
    gap: 20px;
}

.telemetry-section,
.control-section,
.timer-section,
.log-section {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.telemetry-section h2,
.control-section h2,
.timer-section h2,
.log-section h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 20px;
}

.telemetry-grid {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.telemetry-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 25px;
    border-radius: 10px;
    color: white;
    position: relative;
    overflow: hidden;
}

.telemetry-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

.card-icon {
    font-size: 40px;
    margin-bottom: 10px;
}

.card-label {
    font-size: 14px;
    opacity: 0.9;
}

.card-value {
    font-size: 36px;
    font-weight: bold;
    margin: 10px 0;
}

.card-unit {
    font-size: 18px;
    opacity: 0.8;
}

.card-timestamp {
    font-size: 12px;
    opacity: 0.7;
    margin-top: 10px;
}

.refresh-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.refresh-controls label {
    color: #666;
    font-size: 14px;
}

.refresh-controls input[type="number"] {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
    width: 80px;
}

.control-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.control-card {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
}

.control-label {
    color: #333;
    font-size: 16px;
    margin-bottom: 15px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #2ecc71;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.mode-select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    background: white;
}

.config-actions {
    margin-top: 30px;
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
}

.config-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.timer-config .form-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.timer-config .form-group {
    flex: 1;
    min-width: 150px;
}

.temp-config .form-group {
    margin-bottom: 15px;
}

.config-section {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.config-section h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 20px;
}

.timer-form label {
    color: #666;
    font-size: 14px;
    margin-bottom: 5px;
}

.timer-form label input[type="checkbox"] {
    margin-right: 5px;
}

.timer-form-row {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.form-group-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group-inline label {
    color: #000;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}

.form-group-inline input[type="text"],
.form-group-inline input[type="time"],
.form-group-inline select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group-inline input:focus,
.form-group-inline select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.timer-list {
    max-height: 300px;
    overflow-y: auto;
}

.no-timers {
    text-align: center;
    color: #999;
    padding: 20px;
}

.timer-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 10px;
}

.timer-info {
    flex: 1;
}

.timer-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.timer-details {
    display: flex;
    gap: 10px;
    font-size: 13px;
    color: #666;
}

.timer-time,
.timer-action,
.timer-repeat {
    background: white;
    padding: 3px 8px;
    border-radius: 4px;
}

.timer-actions {
    display: flex;
    gap: 10px;
}

.btn-toggle {
    padding: 5px 10px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s;
}

.btn-toggle.active {
    background: #2ecc71;
    color: white;
    border-color: #2ecc71;
}

.btn-delete {
    padding: 5px 10px;
    border: 1px solid #e74c3c;
    background: white;
    color: #e74c3c;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s;
}

.btn-delete:hover {
    background: #e74c3c;
    color: white;
}

.log-container {
    max-height: 300px;
    overflow-y: auto;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.log-item {
    display: flex;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #e0e0e0;
    font-size: 13px;
}

.log-item:last-child {
    border-bottom: none;
}

.log-time {
    color: #999;
    min-width: 80px;
}

.log-message {
    flex: 1;
}

.log-success {
    color: #2ecc71;
}

.log-error {
    color: #e74c3c;
}

.log-info {
    color: #3498db;
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .config-form {
        grid-template-columns: 1fr;
    }

    .telemetry-grid {
        grid-template-columns: 1fr;
    }

    .control-grid {
        grid-template-columns: 1fr;
    }

    .timer-form {
        grid-template-columns: 1fr;
    }

    .refresh-controls {
        flex-direction: column;
        align-items: stretch;
    }
}

/* 连接配置水平布局 */
.config-form-row {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: stretch;
}

.device-id-group {
    width: 100%;
}

.device-id-container {
    display: flex;
    gap: 10px;
    align-items: center;
    width: 100%;
}

.device-id-container input {
    flex: 1;
    min-width: 0;
}

.scan-btn {
    white-space: nowrap;
}

.connect-btn {
    white-space: nowrap;
    width: 100%;
}

/* 响应式调整 */
@media (min-width: 768px) {
    .config-form-row {
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
    }
    
    .device-id-group {
        flex: 1;
        min-width: 400px;
    }
    
    .connect-btn {
        width: auto;
    }
}

/* 移动设备配置参数编辑框修复 */
@media (max-width: 768px) {
    .form-group {
        flex-direction: column;
        align-items: stretch;
        text-align: left;
    }
    
    .form-group label {
        min-width: 100%;
        margin-bottom: 5px;
    }
    
    .form-group input[type="number"] {
        width: 100%;
        min-width: 200px;
        padding: 12px;
        font-size: 16px;
        color: #333;
        background: white;
        border: 1px solid #ddd;
        border-radius: 5px;
    }
    
    .form-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .config-grid {
        grid-template-columns: 1fr;
    }
}

/* 温湿度显示 - 确保flex布局 */
.telemetry-grid {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.telemetry-card {
    flex: 1;
    min-width: 200px;
}

@media (max-width: 768px) {
    .telemetry-grid {
        flex-direction: column;
    }
    
    .telemetry-card {
        width: 100%;
    }
}