:root {
    color-scheme: dark;

    --background: #0d1117;
    --surface: #161b22;
    --surface-soft: #1c222b;
    --border: rgba(255, 255, 255, 0.08);

    --text: #f0f6fc;
    --text-muted: #8b949e;

    --normal: #3fb950;
    --warning: #d29922;
    --critical: #f85149;
    --offline: #8b949e;

    --shadow:
        0 20px 45px rgba(0, 0, 0, 0.22);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--background);
}

body {
    min-height: 100%;
    margin: 0;

    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    color: var(--text);

    background:
        radial-gradient(
            circle at top left,
            rgba(47, 129, 247, 0.10),
            transparent 32rem
        ),
        var(--background);
}

button,
input,
select,
textarea {
    font: inherit;
}

.app-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding:
        max(24px, env(safe-area-inset-top))
        0
        max(30px, env(safe-area-inset-bottom));
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;

    margin-bottom: 24px;
}

.eyebrow {
    margin: 0 0 5px;

    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

h1 {
    margin: 0;

    font-size: clamp(1.75rem, 4vw, 2.65rem);
    letter-spacing: -0.045em;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 9px;

    min-width: 112px;
    padding: 10px 14px;

    border: 1px solid var(--border);
    border-radius: 999px;

    font-size: 0.9rem;
    font-weight: 800;

    background: var(--surface);
}

.status-dot {
    width: 9px;
    height: 9px;

    border-radius: 50%;
    background: var(--offline);
}

.status-online {
    color: #7ee787;
}

.status-online .status-dot {
    background: var(--normal);

    box-shadow:
        0 0 0 5px rgba(63, 185, 80, 0.12);
}

.status-offline {
    color: #c9d1d9;
}

.status-error {
    color: #ff7b72;
}

.status-error .status-dot {
    background: var(--critical);
}

.dashboard-grid {
    display: grid;
    grid-template-columns:
        minmax(0, 1.7fr)
        minmax(270px, 0.8fr);
    gap: 20px;
}

.card {
    border: 1px solid var(--border);
    border-radius: 24px;

    background:
        linear-gradient(
            180deg,
            rgba(255, 255, 255, 0.025),
            transparent
        ),
        var(--surface);

    box-shadow: var(--shadow);
}

.gauge-card {
    min-height: 490px;
    padding: 24px;
}

.card-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.card-label {
    margin: 0 0 6px;

    color: var(--text);
    font-size: 0.92rem;
    font-weight: 800;
}

.card-description {
    margin: 0;

    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.45;
}

.live-indicator {
    padding: 7px 10px;

    border: 1px solid rgba(63, 185, 80, 0.18);
    border-radius: 999px;

    color: #7ee787;
    background: rgba(63, 185, 80, 0.09);

    font-size: 0.68rem;
    font-weight: 900;
    letter-spacing: 0.12em;
}

.gauge-wrapper {
    position: relative;

    display: flex;
    align-items: center;
    justify-content: center;

    min-height: 350px;
    margin-top: 4px;
}

#powerGauge {
    display: block;

    width: 100%;
    max-width: 720px;
    height: auto;
}

.gauge-value {
    position: absolute;
    top: 54%;
    left: 50%;

    display: flex;
    align-items: baseline;
    gap: 8px;

    transform: translate(-50%, -50%);
}

.gauge-value strong {
    font-size: clamp(3.15rem, 8vw, 5.7rem);
    line-height: 1;
    letter-spacing: -0.065em;
}

.gauge-value span {
    color: var(--text-muted);
    font-size: clamp(1rem, 2.3vw, 1.45rem);
    font-weight: 800;
}

.power-state {
    position: absolute;
    top: 72%;
    left: 50%;

    padding: 7px 13px;

    border-radius: 999px;

    transform: translateX(-50%);

    font-size: 0.82rem;
    font-weight: 900;
}

.state-normal {
    color: #7ee787;
    background: rgba(63, 185, 80, 0.10);
}

.state-warning {
    color: #e3b341;
    background: rgba(210, 153, 34, 0.11);
}

.state-critical {
    color: #ff7b72;
    background: rgba(248, 81, 73, 0.11);
}

.state-unknown {
    color: #c9d1d9;
    background: rgba(139, 148, 158, 0.10);
}

.gauge-scale {
    display: flex;
    justify-content: space-between;

    padding: 0 8%;

    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.stats-column {
    display: grid;
    gap: 20px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 17px;

    min-height: 142px;
    padding: 21px;
}

.stat-icon {
    display: grid;
    place-items: center;

    flex: 0 0 auto;

    width: 50px;
    height: 50px;

    border: 1px solid var(--border);
    border-radius: 17px;

    color: #79c0ff;
    background: var(--surface-soft);

    font-size: 1.3rem;
    font-weight: 900;
}

.stat-value {
    margin: 5px 0 3px;

    color: var(--text);
    font-size: clamp(1.7rem, 4vw, 2.45rem);
    font-weight: 850;
    line-height: 1.05;
    letter-spacing: -0.04em;
}

.stat-value small {
    color: var(--text-muted);
    font-size: 0.85rem;
    letter-spacing: 0;
}

.stat-value-small {
    font-size: clamp(1.45rem, 3vw, 2rem);
}

.stat-meta {
    margin: 0;

    color: var(--text-muted);
    font-size: 0.84rem;
}

.info-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;

    margin-top: 20px;
    padding: 21px 24px;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 14px 20px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;

    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 650;
}

.legend-dot {
    width: 9px;
    height: 9px;

    border-radius: 50%;
}

.legend-dot.normal {
    background: var(--normal);
}

.legend-dot.warning {
    background: var(--warning);
}

.legend-dot.critical {
    background: var(--critical);
}

.app-footer {
    display: flex;
    justify-content: space-between;
    gap: 20px;

    padding: 20px 4px 0;

    color: var(--text-muted);
    font-size: 0.76rem;
}

@media (max-width: 850px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .stats-column {
        grid-template-columns: repeat(3, 1fr);
    }

    .stat-card {
        align-items: flex-start;
        flex-direction: column;
    }

    .info-card {
        align-items: flex-start;
        flex-direction: column;
    }

    .legend {
        justify-content: flex-start;
    }
}

@media (max-width: 650px) {
    .app-shell {
        width: min(100% - 20px, 1180px);
    }

    .app-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .status-badge {
        min-width: 0;
    }

    .gauge-card {
        min-height: 390px;
        padding: 18px;
    }

    .gauge-wrapper {
        min-height: 270px;
    }

    .gauge-value {
        top: 56%;
    }

    .power-state {
        top: 75%;
    }

    .stats-column {
        grid-template-columns: 1fr;
    }

    .stat-card {
        align-items: center;
        flex-direction: row;
    }

    .info-card {
        padding: 19px;
    }

    .app-footer {
        flex-direction: column;
        gap: 5px;
    }
}
.chart-card {
    margin-top: 20px;
    padding: 24px;
}

.chart-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;

    margin-bottom: 20px;
}

.chart-summary {
    display: flex;
    align-items: center;
    gap: 24px;
}

.chart-summary > div {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
}

.chart-summary span {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.chart-summary strong {
    color: var(--text);
    font-size: 0.9rem;
}

.chart-container {
    position: relative;

    width: 100%;
    height: 390px;

    padding: 8px 0;
}

#dailyPowerChart {
    width: 100% !important;
    height: 100% !important;
}

.chart-empty-state {
    position: absolute;
    inset: 0;

    z-index: 2;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 30px;

    color: var(--text-muted);
    text-align: center;
    font-size: 0.9rem;

    pointer-events: none;
}

.chart-empty-state.hidden {
    display: none;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;

    margin-top: 18px;

    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 650;
}

.chart-legend > div {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-legend-line {
    display: inline-block;

    width: 26px;
    height: 3px;

    border-radius: 999px;
}

.chart-legend-line.average {
    background: #58a6ff;
}

.chart-legend-line.maximum {
    background: #a371f7;
}

@media (max-width: 650px) {
    .chart-card {
        padding: 18px 12px 18px 18px;
    }

    .chart-header {
        flex-direction: column;
        gap: 14px;
    }

    .chart-summary {
        width: 100%;
        justify-content: space-between;
    }

    .chart-summary > div {
        align-items: flex-start;
    }

    .chart-container {
        height: 330px;
    }
}
.chart-range-selector {
    display: inline-flex;
    gap: 4px;

    padding: 4px;

    border: 1px solid var(--border);
    border-radius: 14px;

    background: var(--surface-soft);
}

.chart-range-button {
    appearance: none;

    padding: 8px 13px;

    border: 0;
    border-radius: 10px;

    color: var(--text-muted);
    background: transparent;

    font-size: 0.78rem;
    font-weight: 800;

    cursor: pointer;

    transition:
        color 150ms ease,
        background 150ms ease;
}

.chart-range-button:hover {
    color: var(--text);
}

.chart-range-button.active {
    color: var(--text);
    background: rgba(88, 166, 255, 0.16);
}

.chart-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 18px 30px;

    margin-bottom: 18px;
}

.chart-summary > div {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.chart-summary span {
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.chart-summary strong {
    color: var(--text);
    font-size: 0.9rem;
}

.chart-legend-line.instantaneous {
    background: #58a6ff;
}

.chart-legend-line.warning-limit {
    height: 2px;
    background: #d29922;
}

.chart-legend-line.critical-limit {
    height: 2px;
    background: #f85149;
}

.chart-legend-line.contracted-limit {
    height: 2px;
    background: #ff7b72;
}

@media (max-width: 650px) {
    .chart-range-selector {
        width: 100%;
    }

    .chart-range-button {
        flex: 1;
    }

    .chart-summary {
        justify-content: space-between;
        gap: 14px;
    }
}