* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
    min-height: 100vh;
    background: #f5f5f7;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
}

.glass-container {
    max-width: 400px;
    width: 100%;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 28px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    padding: 16px 12px;
    color: #1d1d1f;
}

.header-title {
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    color: #1d1d1f;
    margin-bottom: 12px;
    letter-spacing: -0.3px;
}

.top-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    position: relative;
}

.stats-col {
    flex: 1;
}

.stats-col.center {
    flex: 0 0 auto;
    display: flex;
    flex-direction: row;
    gap: 8px;
    position: relative;
}

.stats-col.right {
    text-align: right;
}

.stats-col.center::before,
.stats-col.center::after {
    content: '';
    position: absolute;
    top: 0;
    width: 1px;
    height: 100%;
    background: rgba(0, 0, 0, 0.1);
}

.stats-col.center::before {
    left: -6px;
}

.stats-col.center::after {
    right: -6px;
}

.stats-header {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: rgba(0, 0, 0, 0.5);
    margin-bottom: 4px;
}

.stats-voltage {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 2px;
    color: #1d1d1f;
}

.stats-minmax {
    font-size: 13px;
    line-height: 1.4;
    color: rgba(0, 0, 0, 0.8);
    font-weight: 500;
}

.stats-minmax span {
    font-weight: 600;
    color: #1d1d1f;
    margin-left: 2px;
    font-size: 12px;
}

.stats-delta {
    font-size: 13px;
    font-weight: 600;
    margin-top: 2px;
}

.delta-green { color: #28cd41; }
.delta-yellow { color: #ff9f0a; }
.delta-red { color: #ff3b30; }

.switch-label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: rgba(0, 0, 0, 0.4);
    text-align: center;
    margin-bottom: 2px;
}

.switch-wrapper {
    display: flex;
    flex-direction: column;
}

.vertical-switch {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 20px;
    padding: 3px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    width: 90px;
}

.vertical-btn {
    text-align: center;
    padding: 6px 0;
    font-size: 13px;
    font-weight: 600;
    border-radius: 17px;
    color: rgba(0, 0, 0, 0.6);
    transition: all 0.2s;
    cursor: pointer;
}

.vertical-btn.active {
    background: #007aff;
    color: white;
    box-shadow: 0 2px 6px rgba(0, 122, 255, 0.3);
}

.module-table {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.1);
}
.mrow {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}
.mrow:last-child { border-bottom: none; }
.mrow-alt { background: rgba(0,0,0,0.06); }
.mrow-num {
    flex: 0 0 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: rgba(0,0,0,0.55);
    background: rgba(0,0,0,0.09);
    border-right: 1px solid rgba(0,0,0,0.12);
}
.mrow-alt .mrow-num {
    background: rgba(0,0,0,0.20);
    color: rgba(0,0,0,0.7);
}
.mrow-cells {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
    padding: 4px;
}
.mrow-right {
    flex: 0 0 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 4px;
    border-left: 1px solid rgba(0,0,0,0.08);
}
.mrow-voltage {
    font-size: 12px;
    font-weight: 700;
    color: #1d1d1f;
    letter-spacing: -0.3px;
}
.mrow-delta {
    font-size: 12px;
    font-weight: 600;
}

.cell {
    background: white;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 0 5px;
    position: relative;
    min-height: 38px;
}

.cell-number {
    position: absolute;
    top: 3px;
    left: 4px;
    font-size: 11px;
    font-weight: 600;
    color: rgba(0, 0, 0, 0.4);
}

.cell-voltage {
    font-size: 16px;
    font-weight: 600;
    color: #1d1d1f;
    letter-spacing: -0.3px;
    margin-top: 5px;
}

.cell-min-label, .cell-max-label {
    position: absolute;
    top: 2px;
    right: 3px;
    font-size: 8px;
    font-weight: 700;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.85);
    padding: 1px 2px;
    border-radius: 2px;
    line-height: 1;
}

.cell-min-label {
    color: #ff3b30;
}

.cell-max-label {
    color: #8e8e93;
}

.cell-balancing-label {
    position: absolute;
    bottom: 2px;
    left: 4px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    color: #007aff;
    background: rgba(255, 255, 255, 0.9);
    padding: 1px 2px;
    border-radius: 2px;
    line-height: 1;
    letter-spacing: 0.3px;
    z-index: 2;
}

.cell-green {
    background: #e8f5e9;
    border-color: #a5d6a7;
}
.cell-orange {
    background: #fff3e0;
    border-color: #ffb74d;
}
.cell-red {
    background: #ffcdd2;       /* more saturated light red */
    border-color: #e57373;     /* bright red border */
    /* text color stays dark (default) */
}

.cell-gray {
    background: #1abc9c;      /* saturated dark teal */
    border-color: #117a65;     /* even darker for the border */
    color: white;              /* white text for contrast */
}

.module-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.module-tab {
    flex: 1;
    min-width: 70px;
    max-width: 85px;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 20px;
    padding: 6px 0;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: rgba(0, 0, 0, 0.5);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.module-tab.active {
    background: #007aff;
    color: white;
    border-color: #007aff;
    box-shadow: 0 2px 6px rgba(0, 122, 255, 0.3);
}

.info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
    border-radius: 16px;
    padding: 10px 14px;
    margin-bottom: 6px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 13px;
    color: #1d1d1f;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.info-row:last-child {
    margin-bottom: 0;
}

.info-left {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 150px;          /* fixed width */
}

.info-right {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 130px;          /* fixed width */
    /* justify-content: flex-end; -- not used */
}

.info-label {
    color: rgba(0, 0, 0, 0.5);
    font-weight: 500;
    min-width: 45px;
}

.info-value {
    font-weight: 600;
    color: #1d1d1f;
}

/* Appended rules */

.hys-btn {
    width: 32px;
    height: 32px;
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: white;
    color: #1d1d1f;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
    transition: all 0.2s;
}

.hys-btn:hover {
    background: #f5f5f5;
}

.hys-btn:active {
    background: #e0e0e0;
    transform: scale(0.95);
}

.hys-input {
    width: 60px;
    height: 32px;
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: white;
    color: #1d1d1f;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    padding: 0 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

/* Hide number input spinners for a cleaner look */
.hys-input::-webkit-outer-spin-button,
.hys-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.hys-input[type=number] {
    -moz-appearance: textfield;
}

.text-red { color: #ff3b30 !important; }

.cell-global-index {
    position: absolute;
    bottom: 2px;
    right: 3px;
    font-size: 0.65em;
    color: rgba(255, 255, 255, 0.4); /* keep it dim so it does not distract */
    font-weight: normal;
}

.cell {
    position: relative; /* required for positioning the inner number */
}

.cell-global-num {
    position: absolute;
    bottom: 0px;
    right: 4px;
    font-size: 0.6em;
    color: #000000; /* pure black */
    opacity: 0.5;   /* semi-transparent so it does not overpower the voltage */
    font-weight: bold;
    pointer-events: none;
    z-index: 5;
}

.header-title sup {
    font-size: 0.6em;       /* half the size of the main text */
    color: gray; /* pale gray */
    vertical-align: super; /* raise to superscript */
    margin-left: 1px;      /* gap from the title */
}

.version-pro {
    color: #007aff !important; /* the accent blue */
    opacity: 1 !important;     /* make sure it is bright, not pale */
}


/* IP shown as an implicit link to /netcfg: looks like plain text, pointer only */
.ip-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

/* TSK.BY label under the balance switch */
.brand-label {
    text-align: center;
    margin-top: 8px;
    margin-bottom: 0;
    font-size: 15px;
    font-weight: 700;
    color: #007aff;
}

/* Analysis mode: smaller cell voltage to make room for the delta badge */
.cell-voltage-small {
    font-size: 16px;
    position: relative;
    right: 4px;
    margin-top: -2px;
    margin-bottom: 12px;
}

/* Delta badge (Analysis mode) — sits where BAL is, slightly larger */
.cell-delta-label {
    position: absolute;
    bottom: 0px;
    left: 2px;
    font-size: 12px;
    font-weight: 700;
    color: rgba(0, 0, 0, 0.6);
    background: rgba(255, 255, 255, 0.9);
    padding: 1px 3px;
    border-radius: 3px;
    line-height: 1;
    letter-spacing: 0.2px;
    z-index: 2;
}

/* Cell dropped more than average beyond threshold — red (like MIN) */
.delta-badge-low {
    color: #ff3b30;
}

/* Cell rose above average beyond threshold — gray (like MAX) */
.delta-badge-high {
    color: #8e8e93;
}

/* "No NTP found!" вместо таймера анализа */
.no-ntp {
    color: #ff3b30 !important;
    font-weight: 700;
}

/* Таймер анализа: зелёный = epoch в NVS (можно выключать прибор) */
.timer-saved {
    color: #28cd41 !important;
}

/* Таймер анализа: серый = идёт по millis (выключение обнулит) */
.timer-local {
    color: #8e8e93 !important;
}

/* Sticky-панель регуляторов (гистерезис/анализ): прилипает к верху
   при прокрутке таблицы — таймер и порог видны при любом числе модулей. */
.sticky-controls {
    position: sticky;
    top: 0;
    z-index: 20;
    /* непрозрачный фон, чтобы таблица читаемо проезжала под панелью */
    background: rgba(245, 245, 247, 0.96);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    margin: 0 -12px 0 -12px;   /* растянуть на всю ширину карточки (компенсация padding) */
    padding: 0 12px;
}
.sticky-controls .info-row {
    margin-bottom: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}