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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(160deg, #0c1a2e 0%, #1a3550 100%);
    min-height: 100vh;
    padding: 20px;
}

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

header {
    color: white;
    margin-bottom: 40px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-content > div:first-child {
    text-align: center;
    flex: 1;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

.build-info {
    font-size: 0.75rem;
    opacity: 0.7;
    text-align: right;
    white-space: nowrap;
    line-height: 1.4;
}

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

.card {
    background: white;
    border-radius: 10px;
    padding: 25px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    position: relative;
    transition: box-shadow 0.2s;
}

.card.full-width {
    grid-column: 1 / -1;
}

.card.wide {
    grid-column: span 2;
}

/* Drag and drop */
.card-drag-handle {
    position: absolute;
    top: 8px;
    right: 12px;
    cursor: grab;
    font-size: 1.2rem;
    color: #ccc;
    user-select: none;
    padding: 4px 6px;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
    z-index: 1;
}

.card-drag-handle:hover {
    color: #3b82f6;
    background: #f0f0f0;
}

.card-drag-handle:active {
    cursor: grabbing;
}

.card.dragging {
    opacity: 0.5;
    box-shadow: 0 15px 40px rgba(0,0,0,0.3);
}

.card.drag-over {
    border: 2px dashed #3b82f6;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.2);
}

.card h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5rem;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 10px;
}

.status-content {
    font-size: 1rem;
    color: #555;
}

.loading {
    text-align: center;
    color: #999;
    padding: 20px;
    font-style: italic;
}

.status-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.status-item:last-child {
    border-bottom: none;
}

.status-label {
    font-weight: 600;
    color: #64748b;
}

.status-value {
    color: #333;
}

.recommendations-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.recommendation {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #3b82f6;
}

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

.recommendation-action {
    font-weight: 600;
    color: #333;
    font-size: 1.1rem;
}

.recommendation-time {
    color: #64748b;
    font-size: 0.9rem;
}

.recommendation-reason {
    color: #666;
    font-size: 0.95rem;
    line-height: 1.4;
}

.recommendation-savings {
    margin-top: 8px;
    color: #28a745;
    font-weight: 600;
}

.savings-content {
    text-align: center;
}

.savings-amount {
    font-size: 3rem;
    color: #28a745;
    font-weight: bold;
    margin: 20px 0;
}

.savings-label {
    font-size: 1.2rem;
    color: #666;
}

.controls {
    text-align: center;
}

.btn-primary {
    background: #1e40af;
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.1rem;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: background 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    background: #1d4ed8;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.btn-primary:active {
    transform: translateY(0);
}

.price-table {
    width: 100%;
}

.price-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

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

.price-time {
    color: #64748b;
    font-weight: 500;
}

.price-value {
    font-weight: 600;
    color: #333;
}

.price-high {
    color: #dc3545;
}

.price-low {
    color: #28a745;
}

.error {
    color: #dc3545;
    text-align: center;
    padding: 20px;
    background: #f8d7da;
    border-radius: 5px;
    border: 1px solid #f5c6cb;
}

/* Battery Status Styles */
.battery-display {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.soc-circle {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 8px solid;
    transition: all 0.3s ease;
}

.soc-high {
    border-color: #28a745;
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
}

.soc-medium {
    border-color: #ffc107;
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
}

.soc-low {
    border-color: #dc3545;
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
}

.charging-badge {
    display: inline-block;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.charging-active {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.charging-idle {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.charging-disconnected {
    background: #e9ecef;
    color: #6c757d;
    border: 1px solid #dee2e6;
}

.soc-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: #333;
}

.soc-label {
    font-size: 0.85rem;
    color: #666;
    margin-top: 5px;
}

.status-active {
    color: #28a745;
    font-weight: bold;
}

/* Battery Values Grid */
.battery-values-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 15px 0 8px;
}

.bv-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 10px 12px;
    text-align: center;
}

.bv-label {
    font-size: 0.72rem;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 4px;
}

.bv-value {
    font-size: 1.0rem;
    font-weight: 600;
    color: #333;
}

.bv-timestamp {
    font-size: 0.72rem;
    color: #bbb;
    text-align: right;
}

/* Modbus Registers Block */
.modbus-registers {
    margin-top: 14px;
    border-top: 1px solid #eee;
    padding-top: 10px;
}

.modbus-header {
    font-size: 0.70rem;
    text-transform: uppercase;
    color: #aaa;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.modbus-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.modbus-table tr {
    border-bottom: 1px solid #f5f5f5;
}

.modbus-table tr:last-child {
    border-bottom: none;
}

.reg-addr {
    font-family: monospace;
    color: #bbb;
    width: 42px;
    padding: 3px 6px 3px 0;
}

.reg-name {
    color: #666;
    padding: 3px 8px;
}

.reg-value {
    font-weight: 600;
    color: #333;
    text-align: right;
    padding: 3px 0;
}

/* Cheapest Hours Styles */
.hours-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.hour-slot {
    background: #1e3a5f;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    color: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.hour-time {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 8px;
}

.hour-price {
    font-size: 1.1rem;
    margin-bottom: 5px;
}

.hour-rank {
    font-size: 0.85rem;
    opacity: 0.9;
}

.hours-summary {
    display: flex;
    justify-content: space-around;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.summary-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 5px;
}

.summary-value {
    font-size: 1.2rem;
    font-weight: bold;
    color: #1e40af;
}

/* Charging Schedule Styles */
.schedule-strategy {
    background: #1e3a5f;
    color: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
}

.schedule-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.info-item {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
}

.info-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 5px;
}

.info-value {
    font-size: 1.2rem;
    font-weight: bold;
    color: #1e40af;
}

.schedule-slots {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.schedule-slot {
    padding: 12px;
    border-radius: 8px;
    border-left: 4px solid;
}

.slot-active {
    background: #d4edda;
    border-color: #28a745;
}

.slot-inactive {
    background: #f8f9fa;
    border-color: #6c757d;
}

.slot-time {
    font-weight: bold;
    color: #333;
    font-size: 1.1rem;
}

.slot-price {
    color: #64748b;
    font-weight: 600;
    margin: 5px 0;
}

.slot-status {
    font-weight: bold;
    margin: 5px 0;
}

.slot-active .slot-status {
    color: #28a745;
}

.slot-inactive .slot-status {
    color: #6c757d;
}

.slot-reason {
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
}

/* Price Graph Styles */
.price-graph {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 200px;
    padding: 20px 10px;
    background: linear-gradient(to top, #f8f9fa 0%, transparent 100%);
    border-radius: 8px;
    margin-bottom: 15px;
}

.price-bar-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    position: relative;
    min-width: 20px;
}

.price-bar {
    width: 100%;
    border-radius: 4px 4px 0 0;
    transition: all 0.3s ease;
    position: relative;
    cursor: pointer;
}

.bar-normal {
    background: linear-gradient(to top, #1e40af 0%, #3b82f6 100%);
}

.bar-high {
    background: linear-gradient(to top, #dc3545 0%, #c82333 100%);
}

.bar-low {
    background: linear-gradient(to top, #28a745 0%, #218838 100%);
}

.bar-current {
    background: linear-gradient(to top, #ffc107 0%, #e0a800 100%);
    box-shadow: 0 0 8px rgba(255, 193, 7, 0.6);
}

.bar-container-current {
    position: relative;
}

.label-current {
    color: #333;
    font-weight: 700;
}

.price-bar:hover {
    opacity: 0.8;
    transform: scaleY(1.05);
}

.price-tooltip {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    white-space: nowrap;
    font-size: 0.85rem;
    z-index: 10;
    margin-bottom: 5px;
}

.price-bar:hover .price-tooltip {
    display: block;
}

.price-bar-label {
    font-size: 0.7rem;
    color: #666;
    margin-top: 5px;
    transform: rotate(-45deg);
    white-space: nowrap;
}

.price-summary {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
}

.price-range {
    font-weight: 600;
    color: #1e40af;
}

.price-section-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 8px;
    margin-bottom: 4px;
}

.price-section-label:first-child {
    margin-top: 0;
}

.price-tomorrow-unavailable {
    font-size: 0.85rem;
    color: #94a3b8;
    font-style: italic;
    margin-top: 16px;
    padding: 10px;
    border-top: 1px solid #e2e8f0;
}

/* Battery Control Styles */
.control-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.control-mode {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
}

.mode-label {
    font-weight: 600;
    color: #64748b;
}

.mode-value {
    font-weight: bold;
    font-size: 1.1rem;
}

.mode-off { color: #6c757d; }
.mode-manual { color: #6c757d; }
.mode-auto { color: #28a745; }
.mode-charge { color: #e6a500; }
.mode-discharge { color: #fd7e14; }
.mode-charging { color: #28a745; }
.mode-discharging { color: #fd7e14; }
.mode-idle { color: #6c757d; }

.control-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
    gap: 10px;
}

.btn-control {
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    color: white;
}

.btn-control:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.btn-control:active {
    transform: translateY(0);
}

.btn-off {
    background: #343a40;
}

.btn-manual {
    background: #6c757d;
}

.btn-auto {
    background: #28a745;
}

.btn-charge {
    background: #ffc107;
    color: #333;
}

.btn-discharge {
    background: #dc3545;
}

.control-power {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.control-power label {
    font-size: 0.9rem;
    color: #555;
    white-space: nowrap;
}

.control-power input {
    width: 120px;
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    text-align: right;
}

.control-power input:focus {
    border-color: #3b82f6;
    outline: none;
}

.threshold-section {
    border-top: 1px solid #eee;
    padding-top: 15px;
}

.threshold-section h3 {
    font-size: 1rem;
    color: #475569;
    margin-bottom: 10px;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.register-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.register-row .reg-label {
    flex: 1;
    font-size: 0.85rem;
    color: #aaa;
}

.register-row input {
    width: 90px;
    padding: 6px 8px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    text-align: right;
}

.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
}

.toggle-hint {
    font-size: 0.8rem;
    color: #999;
    font-style: italic;
    margin-top: 4px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #ccc;
    border-radius: 26px;
    transition: 0.3s;
}

.toggle-slider:before {
    content: "";
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background: #1e40af;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

.control-status {
    text-align: center;
    padding: 8px;
    border-radius: 6px;
    font-weight: 500;
    min-height: 36px;
}

.status-pending {
    background: #fff3cd;
    color: #856404;
}

.status-ok {
    background: #d4edda;
    color: #155724;
}

.status-error {
    background: #f8d7da;
    color: #721c24;
}

/* Action Log Styles */
.log-content {
    max-height: 400px;
    overflow-y: auto;
}

.log-entries {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.log-entry {
    padding: 10px 12px;
    border-radius: 6px;
    border-left: 4px solid #6c757d;
    background: #f8f9fa;
}

.log-entry.log-charge { border-color: #28a745; }
.log-entry.log-discharge { border-color: #dc3545; }
.log-entry.log-auto { border-color: #6c757d; }
.log-entry.log-off { border-color: #343a40; }
.log-entry.log-calc { border-color: #3b82f6; }
.log-entry.log-decision { border-color: #ffc107; }
.log-entry.log-optimize { border-color: #1e40af; }

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

.log-action {
    font-weight: 700;
    font-size: 0.9rem;
    color: #333;
}

.log-time {
    font-size: 0.8rem;
    color: #888;
}

.log-description {
    font-size: 0.85rem;
    color: #555;
    line-height: 1.3;
}

.log-price {
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 500;
}

/* Charging Cost Styles */
.cost-summary {
    text-align: center;
}

.cost-main {
    margin-bottom: 20px;
}

.cost-main .cost-value {
    font-size: 3rem;
    font-weight: bold;
    color: #1e40af;
    display: block;
}

.cost-main .cost-label {
    font-size: 1.1rem;
    color: #666;
}

.cost-details {
    display: flex;
    justify-content: space-around;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
}

.cost-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.cost-label {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 4px;
}

.cost-value-sm {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
}

/* Energy flow card */
.energy-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    text-align: center;
}

.energy-item {
    padding: 10px 4px;
    background: #f8f9fa;
    border-radius: 8px;
}

.energy-icon {
    font-size: 1.8rem;
    margin-bottom: 4px;
}

.energy-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: #333;
}

.energy-label {
    font-size: 0.8rem;
    color: #666;
    margin-top: 2px;
}

/* ===== Responsive / Mobile ===== */

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    header {
        margin-bottom: 20px;
    }

    .header-content {
        flex-direction: column;
        gap: 8px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .build-info {
        text-align: center;
    }

    .dashboard {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .card.wide {
        grid-column: 1 / -1;
    }

    .card {
        padding: 16px;
    }

    .card h2 {
        font-size: 1.2rem;
        margin-bottom: 12px;
        padding-bottom: 8px;
    }

    /* Control buttons: 2+3 grid (5 buttons) */
    .control-buttons {
        grid-template-columns: 1fr 1fr 1fr;
    }

    /* Control power rows: stack on narrow screens */
    .control-power {
        flex-wrap: wrap;
    }

    .control-power label {
        flex: 1 1 100%;
        margin-bottom: 4px;
    }

    .control-power input {
        flex: 1;
        min-width: 80px;
    }

    /* Price graph: allow horizontal scroll */
    .price-graph {
        overflow-x: auto;
        padding: 15px 5px;
        min-width: 0;
    }

    .price-bar-container {
        min-width: 16px;
    }

    .price-bar-label {
        font-size: 0.6rem;
    }

    .price-summary {
        flex-direction: column;
        gap: 6px;
        text-align: center;
    }

    /* Energy grid: 2 columns */
    .energy-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Hours grid */
    .hours-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 10px;
    }

    .hours-summary {
        flex-direction: column;
        gap: 10px;
    }

    /* Schedule info */
    .schedule-info {
        grid-template-columns: 1fr;
    }

    /* Cost details */
    .cost-details {
        flex-direction: column;
        gap: 8px;
    }

    .cost-main .cost-value {
        font-size: 2.2rem;
    }

    /* Savings */
    .savings-amount {
        font-size: 2.2rem;
    }

    /* SOC circle */
    .soc-circle {
        width: 120px;
        height: 120px;
    }

    .soc-value {
        font-size: 2rem;
    }

    /* Recommendation header */
    .recommendation-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    /* Debug controls: wrap */
    .debug-controls {
        flex-wrap: wrap;
        gap: 10px;
    }

    /* Debug entries: allow wrapping */
    .debug-entry {
        flex-wrap: wrap;
        font-size: 0.7rem;
        gap: 4px;
    }

    .debug-source {
        min-width: 70px;
    }

    .debug-details {
        flex-basis: 100%;
        padding-left: 4px;
    }

    .log-logger {
        min-width: 80px;
    }

    /* Bottom controls */
    .controls {
        display: flex;
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }

    .btn-primary {
        padding: 12px 30px;
        font-size: 1rem;
        width: 100%;
        max-width: 300px;
    }

    #reset-layout-btn {
        margin-left: 0 !important;
    }
}

@media (max-width: 400px) {
    header h1 {
        font-size: 1.2rem;
    }

    .control-buttons {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 6px;
    }

    .btn-control {
        padding: 10px;
        font-size: 0.85rem;
    }

    .price-bar-label {
        font-size: 0.5rem;
    }

    .energy-icon {
        font-size: 1.4rem;
    }

    .energy-value {
        font-size: 1rem;
    }
}

/* Debug log */
.debug-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.debug-controls .toggle-row {
    margin: 0;
}

.debug-log-content {
    max-height: 500px;
    overflow-y: auto;
    background: #1e1e1e;
    border-radius: 6px;
    padding: 10px;
}

.debug-placeholder {
    color: #888;
    font-style: italic;
    padding: 20px;
    text-align: center;
}

.debug-entries {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.debug-entry {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 3px 8px;
    border-left: 3px solid;
    font-family: 'Courier New', Consolas, monospace;
    font-size: 0.8rem;
    line-height: 1.4;
    background: #2a2a2a;
    border-radius: 2px;
}

/* Modbus READ — cyan/blue */
.debug-entry.debug-read {
    border-color: #17a2b8;
}
.debug-read .debug-source { color: #5bc0de; }
.debug-read .debug-operation { color: #5bc0de; }

/* Modbus WRITE / CONNECT — orange */
.debug-entry.debug-write {
    border-color: #e67e22;
}
.debug-write .debug-source { color: #f0ad4e; }
.debug-write .debug-operation { color: #f0ad4e; }

/* HA GET — green */
.debug-entry.debug-get {
    border-color: #28a745;
}
.debug-get .debug-source { color: #5cb85c; }
.debug-get .debug-operation { color: #5cb85c; }

/* HA POST — purple */
.debug-entry.debug-post {
    border-color: #8e44ad;
}
.debug-post .debug-source { color: #bb8fce; }
.debug-post .debug-operation { color: #bb8fce; }

/* Errors — red */
.debug-entry.debug-error {
    border-color: #dc3545;
}
.debug-error .debug-source { color: #ff6b6b; }
.debug-error .debug-operation { color: #ff6b6b; }

/* Fallback */
.debug-entry.debug-other {
    border-color: #555;
}
.debug-other .debug-source { color: #aaa; }
.debug-other .debug-operation { color: #e0c46c; }

.debug-time {
    color: #888;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.debug-source {
    font-weight: 700;
    font-size: 0.7rem;
    flex-shrink: 0;
    min-width: 90px;
}

.debug-direction {
    color: #ccc;
    flex-shrink: 0;
}

.debug-operation {
    font-weight: 600;
    flex-shrink: 0;
}

.debug-details {
    color: #ccc;
    word-break: break-all;
}

/* Debug tabs */
.debug-tabs {
    display: flex;
    gap: 4px;
}

.debug-tab {
    padding: 4px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f0f0f0;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    color: #555;
}

.debug-tab.active {
    background: #333;
    color: #fff;
    border-color: #333;
}

/* Backend log levels */
.log-entry {
    border-color: #555;
}

.log-entry.log-error {
    border-color: #dc3545;
}

.log-entry.log-warn {
    border-color: #ffc107;
}

.log-entry.log-info {
    border-color: #17a2b8;
}

.log-entry.log-debug {
    border-color: #6c757d;
}

.log-level {
    font-weight: 700;
    font-size: 0.7rem;
    flex-shrink: 0;
    min-width: 42px;
}

.log-error .log-level {
    color: #ff6b6b;
}

.log-warn .log-level {
    color: #ffc107;
}

.log-info .log-level {
    color: #5bc0de;
}

.log-debug .log-level {
    color: #888;
}

.log-logger {
    color: #b8b8b8;
    font-size: 0.7rem;
    flex-shrink: 0;
    min-width: 120px;
}

/* --- Modbus Register Table --- */
.card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.card-header-row h2 {
    margin-bottom: 0;
}

.register-content {
    overflow-x: auto;
}

.reg-disabled {
    color: #94a3b8;
    font-style: italic;
    padding: 12px 0;
    font-size: 0.9rem;
}

.reg-timestamp {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-bottom: 8px;
    text-align: right;
}

.register-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.83rem;
}

.register-table thead th {
    background: #f1f5f9;
    color: #64748b;
    padding: 6px 10px;
    text-align: left;
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #e2e8f0;
}

.register-table tbody td {
    padding: 5px 10px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.register-table tbody tr:last-child td {
    border-bottom: none;
}

.register-table tbody tr:hover td {
    background: #fafbfc;
}

.reg-section-header td {
    background: #e2e8f0;
    color: #475569;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 4px 10px;
}

.reg-addr {
    color: #94a3b8;
    font-family: monospace;
    font-size: 0.78rem;
    white-space: nowrap;
}

.reg-type {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
    white-space: nowrap;
}

.reg-type-H {
    background: #ede9fe;
    color: #6d28d9;
}

.reg-type-I {
    background: #ccfbf1;
    color: #0f766e;
}

.reg-name {
    color: #334155;
}

.reg-value {
    font-family: monospace;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
}

.reg-unit {
    color: #94a3b8;
    font-size: 0.78rem;
}
