* {
    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-size: 10px;
    color: #f6fa12;
    font-weight: bold;
}

.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;
}

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

.brand-title:hover {
    cursor: pointer;
}

/* 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: 160px;
    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 */
.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;
}

/* Status Section */
.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;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.status-label {
    color: #cccccc;
    font-size: 12px;
    white-space: nowrap;
}

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

.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: 45px;
    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 */
.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-label {
    color: #ffffff;
    font-size: 16px;
    text-align: right;
    width: 100%;
    display: block;
}

.info-value {
    color: #42C949;
    font-weight: bold;
    font-size: 16px;
    text-align: left;
    width: 100%;
    display: block;
}

.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;
}

/* Dòng 1: Bảo vệ/Cảnh báo — Dòng 2: Điện Áp Từng Cell — căn giữa chắc chắn cả 2 dòng */
#cellsVoltageSection .cells-voltage-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-bottom: 6px;
    width: 100%;
    text-align: center;
}
#cellsVoltageSection .cells-voltage-header .protection-alert-wrap,
#cellsVoltageSection .cells-voltage-header .cells-voltage-title-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    text-align: center;
}
#cellsVoltageSection .cells-voltage-header .protection-alert-wrap *,
#cellsVoltageSection .cells-voltage-header .cells-voltage-title-wrap * {
    text-align: center !important;
}
#cellsVoltageSection .cells-voltage-header .table-title {
    margin-bottom: 0;
    text-align: center !important;
}
#cellsVoltageSection .cells-voltage-header .protection-alert {
    text-align: center !important;
    display: inline-block; /* để wrap căn giữa được */
}

/* Bảo vệ / Cảnh báo JK BMS — căn giữa, nhấp nháy khi có cảnh báo */
.protection-alert {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 6px;
    min-height: 1.2em;
    text-align: center;
    transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}
.protection-alert.protection-ok-style .protection-ok {
    color: #7a7a7a;
}
.protection-alert.protection-ok-style {
    background: rgba(122, 122, 122, 0.12);
    color: #9a9a9a;
    border: 1px solid rgba(122, 122, 122, 0.25);
}
/* Nhấp nháy như JK BMS khi có cảnh báo */
.protection-alert.protection-warn {
    background: rgba(248, 81, 73, 0.2);
    color: #ff8a85;
    border: 1px solid rgba(248, 81, 73, 0.55);
    animation: protection-blink 1.2s ease-in-out infinite;
}
@keyframes protection-blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.45; }
}

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

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

.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: 15px;
}

.cell-number {
    color: #cccccc;
}

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

.cell-value.max {
    color: #CF1B18 !important;
    font-weight: bold;
}

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

/* 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;
}

/* 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-icon {
    display: block;
    line-height: 1;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: -300px;
    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;
}

.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 {
    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;
}

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

.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;
    display: block;
    text-decoration: none;
}

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

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

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

/* Phone Modal */
.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;
}

.phone-input:focus {
    outline: none;
    border-color: #f4b26b;
}

.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;
}

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

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

/* Tab Group */
.tab-group-container {
    margin-bottom: 8px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.tab-navigation {
    display: flex;
    gap: 0;
    background: #2a2a2a;
    border-radius: 4px;
    padding: 4px;
    margin-top: 8px;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: #cccccc;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 3px;
}

.tab-btn.active {
    background: #3a3a3a;
    color: #ffffff;
    border: 2px solid #42C949;
}

/* Control Section */
.control-section {
    background: #2a2a2a;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 8px;
}

.control-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px;
    background: #1F1E23;
    border-radius: 3px;
    margin-bottom: 4px;
    border: 1px solid #3a3a3a;
}

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

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #666;
    transition: 0.4s;
    border-radius: 24px;
}

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

input:checked + .slider {
    background-color: #42C949;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.control-input {
    width: 100px;
    background: #3a3a3a;
    border: 1px solid #555;
    border-radius: 3px;
    color: #ffffff;
    padding: 6px 8px;
    font-size: 13px;
}

.control-ok-btn {
    background: #42C949;
    border: none;
    border-radius: 3px;
    color: #1a1a1a;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
}

/* ========== Welcome / Greeting page (KisPer V1.0 index) ========== */
.greeting-container {
    max-width: 500px;
    margin: 50px auto;
    padding: 30px;
    background: #2d2d2d;
    border-radius: 10px;
    border: 1px solid #444;
    text-align: center;
}

.phone-input-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid #444;
}

.phone-label {
    display: block;
    color: #cccccc;
    font-size: 14px;
    margin-bottom: 8px;
    font-weight: bold;
}

.phone-input-box {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    background: #1a1a1a;
    border: 1px solid #555;
    border-radius: 5px;
    color: #00ff00;
    font-size: 14px;
    box-sizing: border-box;
}

.phone-input-box:focus {
    outline: none;
    border-color: #00ff00;
    box-shadow: 0 0 8px rgba(0, 255, 0, 0.3);
}

.search-btn {
    width: 100%;
    background: #00aa00;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.search-btn:hover {
    background: #00dd00;
    transform: translateY(-2px);
}

.greeting-title {
    color: #00ff00;
    font-size: 28px;
    margin-bottom: 20px;
}

.help-btn {
    display: inline-block;
    background: #007bff;
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: bold;
    margin-bottom: 12px;
}

.greeting-subtitle {
    color: #cccccc;
    font-size: 16px;
    margin-bottom: 30px;
}

.devices-section {
    margin: 30px 0;
}

.devices-title {
    color: #cccccc;
    font-size: 18px;
    margin-bottom: 15px;
}

.devices-list-welcome {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
    list-style: none;
    padding: 0;
    margin: 0;
}

.device-link {
    display: block;
    padding: 12px 20px;
    background: #3a3a3a;
    color: #00ff00;
    text-decoration: none;
    border-radius: 5px;
    border: 1px solid #555;
    transition: all 0.3s ease;
    font-weight: bold;
}

.device-link:hover {
    background: #00aa00;
    color: #ffffff;
    transform: translateY(-2px);
}

.no-devices {
    color: #ff6666;
    font-style: italic;
    padding: 20px;
}

.loading-welcome {
    color: #cccccc;
    padding: 20px;
}

.stats {
    margin-top: 20px;
    color: #999;
    font-size: 14px;
}

/* Lang switcher trên trang chào / not found */
.lang-switcher-top {
    text-align: right;
    margin-bottom: 16px;
    font-size: 14px;
}
.lang-switcher-top .lang-link {
    color: #42C949;
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 4px;
}
.lang-switcher-top .lang-link:hover {
    background: #3a3a3a;
    color: #fff;
}
.lang-switcher-top .lang-link.active {
    color: #f4b26b;
    font-weight: bold;
}
.lang-switcher-top .lang-sep {
    color: #666;
    margin: 0 6px;
}

/* Dropdown menu item as link */
.menu-container .menu-item {
    text-decoration: none;
    display: block;
}

/* History section (below Điện trở dây từng cell) */
.history-section {
    background: #1F1E23;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 8px;
    border: 1px solid #444;
}
.history-title {
    color: #f4b26b;
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 8px;
}
.history-view {
    color: #cccccc;
    font-size: 13px;
    margin-bottom: 6px;
}
.history-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}
.history-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #2a2a2a;
    border: 1px solid #555;
    border-radius: 6px;
    color: #42C949;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}
.history-card:hover {
    background: #3a3a3a;
    border-color: #42C949;
    color: #fff;
}
.history-card:active {
    transform: scale(0.98);
}
.history-card-icon {
    font-size: 18px;
    line-height: 1;
}
.history-card-label {
    white-space: nowrap;
}

/* Clickable table title for history */
.table-title-clickable {
    cursor: pointer;
}
.table-title-clickable:hover {
    color: #42C949;
}

/* Chart modal (24h history) - thân thiện desktop + mobile */
.chart-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3000;
    padding: 0;
    align-items: stretch;
    justify-content: center;
}
.chart-modal.show {
    display: flex;
}
.chart-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    cursor: pointer;
}
.chart-modal-content {
    position: relative;
    background: #1e1e1e;
    width: 95%;
    max-width: 720px;
    height: 85vh;
    max-height: 560px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border: 1px solid #444;
    z-index: 3001;
    border-radius: 12px;
    overflow: hidden;
}
.chart-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: #252525;
    border-bottom: 1px solid #444;
    flex-shrink: 0;
}
.chart-modal-title {
    color: #f4b26b;
    font-size: 17px;
    font-weight: bold;
    margin: 0;
    line-height: 1.3;
}
.chart-modal-close {
    background: #3a3a3a;
    border: 1px solid #555;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 0;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
}
.chart-modal-close:hover {
    background: #4a4a4a;
    border-color: #42C949;
}
.chart-modal-close:active {
    background: #2a2a2a;
}
.chart-modal-body {
    padding: 12px 16px 16px;
    overflow: auto;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* Modal mật khẩu BMS JK (Cài Đặt PIN) */
.pin-password-content {
    max-width: 380px;
    height: auto;
    max-height: 90vh;
}
.pin-password-prompt {
    margin: 0 0 12px;
    color: #ccc;
    font-size: 14px;
    line-height: 1.4;
}
.pin-password-input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: #2a2a2a;
    border: 1px solid #555;
    border-radius: 8px;
    color: #fff;
    font-size: 16px;
}
.pin-password-input:focus {
    outline: none;
    border-color: #42C949;
}
.pin-password-error {
    margin: 0 0 12px;
    color: #e57373;
    font-size: 13px;
}
.pin-switch-error {
    margin: 8px 0 12px;
    padding: 8px 10px;
    background: rgba(229, 115, 115, 0.15);
    border-left: 3px solid #e57373;
    color: #e57373;
    font-size: 13px;
    line-height: 1.4;
}
.pin-password-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}
.pin-password-btn {
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid #555;
    -webkit-tap-highlight-color: transparent;
}
.pin-password-cancel {
    background: #3a3a3a;
    color: #ccc;
}
.pin-password-cancel:hover {
    background: #4a4a4a;
}
.pin-password-submit {
    background: #42C949;
    color: #1a1a1a;
    border-color: #42C949;
}
.pin-password-submit:hover {
    background: #52d959;
}

.chart-canvas-wrap {
    position: relative;
    flex: 1;
    min-height: 280px;
    width: 100%;
}
.chart-canvas-wrap canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-height: 100%;
}
.chart-loading {
    text-align: center;
    color: #aaa;
    padding: 32px 16px;
    font-size: 15px;
}

/* Mobile: full màn hình, biểu đồ lớn, dễ chạm */
@media (max-width: 600px) {
    .chart-modal-content {
        width: 100%;
        max-width: none;
        height: 100vh;
        max-height: none;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    .chart-modal-header {
        padding: 12px 14px;
    }
    .chart-modal-title {
        font-size: 16px;
    }
    .chart-modal-close {
        min-width: 48px;
        min-height: 48px;
        font-size: 26px;
    }
    .chart-modal-body {
        padding: 10px 12px 12px;
    }
    .chart-canvas-wrap {
        min-height: min(320px, 50vh);
        flex: 1;
    }
}

/* Main tab bar: Thông Số | Cài Đặt PIN */
.main-tab-bar {
    display: flex;
    gap: 4px;
    background: #2a2a2a;
    border-radius: 4px;
    padding: 4px;
    margin: 8px 0;
    border: 1px solid #444;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.main-tab {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 3px;
    background: transparent;
    color: #999;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
}
.main-tab:hover {
    color: #ccc;
    background: rgba(66, 201, 73, 0.08);
}
.main-tab.active {
    background: #1F1E23;
    color: #42C949;
    border-color: #42C949;
    box-shadow: 0 0 0 1px #42C949;
}

/* Cài đặt PIN panel — full chiều dọc như tab Thông số */
.pin-settings-panel {
    background: #1F1E23;
    border-radius: 4px;
    padding: 10px 8px 16px;
    margin: 0;
    border: 1px solid #444;
    min-height: calc(100vh - 200px);
    overflow-y: auto;
}
.pin-settings-panel::-webkit-scrollbar {
    width: 6px;
}
.pin-settings-panel::-webkit-scrollbar-track {
    background: #2a2a2a;
    border-radius: 3px;
}
.pin-settings-panel::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 3px;
}
.pin-setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    margin-bottom: 4px;
    background: #2a2a2a;
    border-radius: 3px;
    border: 1px solid #3a3a3a;
    gap: 10px;
    transition: border-color 0.2s ease;
}
.pin-setting-row:hover {
    border-color: #555;
}
.pin-setting-row.toggle-row {
    min-height: 44px;
}
.pin-label {
    flex: 1;
    font-size: 13px;
    color: #cccccc;
    line-height: 1.3;
}
.pin-input {
    width: 82px;
    padding: 6px 10px;
    font-size: 13px;
    background: #3a3a3a;
    border: 1px solid #555;
    border-radius: 3px;
    color: #fff;
    text-align: right;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.pin-input:focus {
    outline: none;
    border-color: #42C949;
    box-shadow: 0 0 0 2px rgba(66, 201, 73, 0.2);
}
.pin-input::placeholder {
    color: #666;
}
.pin-ok-btn {
    padding: 6px 16px;
    font-size: 12px;
    font-weight: 700;
    background: #42C949;
    color: #1a1a1a;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s ease, transform 0.1s ease;
}
.pin-ok-btn:hover {
    background: #52d959;
}
.pin-ok-btn:active {
    background: #38b03f;
    transform: scale(0.98);
}

/* Toggle switch — đồng bộ với .switch / .slider */
.pin-toggle {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
    flex-shrink: 0;
}
.pin-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}
.pin-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #666;
    border-radius: 26px;
    transition: 0.3s;
    border: 1px solid #555;
}
.pin-toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: #fff;
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.pin-toggle input:checked + .pin-toggle-slider {
    background-color: #42C949;
    border-color: #42C949;
}
.pin-toggle input:checked + .pin-toggle-slider:before {
    transform: translateX(24px);
}

/* Pin settings: mobile */
@media (max-width: 600px) {
    .pin-settings-panel {
        min-height: calc(100vh - 180px);
        padding: 8px 6px 12px;
    }
    .pin-setting-row {
        padding: 10px 8px;
        gap: 8px;
    }
    .pin-label {
        font-size: 12px;
    }
    .pin-input {
        width: 72px;
        padding: 8px 8px;
        font-size: 14px;
    }
    .pin-ok-btn {
        padding: 8px 14px;
        min-width: 44px;
    }
}

/* Responsive */
@media (max-width: 380px) {
    body {
        padding: 5px;
        font-size: 12px;
    }
    .container {
        padding: 8px;
    }
    .brand-title {
        font-size: 16px;
    }
    .voltage-value, .current-value {
        font-size: 30px;
    }
    .table-cell {
        font-size: 14px;
        padding: 2px 4px;
    }
    .sidebar {
        width: 260px;
    }
    .main-tab {
        padding: 8px 6px;
        font-size: 12px;
    }
    .pin-setting-row {
        padding: 6px 8px;
    }
    .pin-input {
        width: 68px;
    }
}
