body {
    background-color: #1a1a1a;
    color: #e0e0e0;
}

.modbus-channel-status {
    display: inline-block;
    width: 110px;
    font-family: monospace;
    color: #e0e0e0;
}

.modbus-global-controls {
    margin-bottom: 20px;
}

.modbus-channel-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 2rem;
    margin-top: 2rem;
    padding: 1rem;
    background-color: #2d2d2d;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.modbus-channel-controls {
    background-color: #3a3a3a;
    border: 1px solid #444;
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    min-height: 140px;
    position: relative;
}

/* Status background overlays */
.modbus-channel-controls.status-on {
    background: linear-gradient(145deg, rgba(76, 175, 80, 0.15), rgba(76, 175, 80, 0.08));
    border-color: rgba(76, 175, 80, 0.3);
}

.modbus-channel-controls.status-off {
    background: linear-gradient(145deg, rgba(244, 67, 54, 0.15), rgba(244, 67, 54, 0.08));
    border-color: rgba(244, 67, 54, 0.3);
}

.modbus-channel-controls:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.modbus-channel-controls span {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    text-align: center;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    width: 100%;
    color: #e0e0e0;
}

.modbus-button {
    width: 100%;
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    font-weight: bold;
    border-radius: 6px;
    background-color: #007bff;
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    align-self: stretch;
    margin-top: auto;
    box-sizing: border-box;
}

.modbus-button:hover {
    background-color: #0056b3;
    transform: scale(1.02);
}

.modbus-button-open {
    background-color: #4CAF50;
    color: white;
}

.modbus-button-close {
    background-color: #f44336;
    color: white;
}

.modbus-button-refresh {
    background-color: #ffd700;
    color: #000;
    font-weight: bold;
}

.modbus-button-open:hover,
.modbus-button-close:hover {
    transform: scale(1.05);
}

.modbus-button-refresh:hover {
    background-color: #ffe44d;
}

.tasmota-cards-container {
    max-width: 1600px;
    margin: 20px auto;
    font-family: Arial, sans-serif;
    color: #e0e0e0;
}

.tasmota-card {
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(255, 255, 255, 0.1);
    margin-bottom: 16px;
    overflow: hidden;
    background-color: #2d2d2d;
}

.card-header {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: #3a3a3a;
}

.type-badge {
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    background-color: #555;
}

.device-name {
    font-weight: bold;
    color: #ffffff;
}

.card-body {
    padding: 16px;
    background-color: #2d2d2d;
    border-top: 1px solid #444;
}

.value-section {
    margin-top: 12px;
}

.value-content {
    background-color: #3a3a3a;
    padding: 8px;
    border-radius: 4px;
    max-height: 200px;
    overflow: auto;
    border: 1px solid #444;
}

.raw-toggle {
    margin-top: 12px;
    background: none;
    border: none;
    color: #81d4fa;
    cursor: pointer;
    font-size: 14px;
    transition: color 0.2s ease;
}

.raw-toggle:hover {
    color: #29b6f6;
}

.raw-data {
    margin-top: 8px;
    padding: 8px;
    background-color: #3a3a3a;
    border-radius: 4px;
    font-size: 12px;
    white-space: pre-wrap;
    color: #e0e0e0;
    border: 1px solid #444;
}

.command-section {
    margin: 10px 0;
    padding: 15px;
    background: #2d2d2d;
    border-radius: 6px;
    border: 1px solid #444;
}

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

.command-title {
    font-weight: bold;
    color: #FFF;
}

.body-container {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background-color: #2d2d2d;
    border-radius: 6px;
    border: 1px solid #444;
}

.command-section.updated {
    animation: section-highlight-dark 0.5s ease-out;
}

@keyframes section-highlight-dark {
    0% { background-color: rgba(255, 235, 59, 0.3); }
    100% { background-color: #2d2d2d; }
}

.modbus-channel-status.named-channel {
    font-weight: bold;
    color: #007bff;
}

.modbus-channel-status.default-channel {
    color: #555;
}

@media (max-width: 1200px) {
    .modbus-channel-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    .modbus-channel-grid {
        grid-template-columns: 1fr;
    }

    .modbus-button {
        padding: 0.8rem 1rem;
        font-size: 1rem;
    }
}

.all-relays-btn {
    margin-left: auto;
    margin-right: 10px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: bold;
    border-radius: 4px;
    background-color: #1976d2;
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.all-relays-btn:hover {
    background-color: #1565c0;
}