:root {
    color-scheme: dark;
    --bg: #0f1113;
    --bg-nav: #121417;
    --card: #17191c;
    --card-2: #1d2024;
    --line: #23262a;
    --line-2: #2e3136;
    --axis: #3a3d42;
    --text: #f2efe8;
    --text-2: #b9b5ab;
    --muted: #8d8a83;
    --solar: #c98500;
    --solar-hi: #e0a422;
    --solar-light: #e0b048;
    --solar-dark: #a86f00;
    --battery: #9085e9;
    --export: #199e70;
    --export-hi: #2fc28c;
    --grid: #6f747c;
    --home: #f2efe8;
    --car: #d55181;
    --car-light: #eba0bc;
    --good: #0ca30c;
    --warning: #fab219;
    --serious: #ec835a;
    --critical: #d03b3b;
    --info: #7fb0ec;
    --radius: 14px;
    --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--solar-light); }
a:hover { color: #f2cf7a; }

button { font: inherit; }

/* ---------------------------------------------------------------- nav */

.hp-nav {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
    padding: 10px 24px;
    background: var(--bg-nav);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}

.hp-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    font-size: 16px;
}

.hp-brand:hover { color: var(--text); }

.hp-tabs { display: flex; gap: 2px; flex-wrap: wrap; }

.hp-tabs a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-2);
    text-decoration: none;
    padding: 9px 14px;
    border-radius: 8px;
    min-height: 40px;
}

.hp-tabs a:hover { background: var(--card); color: var(--text); }
.hp-tabs a[aria-current="page"] { background: var(--line-2); color: var(--text); font-weight: 500; }

.hp-count {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--critical);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.hp-status {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-2);
}

.hp-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--muted);
}

.hp-dot.ok { background: var(--good); }
.hp-dot.bad { background: var(--critical); }

/* ---------------------------------------------------------------- layout */

.hp-main {
    max-width: 1232px;
    margin: 0 auto;
    padding: 28px 24px 64px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.hp-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}

.hp-head h1 {
    margin: 0;
    font-size: 30px;
    line-height: 1.2;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.hp-eyebrow { font-size: 14px; color: var(--text-2); }

.hp-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.hp-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.hp-grid.wide { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }

/* compact KPI row (Trends): six tiles on one line on desktop */
.hp-grid.hp-kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.hp-kpis .hp-tile { padding: 12px 14px; gap: 2px; }
.hp-kpis .hp-tile .value { font-size: 24px; }
.hp-kpis .hp-tile .value small { font-size: 14px; }
.hp-kpis .hp-tile .hint { font-size: 12px; line-height: 1.35; }
.hp-grid.hp-kpis.k8 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1000px) { .hp-grid.hp-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } .hp-grid.hp-kpis.k8 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 560px) { .hp-grid.hp-kpis, .hp-grid.hp-kpis.k8 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.hp-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
}

.hp-card-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
}

.hp-card h2 { margin: 0; font-size: 18px; font-weight: 600; }
.hp-sub { font-size: 13px; color: var(--text-2); }
.hp-muted { color: var(--muted); }
.hp-small { font-size: 13px; }

/* ---------------------------------------------------------------- tiles */

.hp-tile {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.hp-tile .label { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.hp-tile .value { font-size: 30px; font-weight: 600; line-height: 1.15; }
.hp-tile .value small { font-size: 16px; color: var(--text-2); font-weight: 500; margin-left: 2px; }
.hp-tile .hint { font-size: 13px; color: var(--text-2); }

.hp-swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }

/* ---------------------------------------------------------------- controls */

.hp-btn {
    min-height: 40px;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid var(--line-2);
    background: var(--card);
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-decoration: none;
}

.hp-btn:hover:not([disabled]) { background: var(--card-2); color: var(--text); }
.hp-btn[disabled] { color: #5d5a54; cursor: default; }
.hp-btn.icon { width: 40px; padding: 0; }

.hp-seg {
    display: inline-flex;
    background: var(--card);
    border: 1px solid var(--line-2);
    border-radius: 10px;
    padding: 3px;
}

.hp-seg button {
    min-height: 36px;
    padding: 0 14px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
}

.hp-seg button[aria-pressed="true"] { background: var(--line-2); color: var(--text); font-weight: 500; }

/* ---------------------------------------------------------------- legend & tags */

.hp-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.hp-legend span { display: inline-flex; align-items: center; gap: 6px; }
.hp-legend .line { width: 16px; height: 0; border-top: 2px solid var(--text); }
.hp-legend .line.dash { border-top-style: dashed; }
.hp-legend .line.ghost { border-top: 2px dashed var(--info); }

/* change against a comparison period, under a KPI tile */
.hp-delta { font-size: 12px; line-height: 1.35; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 1.35em; }
.hp-delta b { font-weight: 600; }
.hp-delta.good b { color: #4fd14f; }
.hp-delta.bad b { color: var(--serious); }
#hist-legend { margin: 0 0 8px; }
#hist-seg { max-width: 100%; overflow-x: auto; }
#hist-seg button { white-space: nowrap; }
@media (max-width: 560px) { #hist-seg button { padding: 0 10px; } }
#t-years td.dim { color: var(--muted); }
#t-years th, #t-years td { white-space: nowrap; }

.hp-tag {
    font-family: var(--mono);
    font-size: 11px;
    padding: 0 6px;
    border-radius: 4px;
    border: 1px solid var(--line-2);
    color: var(--text-2);
    white-space: nowrap;
}

.hp-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--card-2);
    color: var(--text-2);
}

.hp-pill.good { color: #4fd14f; background: #10230f; }
.hp-pill.warning { color: var(--warning); background: #2a2210; }
.hp-pill.serious { color: var(--serious); background: #2a1d14; }
.hp-pill.critical { color: #f08080; background: #2d1515; }
.hp-pill.info { color: var(--info); background: #13202f; }

/* ---------------------------------------------------------------- charts */

.hp-chart { position: relative; width: 100%; }
.hp-chart svg { display: block; overflow: visible; }
.hp-chart .tick { font-size: 11px; fill: var(--muted); font-family: var(--font); }
.hp-chart .ann { font-size: 12px; fill: var(--text-2); font-family: var(--font); }

.hp-tip {
    position: absolute;
    pointer-events: none;
    background: #23262a;
    border: 1px solid #34383d;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.45;
    white-space: nowrap;
    z-index: 5;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.hp-tip strong { display: block; font-size: 13px; margin-bottom: 2px; }
.hp-tip .row { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.hp-tip .row span:first-child { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.hp-tip .row b { font-weight: 600; font-variant-numeric: tabular-nums; }

.hp-panel-title { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; }
.hp-panel-title strong { font-weight: 600; }

.hp-divider { border-top: 1px solid var(--line); padding-top: 14px; }

/* ---------------------------------------------------------------- lists */

.hp-insights { display: flex; flex-direction: column; gap: 14px; }

.hp-insight { display: flex; gap: 12px; align-items: flex-start; }
.hp-insight .ico {
    flex: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--card-2);
}
.hp-insight strong { display: block; font-size: 15px; }
.hp-insight p { margin: 2px 0 0; font-size: 14px; color: var(--text-2); }

.hp-bars { display: flex; flex-direction: column; gap: 10px; }
.hp-bar-row {
    display: grid;
    grid-template-columns: minmax(110px, 160px) 1fr 64px;
    gap: 12px;
    align-items: center;
    font-size: 14px;
}
.hp-bar-row .track { height: 12px; background: var(--line); border-radius: 4px; position: relative; }
.hp-bar-row .fill { height: 12px; border-radius: 4px; background: var(--solar); }
.hp-bar-row .mark { position: absolute; top: -3px; width: 2px; height: 18px; background: var(--text); border-radius: 1px; }
.hp-bar-row .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.hp-bar-row .name small { display: block; color: var(--muted); font-size: 12px; }

/* period energy balance: one split bar per side of the meter */
.hp-balance { display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px; }
.hp-bal-row { display: grid; grid-template-columns: minmax(110px, 160px) 1fr; gap: 12px; align-items: start; font-size: 14px; }
.hp-bal-row .name strong { display: block; font-weight: 600; }
.hp-bal-row .name small { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.hp-split { display: flex; gap: 2px; height: 14px; margin-top: 3px; border-radius: 4px; overflow: hidden; background: var(--line); }
.hp-split span { display: block; height: 100%; min-width: 2px; }
.hp-split-legend { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; margin-top: 6px; font-size: 13px; color: var(--text-2); }
.hp-split-legend span { display: inline-flex; align-items: center; gap: 6px; }
.hp-split-legend b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.hp-balance .note { font-size: 12px; color: var(--muted); }
@media (max-width: 560px) { .hp-bal-row { grid-template-columns: minmax(0, 1fr); gap: 4px; } }

.hp-table-wrap { overflow-x: auto; }
.hp-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
.hp-table th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
}
.hp-table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.hp-table td.num, .hp-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.hp-table tr:last-child td { border-bottom: 0; }
#m-car td.num { white-space: nowrap; }

.hp-alert {
    display: grid;
    grid-template-columns: 22px 1fr auto;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
    align-items: start;
}
.hp-alert:last-child { border-bottom: 0; }
.hp-alert strong { font-size: 14px; display: block; }
.hp-alert p { margin: 2px 0 0; font-size: 13px; color: var(--text-2); }
.hp-alert time { font-size: 12px; color: var(--muted); white-space: nowrap; text-align: right; }
.hp-alert.closed { opacity: 0.6; }

.hp-banner {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    background: #2a1d14;
    color: #f2dccf;
}
.hp-banner.info { background: #13202f; color: #d6e6fa; }
.hp-banner.critical { background: #2d1515; color: #f6d4d4; }

.hp-empty { color: var(--muted); margin: 0; }
.hp-skeleton { color: var(--muted); font-size: 14px; padding: 40px 0; text-align: center; }
.d-none { display: none !important; }

/* ---------------------------------------------------------------- live */

.hp-live { max-width: 1100px; }
.hp-hero-text { font-size: 32px; line-height: 1.15; font-weight: 600; margin: 0; }
.hp-flow { position: relative; width: 100%; max-width: 560px; margin: 0 auto; aspect-ratio: 560 / 380; }
.hp-flow > svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.hp-flow .node {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    transform: translate(-50%, -50%);
    text-align: center;
}
.hp-flow .node .badge {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--card-2);
    border: 1px solid var(--line-2);
}
.hp-flow .node b { font-size: 20px; line-height: 1.15; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hp-flow .node span { font-size: 12px; color: var(--text-2); }
.hp-flow path.flow { fill: none; stroke-width: 3; stroke-linecap: round; }
.hp-flow path.flow.active { stroke-dasharray: 6 10; animation: hp-dash 1.1s linear infinite; }
.hp-flow path.flow.idle { stroke: var(--axis) !important; stroke-dasharray: 2 6; }
@keyframes hp-dash { to { stroke-dashoffset: -32; } }
@media (prefers-reduced-motion: reduce) { .hp-flow path.flow.active { animation: none; } }

/* charge points (Live) */
.hp-cps { display: flex; flex-direction: column; gap: 14px; }
.hp-cp { display: flex; flex-direction: column; gap: 6px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.hp-cp:last-child { padding-bottom: 0; border-bottom: 0; }
.hp-cp-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.hp-cp-head strong { font-size: 15px; display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hp-cp-head b { font-size: 20px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hp-cp .hp-bar-row .fill { background: var(--car); }

.hp-battery {
    width: 64px;
    height: 26px;
    border: 2px solid var(--battery);
    border-radius: 6px;
    padding: 2px;
    position: relative;
}
.hp-battery::after {
    content: "";
    position: absolute;
    right: -6px;
    top: 7px;
    width: 4px;
    height: 8px;
    border-radius: 0 2px 2px 0;
    background: var(--battery);
}
.hp-battery .lvl { height: 100%; background: var(--battery); border-radius: 3px; }

@media (max-width: 720px) {
    .hp-nav { padding: 8px 12px 0; gap: 4px 8px; }
    .hp-tabs { order: 3; width: 100%; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; }
    .hp-tabs a { padding: 8px 10px; flex: none; }
    .hp-status { margin-left: auto; }
    .hp-main { padding: 20px 14px 48px; }
    .hp-head h1 { font-size: 24px; }
    .hp-card { padding: 16px; }
    .hp-tile .value { font-size: 26px; }
    .hp-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
    .hp-grid.wide { grid-template-columns: minmax(0, 1fr); }
    .hp-hero-text { font-size: 26px; }
    .hp-flow .node b { font-size: 16px; }
    .hp-flow .node .badge { width: 42px; height: 42px; }
    .hp-bar-row { grid-template-columns: 100px 1fr 52px; }
}
