:root {
    --screen-blue: #003cff;
    --screen-blue-deep: #0028b3;
    --screen-white: #eef9ff;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    background: radial-gradient(circle at top, #24304f 0%, #121826 42%, #0a0d16 100%);
    color: #fff;
}

img,
svg,
canvas {
    max-width: 100%;
    height: auto;
}

.left-stats .stat-line {
    display: grid;
    grid-template-columns: 28px 1fr;
    align-items: center;
    width: 100%;
}

.left-stats .stat-label {
    text-align: left;
}

.left-stats .stat-value {
    text-align: right;
}

.page-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 28px;
    padding: 26px;
    flex-wrap: wrap;
}

.panel-shell {
    filter: drop-shadow(0 22px 28px rgba(0, 0, 0, 0.45));
}

.responsive-shell,
.shell-frame,
.lcd-bezel {
    width: 100%;
    max-width: 100%;
}

.shell-frame {
    padding: 18px;
    border-radius: 12px;
    background: linear-gradient(145deg, #171b25, #0f121a);
    border: 2px solid #91959f;
    box-shadow: inset 0 0 0 2px #3b4150, inset 0 0 0 6px #151924;
}

.lcd-bezel {
    padding: 16px;
    border-radius: 10px;
    background: linear-gradient(145deg, #2a313d, #161b22);
    border: 2px solid #d2d6dd;
    box-shadow: inset 0 0 0 2px #4f5663, inset 0 0 12px rgba(255, 255, 255, 0.06);
}

.lcd-screen {
    position: relative;
    width: min(980px, 95vw);
    max-width: 100%;
    min-height: 430px;
    overflow: hidden;
    border-radius: 3px;
    padding: 22px 34px 24px;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.18), rgba(255,255,255,0) 18%),
        linear-gradient(180deg, var(--screen-blue) 0%, var(--screen-blue-deep) 100%);
    border: 2px solid #82a7ff;
    color: var(--screen-white);
    font-family: "Courier New", Courier, monospace;
    text-shadow: 0 0 8px rgba(225, 242, 255, 0.35);
}

.lcd-glow,
.lcd-noise {
    pointer-events: none;
    position: absolute;
    inset: 0;
}

.lcd-glow {
    background: radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.08), transparent 38%), linear-gradient(180deg, transparent, rgba(255,255,255,0.05));
}

.lcd-noise {
    background-image: linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
    background-size: 100% 4px, 4px 100%;
    mix-blend-mode: screen;
    opacity: 0.35;
}

.lcd-header {
    position: relative;
    z-index: 2;
    display: flex;
    justify-content: flex-start;
    align-items: baseline;
    font-size: clamp(18px, 2.1vw, 30px);
    letter-spacing: 2px;
    min-height: 42px;
}

.lcd-main {
    position: relative;
    z-index: 2;
    margin-top: 20px;
}

.device-row {
    display: grid;
    grid-template-columns: 190px 110px 280px 110px 190px;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.solar-block,
.battery-wrap,
.mppt-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.solar-block,
.battery-wrap {
    gap: 18px;
}

.metric-top,
.metric-bottom {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 10px;
    font-size: clamp(20px, 2vw, 26px);
    letter-spacing: 1px;
    min-height: 28px;
}

.metric-left,
.metric-right {
    width: 95%;
}

.metric-left {
    justify-content: flex-start;
}

.metric-right {
    justify-content: flex-end;
}

.metric-label {
    opacity: 0.95;
}

.metric-value {
    font-weight: 700;
}

.solar-grid {
    width: 106px;
    display: grid;
    gap: 10px;
}

.solar-line-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.solar-cell {
    display: block;
    height: 12px;
    border-radius: 1px;
    border: 2px solid rgba(240, 250, 255, 0.95);
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.25);
}

.flow-line {
    height: 7px;
    position: relative;
    background: linear-gradient(90deg, rgba(238,249,255,0.9), rgba(238,249,255,0.95));
    box-shadow: 0 0 12px rgba(255,255,255,0.35);
}

.flow-line::after {
    content: "";
    position: absolute;
    right: -8px;
    top: 50%;
    width: 13px;
    height: 13px;
    border-top: 3px solid var(--screen-white);
    border-right: 3px solid var(--screen-white);
    transform: translateY(-50%) rotate(45deg);
}

.mppt-stack {
    gap: 22px;
}

.mppt-box {
    position: relative;
    width: 100%;
    min-height: 150px;
    border: 3px solid rgba(240, 250, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    box-shadow: 0 0 10px rgba(255,255,255,0.22);
    padding: 16px 18px;
}

.mppt-title {
    font-size: clamp(24px, 2.5vw, 40px);
    font-weight: bold;
    letter-spacing: 2px;
    margin-bottom: 14px;
}

.mppt-status-window {
    position: relative;
    width: 100%;
    height: 34px;
    overflow: hidden;
    border-top: 2px solid rgba(238,249,255,0.5);
    border-bottom: 2px solid rgba(238,249,255,0.5);
    display: flex;
    align-items: center;
}

.mppt-status-text {
    position: absolute;
    left: 100%;
    white-space: nowrap;
    font-size: clamp(18px, 1.7vw, 24px);
    line-height: 1;
    animation: mpptMarquee 25s linear infinite;
}

.mppt-status-text.is-static {
    position: static;
    transform: none;
    animation: none;
    width: 100%;
    text-align: center;
}

@keyframes mpptMarquee {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-170%);
    }
}

.mppt-pin {
    position: absolute;
    left: 50%;
    width: 76px;
    height: 4px;
    background: var(--screen-white);
    transform: translateX(-50%);
}

.pin-top { top: -18px; }
.pin-bottom { bottom: -18px; }

.left-stats {
    width: 100%;
    text-align: left;
    font-size: clamp(22px, 2vw, 30px);
    line-height: 1.25;
    letter-spacing: 1px;
}

.stat-line {
    white-space: nowrap;
}

.battery-box {
    position: relative;
    width: 160px;
    height: 86px;
    border: 3px solid var(--screen-white);
    display: flex;
    align-items: center;
    padding: 10px 12px;
    box-shadow: 0 0 10px rgba(255,255,255,0.22);
}

.battery-cap {
    position: absolute;
    right: -13px;
    top: 50%;
    width: 10px;
    height: 36px;
    border: 3px solid var(--screen-white);
    transform: translateY(-50%);
    background: transparent;
}

.battery-slots {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    width: 100%;
    height: 100%;
}

.battery-segment {
    border: 2px solid rgba(240, 250, 255, 0.95);
    background: transparent;
    box-shadow: inset 0 0 8px rgba(255,255,255,0.08);
    min-width: 12px;
}

.battery-segment.active {
    background: rgba(230, 246, 255, 0.95);
    box-shadow: 0 0 10px rgba(255,255,255,0.45), inset 0 0 10px rgba(255,255,255,0.3);
}

.battery-box.charging .battery-segment.active {
    animation: chargePulse 1.1s infinite ease-in-out;
}

@keyframes chargePulse {
    0%, 100% { opacity: 0.45; }
    50% { opacity: 1; }
}

.battery-percent-line {
    justify-content: center;
}

.info-card {
    width: min(420px, 94vw);
    background: rgba(17, 22, 34, 0.88);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 18px;
    padding: 22px;
    box-shadow: 0 18px 32px rgba(0,0,0,0.28);
}

.info-card h1 {
    margin: 0 0 18px;
    font-size: 24px;
}

.meta-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.notice {
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(112, 144, 255, 0.12);
    border: 1px solid rgba(124, 153, 255, 0.22);
    line-height: 1.55;
    margin-bottom: 12px;
}

.notice.warning {
    background: rgba(255, 180, 77, 0.11);
    border-color: rgba(255, 180, 77, 0.22);
}

.quick-list {
    display: grid;
    gap: 10px;
    line-height: 1.5;
    color: #d7dcec;
}

code {
    background: rgba(255,255,255,0.08);
    border-radius: 8px;
    padding: 2px 6px;
}

@media (max-width: 1100px) {
    .page-wrap {
        gap: 18px;
    }

    .lcd-screen {
        width: min(900px, 95vw);
    }

    .device-row {
        grid-template-columns: 170px 90px 250px 90px 170px;
        gap: 10px;
    }

    .metric-top,
    .metric-bottom,
    .left-stats {
        font-size: clamp(18px, 1.9vw, 26px);
    }
}

@media (max-width: 820px) {
    .page-wrap {
        min-height: auto;
        align-items: flex-start;
        justify-content: flex-start;
        padding: 10px;
        gap: 12px;
    }

    .shell-frame {
        padding: 8px;
    }

    .lcd-bezel {
        padding: 8px;
    }

    .lcd-screen {
        width: 100%;
        min-height: auto;
        padding: 12px;
        overflow: visible;
    }

    .lcd-header {
        font-size: clamp(14px, 4vw, 22px);
        min-height: auto;
        margin-bottom: 10px;
    }

    .lcd-main {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 6px;
        margin-top: 12px;
    }

    .device-row {
        min-width: 488px;
        grid-template-columns: 100px 48px 160px 48px 100px;
        gap: 8px;
    }

    .solar-block,
    .battery-wrap,
    .mppt-stack {
        gap: 10px;
    }

    .metric-top,
    .metric-bottom,
    .left-stats {
        font-size: clamp(11px, 2.4vw, 16px);
    }

    .solar-grid {
        width: 62px;
        gap: 5px;
    }

    .solar-line-group {
        gap: 4px;
    }

    .solar-cell {
        height: 8px;
        border-width: 1px;
    }

    .flow-line {
        height: 4px;
    }

    .flow-line::after {
        width: 8px;
        height: 8px;
        right: -5px;
        border-top-width: 2px;
        border-right-width: 2px;
    }

    .mppt-box {
        min-height: 96px;
        padding: 10px 10px;
        border-width: 2px;
    }

    .mppt-title {
        font-size: clamp(15px, 3vw, 22px);
        margin-bottom: 8px;
    }

    .mppt-status-window {
        height: 24px;
    }

    .mppt-status-text {
        font-size: clamp(10px, 2vw, 13px);
    }

    .mppt-pin {
        width: 42px;
        height: 2px;
    }

    .pin-top { top: -11px; }
    .pin-bottom { bottom: -11px; }

    .battery-box {
        width: 86px;
        height: 46px;
        padding: 5px 6px;
        border-width: 2px;
    }

    .battery-cap {
        right: -8px;
        width: 6px;
        height: 18px;
        border-width: 2px;
    }

    .battery-slots {
        gap: 3px;
    }

    .battery-segment {
        border-width: 1px;
        min-width: 0;
    }

    .stat-line {
        white-space: normal;
    }

    .left-stats .stat-line {
        grid-template-columns: 22px 1fr;
        gap: 6px;
    }

    .info-card {
        width: 100%;
    }
}

@media (max-width: 580px) {
    .page-wrap {
        padding: 8px;
    }

    .lcd-screen {
        padding: 10px;
    }

    .lcd-main {
        overflow-x: visible;
    }

    .device-row {
        min-width: 0;
        grid-template-columns: 1fr;
        gap: 14px;
        justify-items: center;
    }

    .flow-line {
        display: none;
    }

    .solar-block,
    .mppt-stack,
    .battery-wrap {
        width: 100%;
        max-width: 220px;
    }

    .metric-left,
    .metric-right,
    .left-stats {
        width: 100%;
        justify-content: center;
        text-align: center;
    }

    .metric-top,
    .metric-bottom {
        min-height: auto;
    }

    .left-stats .stat-line {
        grid-template-columns: 1fr auto;
        align-items: center;
    }

    .left-stats .stat-label,
    .left-stats .stat-value {
        text-align: center;
    }

    .mppt-box {
        width: 100%;
    }

    .mppt-status-text {
        white-space: normal;
        position: static;
        left: auto;
        animation: none;
        text-align: center;
        line-height: 1.3;
    }

    .battery-percent-line,
    .metric-top.metric-right,
    .metric-top.metric-left,
    .metric-bottom.metric-left {
        justify-content: center;
    }
}
