:root {
    color-scheme: light;
    --ink: #17201d;
    --muted: #61706a;
    --line: #d7ded9;
    --paper: #f7f8f4;
    --panel: #ffffff;
    --pv: #e2a915;
    --load: #2d8c7f;
    --grid: #6f5cc2;
    --battery: #33834d;
    --danger: #b44046;
    --shadow: 0 18px 45px rgba(21, 30, 26, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(247, 248, 244, 0.98)),
        repeating-linear-gradient(90deg, rgba(45, 140, 127, 0.08) 0, rgba(45, 140, 127, 0.08) 1px, transparent 1px, transparent 96px);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    letter-spacing: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 28px clamp(18px, 4vw, 52px);
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(16px);
    position: sticky;
    top: 0;
    z-index: 10;
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: clamp(28px, 4vw, 48px);
    line-height: 1.04;
    font-weight: 800;
}

h2 {
    font-size: clamp(22px, 3vw, 32px);
    line-height: 1.1;
}

.eyebrow {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.muted {
    color: var(--muted);
    font-size: 13px;
}

.status-stack {
    display: flex;
    align-items: flex-end;
    flex-direction: column;
    gap: 8px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    border-radius: 999px;
    padding: 0 14px;
    font-size: 13px;
    font-weight: 700;
    border: 1px solid var(--line);
    background: var(--panel);
}

.status-ok {
    color: #17613b;
    border-color: rgba(51, 131, 77, 0.28);
    background: rgba(51, 131, 77, 0.1);
}

.status-error {
    color: var(--danger);
    border-color: rgba(180, 64, 70, 0.26);
    background: rgba(180, 64, 70, 0.1);
}

.status-pending {
    color: var(--muted);
}

.shell {
    width: min(1440px, 100%);
    margin: 0 auto;
    padding: clamp(18px, 4vw, 52px);
}

.alert {
    margin-bottom: 18px;
    padding: 14px 16px;
    border: 1px solid rgba(180, 64, 70, 0.28);
    border-left: 4px solid var(--danger);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    color: #73262b;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.metric {
    display: flex;
    min-height: 154px;
    flex-direction: column;
    justify-content: space-between;
    border-radius: 8px;
    padding: 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    overflow: hidden;
    position: relative;
}

.metric::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 5px;
    background: var(--accent, var(--line));
}

.metric-pv {
    --accent: var(--pv);
}

.metric-load {
    --accent: var(--load);
}

.metric-grid {
    --accent: var(--grid);
}

.metric-battery {
    --accent: var(--battery);
}

.metric-label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.metric strong {
    font-size: clamp(28px, 4vw, 46px);
    line-height: 1;
    white-space: nowrap;
}

.metric small {
    color: var(--muted);
    font-size: 14px;
}

.energy-band {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.7fr);
    gap: 18px;
    margin-top: 22px;
    align-items: stretch;
}

.flow-board {
    min-height: 390px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(247, 248, 244, 0.86)),
        repeating-linear-gradient(90deg, rgba(97, 112, 106, 0.08) 0, rgba(97, 112, 106, 0.08) 1px, transparent 1px, transparent 96px),
        repeating-linear-gradient(0deg, rgba(97, 112, 106, 0.06) 0, rgba(97, 112, 106, 0.06) 1px, transparent 1px, transparent 78px);
    box-shadow: var(--shadow);
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(90px, 1fr));
    align-items: center;
    padding: clamp(16px, 3vw, 34px);
    position: relative;
    overflow: hidden;
}

.flow-node {
    min-width: 0;
    min-height: 124px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.94);
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 16px;
    position: relative;
    z-index: 2;
    overflow: hidden;
    box-shadow: 0 12px 30px rgba(21, 30, 26, 0.1);
}

.flow-node::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 5px;
    background: var(--accent, var(--line));
}

.flow-visual {
    width: 52px;
    height: 52px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--accent, var(--muted));
    display: flex;
    align-items: center;
    justify-content: center;
}

.flow-visual svg {
    width: 38px;
    height: 38px;
}

.flow-copy {
    min-width: 0;
    display: grid;
    gap: 8px;
}

.flow-copy span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.flow-copy strong {
    font-size: clamp(20px, 2.3vw, 30px);
    line-height: 1;
    white-space: nowrap;
}

.flow-copy small {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.flow-node.source {
    --accent: var(--pv);
    grid-column: 1 / 3;
    grid-row: 1;
    border-color: rgba(226, 169, 21, 0.45);
}

.flow-node.source .flow-visual {
    border-color: rgba(226, 169, 21, 0.38);
    background: rgba(226, 169, 21, 0.11);
}

.flow-node.home {
    --accent: var(--load);
    grid-column: 3 / 5;
    grid-row: 2;
    border-color: rgba(45, 140, 127, 0.45);
}

.flow-node.home .flow-visual {
    border-color: rgba(45, 140, 127, 0.38);
    background: rgba(45, 140, 127, 0.1);
}

.flow-node.grid {
    --accent: var(--grid);
    grid-column: 5 / 7;
    grid-row: 2;
    border-color: rgba(111, 92, 194, 0.45);
}

.flow-node.grid .flow-visual {
    border-color: rgba(111, 92, 194, 0.38);
    background: rgba(111, 92, 194, 0.1);
}

.flow-node.battery {
    --accent: var(--battery);
    grid-column: 2 / 4;
    grid-row: 3;
    border-color: rgba(51, 131, 77, 0.45);
}

.flow-node.battery .flow-visual {
    border-color: rgba(51, 131, 77, 0.38);
    background: rgba(51, 131, 77, 0.1);
}

.flow-line {
    height: 6px;
    background: linear-gradient(90deg, var(--pv), var(--load), var(--grid));
    border-radius: 999px;
    opacity: 0.72;
    z-index: 1;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.58), 0 8px 18px rgba(45, 140, 127, 0.18);
}

.flow-line-a {
    grid-column: 2 / 5;
    grid-row: 1 / 3;
    transform: rotate(28deg);
}

.flow-line-b {
    grid-column: 4 / 6;
    grid-row: 2;
}

.summary-panel {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.summary-panel > div {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 18px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
}

.summary-panel span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.summary-panel strong {
    font-size: clamp(22px, 3vw, 34px);
}

.daily-charts-band {
    margin-top: 22px;
    border-top: 1px solid var(--line);
    padding-top: 24px;
}

.daily-charts-grid {
    display: grid;
    grid-template-columns: 1fr 1.1fr 1fr;
    gap: 14px;
}

.chart-panel {
    min-width: 0;
    min-height: 270px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 18px;
}

.chart-card-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.chart-card-head span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.chart-card-head strong {
    max-width: 60%;
    text-align: right;
    font-size: clamp(18px, 2.2vw, 26px);
    line-height: 1.1;
}

.data-pill {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    padding: 0 12px;
    white-space: nowrap;
}

.data-pill.ok {
    border-color: rgba(51, 131, 77, 0.28);
    background: rgba(51, 131, 77, 0.1);
    color: #17613b;
}

.data-pill.error {
    border-color: rgba(180, 64, 70, 0.28);
    background: rgba(180, 64, 70, 0.1);
    color: var(--danger);
}

.data-pill.sell {
    border-color: rgba(51, 131, 77, 0.28);
    background: rgba(51, 131, 77, 0.1);
    color: #17613b;
}

.data-pill.use {
    border-color: rgba(226, 169, 21, 0.32);
    background: rgba(226, 169, 21, 0.14);
    color: #6d5310;
}

.data-pill.neutral {
    border-color: rgba(111, 92, 194, 0.24);
    background: rgba(111, 92, 194, 0.1);
    color: #4e4288;
}

.balance-chart {
    display: grid;
    gap: 16px;
}

.balance-row {
    display: grid;
    gap: 8px;
}

.balance-row-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.balance-row-head span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.balance-row-head strong {
    font-size: 18px;
}

.balance-track {
    height: 18px;
    border-radius: 999px;
    background: rgba(97, 112, 106, 0.14);
    overflow: hidden;
}

.balance-track span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--load);
}

.balance-row.export .balance-track span,
.balance-row.cost-out .balance-track span {
    background: var(--battery);
}

.balance-row.import .balance-track span,
.balance-row.cost-in .balance-track span {
    background: var(--grid);
}

.daily-energy-chart {
    min-height: 185px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    align-items: end;
}

.daily-energy-bar {
    min-width: 0;
    height: 185px;
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 8px;
    align-items: end;
    text-align: center;
}

.daily-energy-bar strong {
    min-height: 22px;
    font-size: 13px;
    white-space: nowrap;
}

.daily-energy-bar div {
    min-height: 112px;
    display: flex;
    align-items: end;
    justify-content: center;
}

.daily-energy-bar div span {
    width: min(100%, 44px);
    min-height: 6px;
    border-radius: 999px 999px 3px 3px;
    background: var(--load);
}

.daily-energy-bar.pv div span {
    background: var(--pv);
}

.daily-energy-bar.load div span {
    background: var(--load);
}

.daily-energy-bar.import div span {
    background: var(--grid);
}

.daily-energy-bar.export div span {
    background: var(--battery);
}

.daily-energy-bar small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.load-report-band {
    margin-top: 22px;
    border-top: 1px solid var(--line);
    padding-top: 24px;
}

.load-report-band[hidden] {
    display: none;
}

.load-report-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
    margin-bottom: 16px;
}

.load-stat-card {
    min-width: 0;
    min-height: 118px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 14px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 7px;
}

.load-stat-card span,
.load-stat-card small {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.load-stat-card strong {
    font-size: clamp(18px, 2.1vw, 27px);
    line-height: 1.12;
}

.load-daily-chart,
.load-hourly-chart {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 18px 14px;
    overflow-x: auto;
}

.load-daily-chart {
    min-height: 260px;
    margin-bottom: 16px;
}

.load-hourly-chart {
    min-height: 340px;
}

.load-day-bars,
.load-hour-bars {
    display: grid;
    align-items: end;
    gap: 7px;
}

.load-day-bars {
    min-width: 720px;
    min-height: 220px;
    grid-template-columns: repeat(14, minmax(32px, 1fr));
}

.load-hour-bars {
    min-width: 860px;
    min-height: 304px;
    grid-template-columns: repeat(24, minmax(24px, 1fr));
}

.load-day-bar,
.load-hour-bar {
    min-width: 0;
    min-height: 5px;
    border: 0;
    border-radius: 8px 8px 3px 3px;
    background: linear-gradient(180deg, var(--load), #29756d);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    padding: 8px 2px 5px;
}

.load-day-bar {
    cursor: pointer;
}

.load-day-bar:hover,
.load-day-bar.active {
    outline: 2px solid var(--pv);
    outline-offset: 2px;
}

.load-day-bar.unavailable {
    opacity: 0.42;
    background: linear-gradient(180deg, #9da9a3, #74807a);
}

.load-day-bar span,
.load-hour-bar span {
    display: none;
}

.load-day-bar small,
.load-hour-bar strong {
    color: rgba(255, 255, 255, 0.94);
    font-size: 11px;
    font-weight: 800;
}

.load-table-wrap {
    max-height: 460px;
}

.weather-band {
    margin-top: 22px;
    border-top: 1px solid var(--line);
    padding-top: 24px;
}

.weather-band[hidden] {
    display: none;
}

.weather-head-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.weather-day-tabs {
    justify-content: flex-start;
    margin-bottom: 14px;
}

.range-tabs {
    display: inline-flex;
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    overflow: hidden;
}

.range-tab {
    min-width: 72px;
    border: 0;
    border-right: 1px solid var(--line);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    padding: 0 12px;
}

.range-tab:last-child {
    border-right: 0;
}

.range-tab.active {
    background: rgba(45, 140, 127, 0.12);
    color: var(--ink);
}

.range-tab:hover {
    background: rgba(45, 140, 127, 0.08);
}

.weather-stats-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.weather-stat-card {
    min-width: 0;
    min-height: 118px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 14px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 7px;
}

.weather-stat-card span,
.weather-stat-card small {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.weather-stat-card strong {
    font-size: clamp(18px, 2.1vw, 27px);
    line-height: 1.12;
    overflow-wrap: anywhere;
}

.weather-chart {
    min-height: 360px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 18px 14px;
    overflow-x: auto;
}

.weather-bars {
    min-width: 980px;
    min-height: 324px;
    display: grid;
    gap: 6px;
    align-items: stretch;
}

.weather-bar {
    min-width: 0;
    min-height: 0;
    height: 100%;
    border-radius: 8px 8px 3px 3px;
    background: rgba(95, 109, 103, 0.16);
    color: #ffffff;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
    padding: 8px 2px 5px;
}

.weather-forecast-fill,
.weather-actual-fill {
    position: absolute;
    bottom: 0;
    display: block;
}

.weather-forecast-fill {
    left: 0;
    right: 0;
    height: var(--forecast-height, 0%);
    border-radius: 8px 8px 3px 3px;
    background: var(--muted);
}

.weather-actual-fill {
    left: 5px;
    right: 5px;
    height: var(--actual-height, 0%);
    border: 2px solid rgba(255, 255, 255, 0.92);
    border-bottom: 0;
    border-radius: 7px 7px 2px 2px;
    background: #17201d;
    box-shadow: 0 -6px 14px rgba(23, 32, 29, 0.16);
}

.weather-bar.high .weather-forecast-fill {
    background: linear-gradient(180deg, var(--pv), #c79213);
}

.weather-bar.medium .weather-forecast-fill {
    background: linear-gradient(180deg, var(--load), #307d85);
}

.weather-bar.low .weather-forecast-fill {
    background: linear-gradient(180deg, #93a19b, #6f7d77);
}

.weather-bar.rain .weather-forecast-fill {
    background: linear-gradient(180deg, var(--grid), #5c539d);
}

.weather-bar.current {
    outline: 2px solid var(--battery);
    outline-offset: 2px;
}

.weather-bar span {
    display: none;
    position: absolute;
}

.weather-bar strong {
    font-size: 11px;
    position: relative;
    z-index: 2;
    text-shadow: 0 1px 3px rgba(23, 32, 29, 0.4);
}

.weather-bar small {
    color: rgba(255, 255, 255, 0.92);
    font-size: 9px;
    font-weight: 800;
    position: relative;
    z-index: 2;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    text-shadow: 0 1px 3px rgba(23, 32, 29, 0.45);
}

.weather-table-wrap {
    max-height: 460px;
}

.supla-band {
    margin-top: 22px;
    border-top: 1px solid var(--line);
    padding-top: 24px;
}

.supla-band[hidden] {
    display: none;
}

.supla-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.supla-card {
    min-width: 0;
    min-height: 132px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
}

.supla-card span,
.supla-card small {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.supla-card strong {
    font-size: clamp(21px, 2.5vw, 31px);
    line-height: 1.1;
}

.supla-phase-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.supla-phase-card {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.86);
    padding: 14px;
    display: grid;
    gap: 10px;
}

.supla-phase-card > strong {
    font-size: 18px;
}

.supla-phase-card div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-top: 1px solid rgba(215, 222, 217, 0.72);
    padding-top: 9px;
}

.supla-phase-card span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.supla-phase-card b {
    text-align: right;
    font-size: 16px;
}

.sell-plan-band {
    margin-top: 22px;
    border-top: 1px solid var(--line);
    padding-top: 24px;
}

.sell-context-grid,
.sell-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.sell-stats-grid {
    margin-top: 12px;
}

.sell-context-card,
.sell-stat-card {
    min-width: 0;
    min-height: 116px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 14px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 7px;
}

.sell-context-card span,
.sell-context-card small,
.sell-stat-card span,
.sell-stat-card small {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.sell-context-card strong,
.sell-stat-card strong {
    font-size: clamp(18px, 2.1vw, 26px);
    line-height: 1.12;
    overflow-wrap: anywhere;
}

.sell-chart {
    min-height: 360px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 18px 14px;
    margin-top: 16px;
    overflow-x: auto;
}

.sell-bars {
    min-width: 920px;
    min-height: 324px;
    display: grid;
    grid-template-columns: repeat(24, minmax(26px, 1fr));
    gap: 7px;
    align-items: end;
    position: relative;
}

.sell-bars::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: var(--baseline, 0%);
    border-top: 1px dashed rgba(97, 112, 106, 0.55);
}

.sell-bar {
    min-width: 0;
    min-height: 6px;
    border-radius: 8px 8px 3px 3px;
    background: var(--load);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    gap: 4px;
    padding: 8px 2px 5px;
    position: relative;
    z-index: 1;
}

.sell-bar.sell {
    background: linear-gradient(180deg, var(--battery), #69ad73);
}

.sell-bar.use {
    background: linear-gradient(180deg, var(--pv), #b58a1d);
}

.sell-bar.neutral {
    background: linear-gradient(180deg, var(--grid), var(--load));
}

.sell-bar span {
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.22);
    padding: 2px 5px;
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
}

.sell-bar strong {
    font-size: 13px;
}

.sell-bar small {
    max-width: 100%;
    color: rgba(255, 255, 255, 0.92);
    font-size: 10px;
    font-weight: 700;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
}

.sell-table-wrap {
    max-height: 460px;
}

.sell-row-sell {
    background: rgba(51, 131, 77, 0.08);
}

.sell-row-use {
    background: rgba(226, 169, 21, 0.1);
}

.tariff-band,
.forecast-band,
.config-band {
    margin-top: 22px;
    border-top: 1px solid var(--line);
    padding-top: 24px;
}

.config-band {
    color: var(--muted);
}

.config-band summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    cursor: pointer;
    list-style: none;
}

.config-band summary::-webkit-details-marker {
    display: none;
}

.config-band summary::after {
    content: "+";
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    font-size: 22px;
    font-weight: 700;
    flex: 0 0 auto;
}

.config-band[open] summary::after {
    content: "-";
}

.entity-count {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    padding: 0 10px;
    margin-left: auto;
    white-space: nowrap;
}

.section-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 16px;
}

.refresh-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    cursor: pointer;
    font-weight: 700;
}

.refresh-button:hover {
    border-color: #9ca9a3;
}

.day-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.day-tab {
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    cursor: pointer;
    font-weight: 700;
    padding: 0 12px;
}

.day-tab.active {
    border-color: rgba(45, 140, 127, 0.45);
    background: rgba(45, 140, 127, 0.12);
}

.day-tab.unavailable {
    color: var(--muted);
    opacity: 0.58;
}

.plain-link {
    color: var(--ink);
    font-weight: 700;
    text-decoration: none;
}

.plain-link:hover {
    text-decoration: underline;
}

.diagnostics-panel {
    border-top: 1px solid var(--line);
    padding-top: 24px;
}

.search-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-form input {
    width: min(360px, 48vw);
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 12px;
    font: inherit;
}

.hourly-chart {
    display: grid;
    grid-template-columns: repeat(24, minmax(20px, 1fr));
    gap: 5px;
    min-height: 190px;
    align-items: end;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 18px 12px 12px;
}

.module-note {
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.hour-bar {
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

.hour-bar span {
    width: 100%;
    min-height: 4px;
    border-radius: 999px 999px 2px 2px;
    background: var(--load);
}

.hour-bar.negative span {
    background: var(--battery);
}

.hour-bar.current span {
    outline: 2px solid var(--pv);
    outline-offset: 2px;
}

.hour-bar small {
    color: var(--muted);
    font-size: 10px;
}

.table-wrap {
    margin-top: 16px;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.price-day-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.price-day-card {
    min-height: 134px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 7px;
}

.price-day-card span,
.price-day-card small {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.price-day-card strong {
    font-size: clamp(20px, 2.6vw, 30px);
}

.price-day-card.unavailable {
    border-color: rgba(180, 64, 70, 0.28);
}

.advice-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.advice-item {
    min-height: 98px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.86);
    padding: 14px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
}

.advice-item span,
.advice-item small {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.advice-item strong {
    font-size: clamp(17px, 2vw, 24px);
    line-height: 1.15;
}

.price-report-chart {
    min-height: 360px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 18px 14px;
    margin-bottom: 16px;
    overflow-x: auto;
}

.price-bars {
    min-width: 860px;
    min-height: 324px;
    display: grid;
    grid-template-columns: repeat(24, minmax(22px, 1fr));
    gap: 7px;
    align-items: end;
    position: relative;
}

.price-bars::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: var(--baseline, 0%);
    border-top: 1px dashed rgba(97, 112, 106, 0.55);
}

.price-bar {
    min-width: 0;
    min-height: 4px;
    border: 0;
    border-radius: 8px 8px 3px 3px;
    background: linear-gradient(180deg, var(--grid), var(--load));
    color: #ffffff;
    cursor: default;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 7px 2px 4px;
    position: relative;
    z-index: 1;
}

.price-bar.negative {
    background: linear-gradient(180deg, var(--battery), #5da96f);
}

.price-bar span {
    display: none;
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
    min-width: max-content;
    border-radius: 8px;
    background: var(--ink);
    color: #ffffff;
    padding: 7px 9px;
    font-size: 12px;
    font-weight: 700;
    box-shadow: var(--shadow);
}

.price-bar:hover span,
.price-bar:focus-visible span {
    display: block;
}

.price-bar small {
    color: rgba(255, 255, 255, 0.92);
    font-size: 10px;
    font-weight: 700;
}

.chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: var(--muted);
    font-weight: 700;
}

.forecast-table-wrap {
    max-height: 460px;
}

table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
}

th,
td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    text-align: right;
    white-space: nowrap;
}

th:first-child,
td:first-child {
    text-align: left;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

tr.current-row {
    background: rgba(226, 169, 21, 0.12);
}

tr.warning-row {
    background: rgba(180, 64, 70, 0.08);
}

code {
    font-family: Consolas, Monaco, monospace;
    font-size: 13px;
}

.mini-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 26px;
    border-radius: 999px;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 700;
    background: rgba(51, 131, 77, 0.1);
    color: #17613b;
}

.mini-nieznany,
.mini-niedostepny,
.mini-rozlaczony,
.mini-pusty {
    background: rgba(180, 64, 70, 0.1);
    color: var(--danger);
}

.entity-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    margin-top: 16px;
}

.entity-item {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(150px, 0.25fr) minmax(0, 1fr) minmax(110px, 0.18fr) minmax(82px, 0.12fr);
    gap: 12px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.84);
    padding: 8px 12px;
}

.entity-item code,
.entity-item span,
.entity-item strong,
.entity-item small {
    overflow-wrap: anywhere;
}

.entity-item span {
    color: var(--ink);
    font-size: 13px;
    font-weight: 700;
}

.entity-item code {
    color: var(--muted);
    font-size: 13px;
}

.entity-value {
    color: var(--ink);
    font-size: 15px;
    text-align: right;
}

.entity-status {
    justify-self: end;
    border-radius: 999px;
    padding: 5px 9px;
    background: rgba(97, 112, 106, 0.1);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.entity-status.ok {
    background: rgba(51, 131, 77, 0.1);
    color: #17613b;
}

.entity-status.error {
    background: rgba(180, 64, 70, 0.1);
    color: var(--danger);
}

@media (max-width: 980px) {
    .metrics-grid,
    .energy-band,
    .daily-charts-grid,
    .load-report-stats,
    .weather-stats-grid,
    .supla-grid,
    .supla-phase-grid,
    .sell-context-grid,
    .sell-stats-grid,
    .price-day-grid,
    .advice-grid {
        grid-template-columns: 1fr 1fr;
    }

    .flow-board,
    .summary-panel {
        grid-column: 1 / -1;
    }
}

@media (max-width: 680px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .status-stack {
        align-items: flex-start;
    }

    .metrics-grid,
    .energy-band,
    .daily-charts-grid,
    .load-report-stats,
    .weather-stats-grid,
    .supla-grid,
    .supla-phase-grid,
    .sell-context-grid,
    .sell-stats-grid,
    .price-day-grid,
    .advice-grid,
    .entity-list {
        grid-template-columns: 1fr;
    }

    .chart-card-head,
    .balance-row-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .chart-card-head strong {
        max-width: 100%;
        text-align: left;
    }

    .data-pill {
        white-space: normal;
    }

    .entity-item {
        grid-template-columns: 1fr;
    }

    .entity-value {
        text-align: left;
    }

    .entity-status {
        justify-self: start;
    }

    .flow-board {
        grid-template-columns: 1fr;
        grid-template-rows: none;
        gap: 12px;
    }

    .flow-node.source,
    .flow-node.home,
    .flow-node.grid,
    .flow-node.battery {
        grid-column: auto;
        grid-row: auto;
    }

    .flow-line {
        display: none;
    }

    .hourly-chart {
        grid-template-columns: repeat(12, minmax(20px, 1fr));
    }

    .section-head,
    .search-form,
    .weather-head-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .range-tabs {
        width: 100%;
    }

    .range-tab {
        flex: 1;
    }

    .day-tabs {
        justify-content: flex-start;
    }

    .search-form input {
        width: 100%;
    }
}
