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

body {
    font-family: 'Arial', sans-serif;
    background: #1a1a1a;
    color: #ffffff;
}

.timestamp-row {
    text-align: center;
    margin: 0px 0;
    padding: 0px;
}

.timestamp-value {
    /* font-family: 'Courier New', monospace; */
    font-size: 10px;
    color: #ffdd01;
}

.container {
    max-width: 400px;
    margin: 0 auto;
    background: #1F1E23;
    border-radius: 6px;
    padding: 1px;
    border: 1px solid #444;
}

/* Update brand-section to accommodate left menu */
.brand-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #2a2a2a;
    border-radius: 3px;
    padding: 8px 12px;
    margin-bottom: 0px;
    border: 1px solid #1F1E23;
    position: relative;
    gap: 8px; /* Add gap between left menu and title */
}

.brand-title {
    color: #f4b26b;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    flex: 1;
    margin: 0; /* Remove default margin */
}

/* Menu Container */
.menu-container {
    position: relative;
    display: inline-block;
}

.menu-button {
    background: #3a3a3a;
    border: 1px solid #555;
    border-radius: 4px;
    color: #ffffff;
    cursor: pointer;
    padding: 6px 10px;
    font-size: 14px;
    transition: all 0.3s ease;
    min-width: 40px;
}

.menu-button:hover {
    background: #4a4a4a;
    border-color: #42C949;
}

.menu-button:active {
    background: #2a2a2a;
}

.menu-icon {
    display: block;
    line-height: 1;
}

/* Dropdown Menu */
.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: #2a2a2a;
    border: 1px solid #555;
    border-radius: 4px;
    min-width: 140px;
    z-index: 1000;
    margin-top: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.dropdown-menu.show {
    display: block;
}

.menu-item {
    padding: 10px 12px;
    color: #ffffff;
    cursor: pointer;
    border-bottom: 1px solid #3a3a3a;
    transition: all 0.2s ease;
    font-size: 13px;
}

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

.menu-item:hover {
    background: #42C949;
    color: #1a1a1a;
}

.menu-item:active {
    background: #3a9c3f;
}

/* Time Section - moved to top and centered */
.time-section {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #3a3a3a;
    border-radius: 3px;
    padding: 6px 8px;
    margin-bottom: 0px;
    border: 1px solid #1F1E23;
    gap: 8px;
}

.time-label {
    color: #cccccc;
    font-size: 13px;
}

.time-value {
    color: #ffffff;
    font-weight: bold;
    font-size: 13px;
}

/* Updated Status Section - labels and values in same row, centered */
.status-section {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: #3a3a3a;
    border-radius: 3px;
    padding: 6px 8px;
    margin-bottom: 0px;
    border: 1px solid #1F1E23;
}

.status-item {
    display: flex;
    flex-direction: row; /* Changed from column to row */
    align-items: center;
    justify-content: center; /* Center content horizontally */
    gap: 6px; /* Increased gap for better spacing */
}

.status-label {
    color: #cccccc;
    font-size: 12px;
    white-space: nowrap; /* Prevent text wrapping */
}

.status-value {
    font-size: 12px;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 8px;
    min-width: 35px;
    text-align: center;
    white-space: nowrap; /* Prevent text wrapping */
}

.status-value.on {
    background: #00aa00;
    color: #ffffff;
}

.status-value.off {
    background: #666;
    color: #cccccc;
}

/* Voltage and Current Row */
.voltage-current-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #1F1E23;
    border-radius: 4px;
    padding: 5px;
    margin-bottom: 1px;
    border: 1px solid #1F1E23;
}

.voltage-section, .current-section {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    flex: 1;
}

.voltage-value, .current-value {
    font-size: 36px;
    font-weight: bold;
    color: #42C949;
    text-align: center;
}

.voltage-unit, .current-unit {
    font-size: 14px;
    color: #42C949;
    margin-left: 4px;
    align-self: flex-start;
    margin-top: 4px;
}

/* Compact Grid Layout - Updated for more items */
.compact-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 8px;
}

.info-column-left, .info-column-right {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-row-left, .info-row-right {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 6px;
    background: #1F1E23;
    border-radius: 3px;
    border: 1px solid #1F1E23;
    font-size: 13px;
}

.info-row.compact {
    padding: 2px 6px;
    font-size: 10px;
}

.info-label {
    color: #ffffff;
    font-size: 14px;
    text-align: right;
    width: 100%; /* Ensure it takes full width */
    display: block; /* Change from default inline */
}

.info-value {
    color: #42C949;
    font-weight: bold;
    font-size: 14px;
    text-align: left;
    width: 100%; /* Ensure it takes full width */
    display: block; /* Change from default inline */
}

.unit {
    font-size: 11px;
    margin-left: 1px;
    color: #999;
}

/* Table Sections */
.table-section.compact {
    background: #1F1E23;
    border-radius: 4px;
    padding: 8px;
    margin-bottom: 8px;
    border: 1px solid #1F1E23;
}

.table-title {
    color: #cccccc;
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 6px;
    text-align: center;
}

.voltage-table {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.table-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 4px;
}

.table-row:last-child {
    grid-template-columns: 1fr 1fr 1fr 1fr;
}

.table-cell {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 6px;
    background: #1F1E23;
    border-radius: 3px;
    border: 1px solid #444;
    font-size: 13px;
}

.cell-number {
    color: #cccccc;
}

.cell-value {
    color: #42C949;
    font-weight: bold;
}

/* Cells Wire Resistance Table specific */
.table-section.compact:last-child .table-row {
    grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
}

/* Data Source Section */
.data-source {
    text-align: center;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 10px;
    color: #999;
}

.update-time, .data-source {
    margin-bottom: 2px;
}

/* Cell voltage highlighting */
.cell-value.max {
    color: #CF1B18 !important;
    font-weight: bold;
}

.cell-value.min {
    color: #2b57f8 !important;
    font-weight: bold;
}

/* Responsive adjustments */
@media (max-width: 380px) {
    body {
        padding: 5px;
        font-size: 12px;
    }
    
    .container {
        padding: 8px;
    }
    
    .brand-title {
        font-size: 16px;
    }
    
    .menu-button {
        padding: 4px 8px;
        font-size: 12px;
        min-width: 35px;
    }
    
    .dropdown-menu {
        min-width: 120px;
    }
    
    .menu-item {
        padding: 8px 10px;
        font-size: 12px;
    }
    
    .voltage-value, .current-value {
        font-size: 24px;
    }
    
    .voltage-unit, .current-unit {
        font-size: 12px;
    }
    
    .info-label,
    .info-value,
    .time-label,
    .time-value,
    .status-label,
    .status-value {
        font-size: 12px;
    }
    
    .table-cell {
        font-size: 12px;
        padding: 2px 4px;
    }
    
    .compact-grid {
        gap: 4px;
    }

    .info-column-left, .info-column-right {
        gap: 3px;
    }
    
    .info-row-left, .info-row-right {
        padding: 2px 4px;
        font-size: 12px;
    }
    
    /* Status section responsive adjustments */
    .status-item {
        gap: 4px; /* Reduce gap on smaller screens */
    }
    
    .status-label {
        font-size: 11px;
    }
    
    .status-value {
        font-size: 11px;
        padding: 2px 6px;
        min-width: 30px;
    }
}


/* Add these styles to the existing CSS */

/* Left Menu Button */
.left-menu-container {
    position: relative;
    display: inline-block;
}

.left-menu-button {
    background: #3a3a3a;
    border: 1px solid #555;
    border-radius: 4px;
    color: #ffffff;
    cursor: pointer;
    padding: 6px 10px;
    font-size: 14px;
    transition: all 0.3s ease;
    min-width: 40px;
}

.left-menu-button:hover {
    background: #4a4a4a;
    border-color: #42C949;
}

.left-menu-button:active {
    background: #2a2a2a;
}

.left-menu-icon {
    display: block;
    line-height: 1;
}

/* Slide Bar (Sidebar) */
.sidebar {
    position: fixed;
    top: 0;
    left: -300px; /* Start off-screen */
    width: 280px;
    height: 100vh;
    background: #2a2a2a;
    border-right: 1px solid #444;
    z-index: 2000;
    transition: left 0.3s ease;
    overflow-y: auto;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.3);
}

.sidebar.show {
    left: 0; /* Slide in */
}

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1999;
    display: none;
}

.sidebar-overlay.show {
    display: block;
}

/* Sidebar Header */
.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #1a1a1a;
    border-bottom: 1px solid #444;
}

.sidebar-title {
    color: #f4b26b;
    font-size: 18px;
    font-weight: bold;
}

.sidebar-close {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.3s ease;
}

.sidebar-close:hover {
    background: #3a3a3a;
}

/* Devices List */
.devices-list {
    padding: 0;
    margin: 0;
    list-style: none;
}

.device-item {
    padding: 12px 20px;
    border-bottom: 1px solid #3a3a3a;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #ffffff;
}

.device-item:hover {
    background: #42C949;
    color: #1a1a1a;
}

.device-item:active {
    background: #3a9c3f;
}

.device-item.active {
    background: #f4b26b;
    color: #1a1a1a;
    font-weight: bold;
}

.device-id {
    font-size: 14px;
    margin-bottom: 2px;
}

.device-phone {
    font-size: 12px;
    color: #888;
    margin-bottom: 2px;
}

.device-status {
    font-size: 11px;
    color: #cccccc;
}

.device-item:hover .device-status,
.device-item.active .device-status {
    color: #1a1a1a;
}

.device-item:hover .device-phone,
.device-item.active .device-phone {
    color: #1a1a1a;
}

/* Loading State */
.devices-loading {
    padding: 20px;
    text-align: center;
    color: #cccccc;
    font-style: italic;
}

.devices-error {
    padding: 20px;
    text-align: center;
    color: #ff6b6b;
}

/* Responsive adjustments for sidebar */
@media (max-width: 380px) {
    .sidebar {
        width: 260px;
    }
    
    .sidebar-header {
        padding: 12px 16px;
    }
    
    .sidebar-title {
        font-size: 16px;
    }
    
    .device-item {
        padding: 10px 16px;
    }
}

/* Chart Modal Styles */
.chart-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3000;
}

.chart-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    cursor: pointer;
}

.chart-modal-content {
    position: relative;
    background: #2a2a2a;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border: 1px solid #555;
    z-index: 3001;
}

.chart-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #1a1a1a;
    border-bottom: 1px solid #444;
    border-radius: 8px 8px 0 0;
}

.chart-modal-title {
    color: #f4b26b;
    font-size: 18px;
    font-weight: bold;
    margin: 0;
}

.chart-modal-close {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.3s ease;
    line-height: 1;
}

.chart-modal-close:hover {
    background: #3a3a3a;
}

.chart-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 400px;
}

.chart-loading {
    text-align: center;
    color: #cccccc;
    padding: 40px;
    font-size: 14px;
}

#historicalChart {
    max-height: 500px;
}

/* Chart time range selector */
.chart-time-range {
    margin-bottom: 20px;
    padding: 15px;
    background: #1a1a1a;
    border-radius: 6px;
    border: 1px solid #444;
}

.time-range-row {
    display: flex;
    gap: 15px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.time-range-item {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 200px;
}

.time-range-item label {
    color: #cccccc;
    font-size: 12px;
    margin-bottom: 5px;
    font-weight: 500;
}

.time-input {
    padding: 8px 12px;
    background: #2a2a2a;
    border: 1px solid #555;
    border-radius: 4px;
    color: #ffffff;
    font-size: 14px;
    font-family: inherit;
}

.time-input:focus {
    outline: none;
    border-color: #4A90E2;
}

.time-range-update-btn {
    padding: 8px 20px;
    background: #4A90E2;
    border: none;
    border-radius: 4px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s ease;
    white-space: nowrap;
}

.time-range-update-btn:hover {
    background: #357ABD;
}

/* Power statistics */
.power-statistics {
    margin-top: 20px;
    padding: 15px;
    background: #1a1a1a;
    border-radius: 6px;
    border: 1px solid #444;
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
}

.power-stat-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.power-stat-label {
    color: #cccccc;
    font-size: 12px;
    font-weight: 500;
}

.power-stat-value {
    font-size: 18px;
    font-weight: bold;
}

.power-stat-value.charged {
    color: #42C949;
}

.power-stat-value.discharged {
    color: #f4b26b;
}

/* Make voltage and current sections clickable */
.voltage-section, .current-section {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.voltage-section:hover, .current-section:hover {
    opacity: 0.8;
}

/* Responsive adjustments for chart modal */
@media (max-width: 600px) {
    .chart-modal-content {
        width: 95%;
        max-height: 95vh;
    }
    
    .chart-modal-header {
        padding: 12px 16px;
    }
    
    .chart-modal-title {
        font-size: 16px;
    }
    
    .chart-modal-body {
        padding: 16px;
    }
    
    #historicalChart {
        max-height: 400px;
    }
    
    .chart-time-range {
        padding: 12px;
    }
    
    .time-range-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .time-range-item {
        min-width: 100%;
    }
    
    .time-range-update-btn {
        width: 100%;
        padding: 10px;
    }
    
    .power-statistics {
        flex-direction: column;
        gap: 15px;
    }
    
    .power-stat-item {
        width: 100%;
    }
}

/* Phone Modal Styles */
.phone-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
}

.phone-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.phone-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
}

.phone-modal-content {
    position: relative;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    max-width: 400px;
    width: 90%;
    z-index: 2001;
}

.phone-modal-header {
    background: #1F1E23;
    padding: 16px;
    border-bottom: 1px solid #444;
    border-radius: 8px 8px 0 0;
}

.phone-modal-title {
    color: #f4b26b;
    font-size: 18px;
    margin: 0;
}

.phone-modal-body {
    padding: 20px;
}

.phone-modal-message {
    color: #ffffff;
    font-size: 14px;
    margin-bottom: 12px;
}

.phone-input {
    width: 100%;
    padding: 12px;
    margin-bottom: 12px;
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 4px;
    color: #ffffff;
    font-size: 14px;
    font-family: 'Arial', sans-serif;
}

.phone-input:focus {
    outline: none;
    border-color: #f4b26b;
    box-shadow: 0 0 8px rgba(244, 178, 107, 0.3);
}

.phone-input::placeholder {
    color: #888;
}

.phone-modal-info {
    color: #888;
    font-size: 12px;
    margin-top: 8px;
    font-style: italic;
}

.phone-modal-footer {
    display: flex;
    gap: 10px;
    padding: 16px;
    border-top: 1px solid #444;
    background: #1F1E23;
    border-radius: 0 0 8px 8px;
}

.phone-modal-btn-cancel,
.phone-modal-btn-save {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

.phone-modal-btn-cancel {
    background: #444;
    color: #ffffff;
}

.phone-modal-btn-cancel:hover {
    background: #555;
}

.phone-modal-btn-save {
    background: #f4b26b;
    color: #1a1a1a;
}

.phone-modal-btn-save:hover {
    background: #ffc87d;
}

.phone-modal-btn-save:active {
    transform: scale(0.98);
}

