body {
    background-color: #0f1117;
    color: #e0e0e0;
    margin: 0;
    font-family: 'Inter', -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.page-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    padding: 2rem;
    min-height: 100vh;
    align-items: flex-start;
}

.panel {
    min-width: 0;
    background-color: #1a1d27;
    border: 1px solid #2a2d3a;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.tasmota-panel {
    background-color: #161922;
    border-color: #242735;
    grid-column: 1 / -1;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #2a2d3a;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
}

.panel-title {
    color: #aaa;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin: 0;
    font-weight: 600;
}

.connection-status {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: 4px;
}

.connection-status.connected { color: #10b981; background: rgba(16, 185, 129, 0.1); }
.connection-status.disconnected { color: #ef4444; background: rgba(239, 68, 68, 0.1); }

.modbus-global-controls {
    display: flex;
    gap: 0.5rem;
}

.modbus-global-controls .modbus-button {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
    background-color: transparent;
    border: 1px solid #2a2d3a;
    color: #888;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    white-space: nowrap;
}

.modbus-global-controls .modbus-button:hover {
    background: #2a2d3a;
    border-color: #3a3d4a;
    color: #fff;
}

.modbus-global-controls .modbus-button-open { color: #10b981; border-color: rgba(16, 185, 129, 0.2); }
.modbus-global-controls .modbus-button-close { color: #ef4444; border-color: rgba(239, 68, 68, 0.2); }

.modbus-channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 1px;
    background-color: #2a2d3a;
    border: 1px solid #2a2d3a;
    border-radius: 4px;
    overflow: hidden;
}

.modbus-channel-controls {
    background-color: #1a1d27;
    padding: 1.25rem 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    transition: background 0.2s;
}

.modbus-channel-controls.status-on { background-color: #1e2524; }

.modbus-channel-controls span {
    font-size: 0.8rem;
    font-weight: 500;
    color: #aaa;
    text-align: center;
}

.modbus-channel-controls.status-on span { color: #10b981; }

.modbus-button {
    width: 100%;
    padding: 0.4rem;
    font-size: 0.75rem;
    background: transparent;
    border: 1px solid #2a2d3a;
    color: #888;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.modbus-button:hover {
    border-color: #3a3d4a;
    color: #eee;
}

.status-on .modbus-button {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
    color: #10b981;
}

.tasmota-cards-container { margin-top: 0.5rem; }

.tasmota-card {
    background: #1a1d27;
    border: 1px solid #2a2d3a;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.card-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #2a2d3a;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.device-name { font-size: 0.85rem; font-weight: 600; color: #aaa; }
.type-badge { font-size: 0.65rem; color: #555; text-transform: uppercase; font-weight: 800; }

.body-container { padding: 1rem; }
.value-content {
    background: #0f1117;
    padding: 0.75rem;
    border-radius: 4px;
    border: 1px solid #2a2d3a;
    font-size: 0.75rem;
    color: #888;
    font-family: 'JetBrains Mono', monospace;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.command-title {
    font-size: 0.7rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.raw-toggle {
    background: transparent;
    border: none;
    color: #10b981;
    font-size: 0.7rem;
    cursor: pointer;
    font-family: inherit;
    padding: 0;
}

.raw-toggle:hover {
    color: #10b981;
    filter: brightness(1.2);
}

.raw-data {
    margin-top: 0.5rem;
    background: #0f1117;
    padding: 0.5rem;
    border-radius: 4px;
    border: 1px solid #2a2d3a;
    font-size: 0.7rem;
    color: #666;
    font-family: 'JetBrains Mono', monospace;
    white-space: pre-wrap;
}

/* --- Tasmota Buttons --- */
.relay-container {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.relay-btn {
    padding: 0.3rem 0.75rem;
    font-size: 0.75rem;
    background: transparent;
    border: 1px solid #2a2d3a;
    color: #888;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.relay-btn:hover {
    border-color: #3a3d4a;
    color: #eee;
    background-color: #2a2d3a;
}

.relay-btn.on {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
    color: #10b981;
}

@media (max-width: 1400px) {
    .page-split {
        grid-template-columns: 1fr;
    }
    .tasmota-panel {
        grid-column: auto;
    }
}
