@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

:root {
  --page: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #fafbfe;
  --text: #111827;
  --muted: #687588;
  --muted-2: #98a3b3;
  --line: #e7ebf1;
  --accent: #f4b321;
  --accent-dark: #c88400;
  --success: #209c60;
  --danger: #d83b3b;
  --info: #227cc6;
  --shadow-1:
    0 1px 2px rgba(15, 23, 42, 0.05), 0 10px 30px rgba(15, 23, 42, 0.06);
  --shadow-2: 0 18px 55px rgba(15, 23, 42, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--page);
  font-family:
    "Inter",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

body[data-theme="dark"] {
  --page: #0f141b;
  --surface: #151b24;
  --surface-2: #101720;
  --text: #edf2f7;
  --muted: #a8b3c2;
  --muted-2: #788699;
  --line: #263241;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 34px rgba(0, 0, 0, 0.28);
  --shadow-2: 0 18px 55px rgba(0, 0, 0, 0.38);
}

body[data-theme="dark"],
body[data-theme="dark"] * {
  color-scheme: dark;
}

body[data-theme="dark"]
  :where(
    h1,
    h2,
    h3,
    h4,
    p,
    label,
    legend,
    button,
    input,
    select,
    .nodeLabel,
    .brandTitle,
    .loggedUser,
    .naglowek-drop
  ) {
  color: var(--text);
}

body[data-theme="dark"]
  :where(svg, .themeToggle, .menuButton, .closeButton, .chartNav) {
  color: var(--text);
}

body[data-theme="dark"]
  :where(
    .muted,
    .brandSubtitle,
    .kpiLabel,
    .unit,
    .cycleCard small,
    .sectionToggle small,
    .panelTitle small,
    .settingsHeader small
  ) {
  color: var(--muted);
}

body[data-theme="dark"] :where(input, select, .settingsItem, #chartDate) {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--line);
}

body[data-theme="dark"] option {
  color: var(--text);
  background: var(--surface);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.appShell {
  width: min(1240px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 48px;
}

.appHeader {
  position: sticky;
  top: 12px;
  z-index: 50;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 14px;
  align-items: center;
  min-height: 72px;
  padding: 12px 14px;
  margin-bottom: 18px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.logo {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
}

.iconBadge {
  display: grid;
  place-items: center;
  color: var(--accent-dark);
  background: #fff8e8;
  border: 1px solid rgba(244, 179, 33, 0.35);
  border-radius: var(--radius);
}

body[data-theme="dark"] .iconBadge {
  background: rgba(244, 179, 33, 0.12);
}

.brandText {
  display: grid;
  min-width: 0;
}

.brandTitle {
  overflow: hidden;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brandSubtitle {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.headerContext {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.systemStatus {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 11px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--success);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.alertInline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 260px;
  min-height: 40px;
  padding: 0 11px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
}

.alertInline svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.alertInline .alertText {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.headerContext.hasAlert .alertInline {
  background: rgba(216, 59, 59, 0.08);
  border-color: rgba(216, 59, 59, 0.36);
  color: var(--danger);
}

.installationChip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 11px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.installationChip:hover {
  border-color: var(--accent);
}

.statusDot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 5px rgba(32, 156, 96, 0.12);
  animation: onlinePulse 1.8s ease-out infinite;
}

body.is-data-stale .systemStatus {
  color: var(--danger);
}

body.is-data-stale .statusDot {
  background: var(--danger);
  animation: none;
  box-shadow: 0 0 0 5px rgba(216, 59, 59, 0.12);
}

body.is-data-stale .energyFlow,
body.is-data-stale .summaryBand,
body.is-data-stale .kpiGrid {
  opacity: 0.58;
}

body.is-data-stale .energyFlow .flow,
body.is-data-stale .flowComet {
  animation-play-state: paused;
}

@keyframes onlinePulse {
  0% {
    box-shadow: 0 0 0 0 rgba(32, 156, 96, 0.36);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(32, 156, 96, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(32, 156, 96, 0);
  }
}

.loggedUser {
  color: var(--text);
}

.menuButton,
.closeButton,
.themeToggle {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.menuButton:hover,
.closeButton:hover,
.themeToggle:hover {
  transform: translateY(-1px);
  border-color: rgba(244, 179, 33, 0.72);
  box-shadow: var(--shadow-1);
}

.themeToggle {
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 800;
}

.menuButton span {
  display: none;
}

.menuButton svg,
.themeToggle svg,
.closeButton svg,
.nodeIcon svg,
.drop-icon,
.chartNav svg,
.logo svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

.closeButton {
  position: relative;
}

.closeButton::before,
.closeButton::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 99px;
}

.closeButton::before {
  transform: rotate(45deg);
}

.closeButton::after {
  transform: rotate(-45deg);
}

.sideMenu {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 100;
  width: 0;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--surface);
  box-shadow: -24px 0 70px rgba(15, 23, 42, 0.2);
  transition: width 0.32s ease;
}

.settingsHeader,
.settings {
  width: 330px;
  padding-inline: 24px;
}

.settingsHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.settname {
  display: block;
  font-size: 1.2rem;
  font-weight: 800;
}

.settingsHeader small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.settings {
  display: grid;
  gap: 10px;
  padding-top: 18px;
  padding-bottom: 28px;
}

label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.settingsItem,
.settingsItem2,
.settingsItemUsersPv,
.settingsItemUsersNowPv,
.settingsItemUsersImg {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.settingsItem {
  height: 44px;
  padding: 0 12px;
  color: var(--text);
}

.settingsItem:focus,
#chartDate:focus {
  outline: 3px solid rgba(244, 179, 33, 0.22);
  border-color: var(--accent);
}

.settingsItem2 {
  min-height: 38px;
  display: grid;
  place-items: center;
  color: var(--text);
  font-weight: 800;
}

.settingsItem3 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.settingsGroup {
  display: grid;
  gap: 8px;
  padding-top: 6px;
}

body.hide-rankings .settingsRankingGroup {
  display: none;
}

.settingsItemUsersPv,
.settingsItemUsersNowPv {
  min-height: 82px;
  padding: 10px;
  white-space: pre-line;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 600;
}

.settingsItemUsersImg {
  overflow: hidden;
  aspect-ratio: 16 / 10;
}

.imagepv {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.login,
.logout {
  padding: 0;
  color: #fff;
  background: var(--text);
  border-color: var(--text);
  font-weight: 800;
}

.login:hover,
.logout:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.logout,
#logoutBr {
  display: none;
}

.result {
  display: none;
  min-height: 18px;
  font-size: 0.8rem;
  font-weight: 700;
}

.dashboard {
  display: grid;
  gap: 16px;
}

.energyFlow {
  order: 1;
}

.summaryBand {
  order: 2;
}

.kpiGrid {
  order: 3;
}

.cycleStrip {
  order: 4;
}

#dc6 {
  order: 9;
}

.dropdown6 {
  order: 10;
}

#dc3 {
  order: 7;
}

.statystyki {
  order: 8;
}

#dc4 {
  order: 11;
}

.dropdown4 {
  order: 12;
}

#dc5 {
  order: 13;
}

.dropdown5 {
  order: 14;
}

.cdebug {
  order: 98;
}

.summaryBand,
.kpiCard,
.energyFlow,
.cycleCard,
.sectionToggle,
.analyticsPanel,
.dataTable,
.chartPanel,
.chartDane,
.cdebug {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}

.summaryBand {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
  padding: 0;
  overflow: hidden;
  background: transparent;
  border: 0;
  box-shadow: none;
  animation: fadeUp 0.45s ease both;
}

.eyebrow {
  display: inline-flex;
  margin-bottom: 10px;
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.liveProduction {
  display: grid;
  gap: 4px;
  justify-items: start;
  min-height: 120px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}

.livePv {
  border-color: rgba(32, 156, 96, 0.28);
}

.liveUse {
  border-color: rgba(244, 179, 33, 0.34);
}

.liveGrid {
  border-color: rgba(34, 124, 198, 0.25);
}

.liveProduction > span,
.kpiLabel,
.sectionHint {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.liveProduction strong {
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: 1;
}

.kpiGrid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.kpiCard {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: 22px 22px 20px 22px;
  border-color: var(--line);
  animation: fadeUp 0.5s ease both;
}

.kpiCard legend {
  padding: 0 8px;
  color: var(--muted-2);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.eDane,
.val {
  font-weight: 800;
}

.kpiCard .eDane,
.kpiCard .val {
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1;
}

.unit {
  color: var(--muted);
  font-size: 1rem;
  font-weight: 800;
}

.energyFlow {
  padding: 22px;
  animation: fadeUp 0.55s ease both;
}

.sectionHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.sectionHeader h2 {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.1;
}

.teslaFlow {
  min-height: 0;
}

.flowScene {
  position: relative;
  --flow-axis: calc(50% - 5px);
  min-height: 210px;
  display: grid;
  grid-template-columns: minmax(150px, 0.9fr) minmax(170px, 1fr) minmax(
      150px,
      0.9fr
    );
  grid-template-rows: 1fr;
  gap: 22px 44px;
  align-items: center;
  padding: 18px;
  isolation: isolate;
}

.flowScene .flowNode {
  width: min(210px, 100%);
  min-height: 132px;
  padding: 16px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(8px);
}

.flowScene .flowPvNode {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
}

.flowScene .flowHomeNode {
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
  align-self: center;
  min-height: 168px;
}

.flowScene .flowGridNode {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
}

.flowLine {
  position: absolute;
  z-index: 0;
  pointer-events: none;
  background: color-mix(in srgb, var(--line) 78%, transparent);
  border-radius: 99px;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--line) 85%, transparent);
}

.flowLinePv {
  left: 18%;
  right: 48%;
  top: var(--flow-axis);
  height: 10px;
}

.flowLineGrid {
  left: 54%;
  right: 18%;
  top: var(--flow-axis);
  height: 10px;
}

.flowComet {
  position: absolute;
  z-index: 1;
  left: 18%;
  width: 76px;
  height: 10px;
  pointer-events: none;
  border-radius: 99px;
  opacity: 0.95;
  filter: blur(0.1px) drop-shadow(0 0 12px currentColor);
  transform: translate(-100%, -50%);
  animation-duration: 2.2s;
  animation-fill-mode: both;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  will-change: left, top, transform;
}

.flowCometPv {
  top: calc(var(--flow-axis) + 5px);
  color: var(--success);
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(32, 156, 96, 0.12) 28%,
    rgba(32, 156, 96, 0.28) 62%,
    var(--success) 100%
  );
  animation-name: cometPv;
}

.flowCometGrid {
  left: 82%;
  top: calc(var(--flow-axis) + 5px);
  color: var(--danger);
  background: linear-gradient(
    90deg,
    var(--danger) 0%,
    rgba(216, 59, 59, 0.28) 38%,
    rgba(216, 59, 59, 0.12) 72%,
    transparent 100%
  );
  transform: translate(0, -50%);
  animation-name: cometGrid;
}

.flowCometGrid.is-export {
  left: 52%;
  color: var(--success);
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(32, 156, 96, 0.12) 28%,
    rgba(32, 156, 96, 0.28) 62%,
    var(--success) 100%
  );
  transform: translate(-100%, -50%);
  animation-name: cometGridExport;
}

.flowCometGrid.is-import {
  left: 82%;
  color: var(--danger);
  background: linear-gradient(
    90deg,
    var(--danger) 0%,
    rgba(216, 59, 59, 0.28) 38%,
    rgba(216, 59, 59, 0.12) 72%,
    transparent 100%
  );
  transform: translate(0, -50%);
  animation-name: cometGrid;
}

.flowComet.is-idle {
  display: none;
}

.c1 {
  animation-delay: 0s;
}
.c2 {
  animation-delay: 0.55s;
}
.c3 {
  animation-delay: 1.1s;
}
.c4 {
  animation-delay: 1.65s;
}

@keyframes cometPv {
  from {
    left: 18%;
    transform: translate(-100%, -50%);
  }
  to {
    left: 52%;
    transform: translate(0, -50%);
  }
}

@keyframes cometGrid {
  from {
    left: 82%;
    transform: translate(0, -50%);
  }
  to {
    left: 54%;
    transform: translate(-100%, -50%);
  }
}

@keyframes cometGridExport {
  from {
    left: 52%;
    transform: translate(-100%, -50%);
  }
  to {
    left: 82%;
    transform: translate(0, -50%);
  }
}

@keyframes cometPvMobile {
  from {
    top: var(--flow-mobile-pv-start);
    transform: translate(-50%, -100%);
  }
  to {
    top: var(--flow-mobile-pv-end);
    transform: translate(-50%, 0);
  }
}

@keyframes cometGridMobileImport {
  from {
    top: var(--flow-mobile-grid-end);
    transform: translate(-50%, 0);
  }
  to {
    top: var(--flow-mobile-grid-start);
    transform: translate(-50%, -100%);
  }
}

@keyframes cometGridMobileExport {
  from {
    top: var(--flow-mobile-grid-start);
    transform: translate(-50%, -100%);
  }
  to {
    top: var(--flow-mobile-grid-end);
    transform: translate(-50%, 0);
  }
}

.flowNode {
  position: relative;
  z-index: 1;
  min-height: 190px;
  display: grid;
  place-items: center;
  gap: 9px;
  padding: 22px;
  text-align: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.flowPvNode {
  grid-column: 1;
  grid-row: 1;
  align-self: start;
  justify-self: start;
}

.flowHomeNode {
  grid-column: 3;
  grid-row: 1;
  align-self: start;
  justify-self: end;
}

.flowGridNode {
  grid-column: 3;
  grid-row: 2;
  align-self: end;
  justify-self: end;
}

.produkcja .val,
.livePv .val,
.edAJAX,
.emAJAX,
.ecAJAX,
.prod,
.ieE,
.pew,
.bilans {
  color: var(--success);
}

.liveGrid .val,
.ieI,
.pobImp,
.bilans_ujemny {
  color: var(--danger);
}

.pobor .val {
  color: var(--muted);
}

.flowGridNode.is-export .val {
  color: var(--success);
}

.flowGridNode.is-import .val {
  color: var(--danger);
}

.flowGridNode.is-neutral .val {
  color: var(--muted);
}

.uzycie .val,
.liveUse .val,
.pob,
.pobPV,
.ppw {
  color: var(--info);
}

.flowNodeMain {
  background: #fffaf0;
  border-color: rgba(244, 179, 33, 0.38);
  box-shadow: 0 18px 50px rgba(244, 179, 33, 0.16);
}

.nodeIcon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

body[data-theme="dark"] .nodeIcon {
  background: var(--surface-2);
}

body[data-theme="dark"] .flowNode,
body[data-theme="dark"] .liveProduction,
body[data-theme="dark"] .kpiCard,
body[data-theme="dark"] .cycleCard > div,
body[data-theme="dark"] .chartPanel,
body[data-theme="dark"] .chartDane,
body[data-theme="dark"] .dataTable,
body[data-theme="dark"] .analyticsPanel,
body[data-theme="dark"] .sectionToggle {
  background: var(--surface);
}

.brand .brandLogo {
  width: auto;
  max-width: 100%;
  height: 38px;
  flex: 0 1 auto;
  min-width: 0;
}

.brand .logo-dark {
  display: none;
}

body[data-theme="dark"] .brand .logo-dark {
  display: block;
}

body[data-theme="dark"] .brand .logo-light {
  display: none;
}

@media (min-width: 761px) {
  .brand .brandLogo {
    height: 64px;
  }
}

body[data-theme="dark"] .invdRowTitle .invdColTitle,
body[data-theme="dark"] .invdRowTitle .invdColTitle2 {
  background: rgba(255, 255, 255, 0.04);
}

.produkcja .nodeIcon {
  color: var(--success);
}

.uzycie .nodeIcon {
  color: var(--info);
}

.pobor .nodeIcon {
  color: var(--danger);
}

.inverterNode .nodeIcon {
  color: var(--accent-dark);
}

.nodeGlyph {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  color: var(--accent-dark);
  background: #fff8e8;
  border: 1px solid rgba(244, 179, 33, 0.38);
  border-radius: var(--radius);
  font-size: 0.78rem;
  font-weight: 900;
}

body[data-theme="dark"] .nodeGlyph {
  background: rgba(244, 179, 33, 0.13);
}

.nodeLabel {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
}

.flowNode .val {
  font-size: clamp(1.7rem, 4vw, 2.4rem);
}

.cycleStrip {
  width: 100%;
}

.cycleCard {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  overflow: visible;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.donut {
  --value: 0;
  width: 86px;
  height: 86px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--surface) 0 55%, transparent 56%),
    conic-gradient(var(--accent) calc(var(--value) * 1%), #e9eef5 0);
}

.autoconsumptionDonut {
  background:
    radial-gradient(circle at center, var(--surface) 0 55%, transparent 56%),
    conic-gradient(var(--info) calc(var(--value, 0) * 1%), #e9eef5 0);
}

body[data-theme="dark"] .donut {
  background:
    radial-gradient(circle at center, var(--surface) 0 55%, transparent 56%),
    conic-gradient(var(--accent) calc(var(--value) * 1%), #263241 0);
}

body[data-theme="dark"] .autoconsumptionDonut {
  background:
    radial-gradient(circle at center, var(--surface) 0 55%, transparent 56%),
    conic-gradient(var(--info) calc(var(--value, 0) * 1%), #263241 0);
}

.autoconsumptionCard {
  align-items: center;
  justify-items: center;
  text-align: center;
}

.autoconsumptionCard > span {
  grid-column: 1;
  grid-row: 1;
  align-self: center;
}

.cycleCard > div {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px 14px;
  align-items: center;
  justify-items: center;
  text-align: center;
  min-width: 0;
  padding: 22px 22px 20px;
  background:
    linear-gradient(
      180deg,
      color-mix(in srgb, var(--surface-2) 70%, transparent),
      transparent
    ),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}

.cycleCard > div:not(.balanceCard) .metricValue {
  grid-column: 1 / -1;
  justify-self: center;
  text-align: center;
}

.cycleCard > div:not(.balanceCard) small {
  grid-column: 1 / -1;
  justify-self: center;
  text-align: center;
}

.cycleCard > div:first-child,
.cycleCard > div:nth-child(3) {
  align-items: center;
}

.cycleCard .balanceCard {
  align-items: center;
  grid-template-columns: 1fr;
}

.cycleCard .balanceCard .balanceValue {
  grid-column: 1 / -1;
  justify-self: center;
  text-align: center;
}

.cycleCard span:first-child {
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 800;
}

.cycleCard strong {
  font-size: clamp(2.1rem, 4.5vw, 3.45rem);
  line-height: 1.1;
}

.metricValue {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  width: fit-content;
  font-size: 1rem;
  line-height: 1;
  white-space: nowrap;
}

.metricNumber {
  font-size: clamp(2.8rem, 4.8vw, 4.25rem) !important;
  line-height: 0.95;
  font-weight: 900;
}

.metricUnit {
  font-size: clamp(0.92rem, 1.15vw, 1.05rem) !important;
  line-height: 1;
  font-weight: 800;
  opacity: 0.82;
}

.balanceValue {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  width: fit-content;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid rgba(34, 124, 198, 0.24);
  border-radius: var(--radius);
}

.balanceCard {
  grid-template-columns: 1fr !important;
  grid-template-rows: auto 1fr !important;
  gap: 12px 14px !important;
  align-items: center !important;
  overflow: hidden;
  min-height: 150px;
  border-left: 8px solid var(--line) !important;
  border-width: 2px !important;
}

.balanceCard.is-positive {
  background:
    linear-gradient(
      135deg,
      color-mix(in srgb, var(--success) 22%, var(--surface)) 0%,
      color-mix(in srgb, var(--success) 8%, var(--surface)) 58%,
      var(--surface) 100%
    ),
    var(--surface);
  border-color: color-mix(in srgb, var(--success) 48%, var(--line)) !important;
  border-left-color: var(--success) !important;
}

.balanceCard.is-negative {
  background:
    linear-gradient(
      135deg,
      color-mix(in srgb, var(--danger) 22%, var(--surface)) 0%,
      color-mix(in srgb, var(--danger) 8%, var(--surface)) 58%,
      var(--surface) 100%
    ),
    var(--surface);
  border-color: color-mix(in srgb, var(--danger) 52%, var(--line)) !important;
  border-left-color: var(--danger) !important;
}

body[data-theme="dark"] .balanceCard.is-positive {
  background:
    linear-gradient(
      135deg,
      color-mix(in srgb, var(--success) 24%, var(--surface)) 0%,
      color-mix(in srgb, var(--success) 11%, var(--surface)) 62%,
      var(--surface) 100%
    ),
    var(--surface);
}

body[data-theme="dark"] .balanceCard.is-negative {
  background:
    linear-gradient(
      135deg,
      color-mix(in srgb, var(--danger) 24%, var(--surface)) 0%,
      color-mix(in srgb, var(--danger) 11%, var(--surface)) 62%,
      var(--surface) 100%
    ),
    var(--surface);
}

.balanceCopy {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  text-align: center;
}

.balanceCopy > span {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 0.98rem;
  font-weight: 900;
}

.balanceCard .balanceValue {
  grid-column: 1 / -1;
  grid-row: 2;
  align-self: center;
  justify-self: center;
  gap: 7px;
  padding: 12px 16px;
  background: var(--surface);
  border-width: 2px;
  border-radius: calc(var(--radius) + 2px);
}

.balanceCard.is-positive .balanceValue {
  border-color: color-mix(in srgb, var(--success) 48%, var(--line));
}

.balanceCard.is-positive .balanceValue,
.balanceCard.is-positive .balanceValue .metricNumber,
.balanceCard.is-positive .balanceValue .metricUnit {
  color: var(--success) !important;
}

.balanceCard.is-negative .balanceValue {
  border-color: color-mix(in srgb, var(--danger) 52%, var(--line));
}

.balanceCard.is-negative .balanceValue,
.balanceCard.is-negative .balanceValue .metricNumber,
.balanceCard.is-negative .balanceValue .metricUnit {
  color: var(--danger) !important;
}

.balanceCard .metricNumber {
  font-size: clamp(2.8rem, 4.8vw, 4.25rem) !important;
  letter-spacing: 0;
}

.balanceHint {
  display: block;
  color: var(--muted) !important;
  font-size: 0.82rem !important;
  line-height: 1.25;
}

.balanceValue .unit {
  color: inherit;
}

#max_produkcja_kiedy,
.boldMax {
  display: inline-flex;
  width: fit-content;
  padding: 5px 9px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.cycleCard small {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.autoconsumptionCard .donut {
  grid-column: 1 / -1;
  grid-row: 2;
  width: min(178px, 92%);
  height: auto;
  aspect-ratio: 1;
  justify-self: center;
  align-self: center;
}

.autoconsumptionCard .donut strong {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.08em;
  white-space: nowrap;
  color: var(--text);
}

.autoconsumptionCard .autoconsumptionValue {
  font-size: clamp(2.8rem, 4.8vw, 4.25rem) !important;
  line-height: 0.95;
  font-weight: 900;
}

.autoconsumptionCard .autoconsumptionUnit {
  color: var(--text);
  opacity: 1;
}

.sectionToggle {
  width: 100%;
  min-height: 68px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  text-align: left;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.sectionToggle:hover {
  transform: translateY(-1px);
  border-color: rgba(244, 179, 33, 0.65);
  box-shadow: var(--shadow-2);
}

.sectionToggle small {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.naglowek-drop {
  display: block;
  color: var(--text);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: none;
}

.drop-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  opacity: 0.62;
  transition:
    transform 0.22s ease,
    opacity 0.22s ease;
}

.sectionToggle:hover .drop-icon {
  opacity: 1;
}

.drop-icon3,
.drop-icon4,
.drop-icon5,
.drop-icon6 {
  transform: rotate(-180deg);
}

.rotate,
.rotate-down {
  transform: rotate(0deg);
}

.statystyki,
.dropdown4,
.dropdown5,
.dropdown6 {
  display: none;
}

.show {
  display: block;
  animation: reveal 0.28s ease both;
}

.hide {
  display: none;
}

.analyticsGrid.show,
.technicalSection.show,
.chartSection.show {
  display: grid;
}

.analyticsGrid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.analyticsPanel {
  display: grid;
  align-content: start;
  gap: 16px;
  min-height: 222px;
  padding: 18px;
}

.panelTitle {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.panelTitle span {
  font-weight: 800;
}

.panelTitle small {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.importEksport {
  gap: 16px;
}

.importEksport .panelTitle {
  align-items: baseline;
}

.importEksport .panelTitle span {
  font-size: 1.08rem;
}

.importEksport .panelTitle small {
  font-size: 0.84rem;
}

.wykresW {
  display: flex;
  width: 100%;
  height: 36px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 800;
  isolation: isolate;
}

.importEksport .wykresW {
  height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
}

.importEksport .impeks,
.importEksport .ex1 {
  font-size: 0.88rem;
  font-weight: 900;
}

.ex,
.imp,
.impeks,
.pw {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 100%;
  padding: 0 8px;
  color: #fff;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  transition: width 0.35s ease;
}

.ex {
  background: var(--success);
}

.imp,
.impeks {
  background: var(--danger);
}

.pw {
  background: var(--info);
}

.cycleBarSegment.is-empty {
  display: none;
}

.cycleBarSegment.is-tiny {
  color: transparent;
}

.daneW {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.daneW > div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 12px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.84rem;
  font-weight: 800;
}

.importEksport .daneW {
  gap: 10px;
}

.importEksport .daneW > div {
  min-height: 72px;
  padding: 13px 12px;
  background: var(--surface-2);
  border-color: var(--line);
  border-radius: 7px;
  color: var(--muted);
  font-size: 0.88rem;
}

.importEksport .daneW strong {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  margin-top: 2px;
}

.importEksport .daneW .val {
  font-size: 1rem;
  font-weight: 900;
}

.importEksport .daneW .unit {
  font-size: 1rem;
}

.daneW strong {
  color: var(--text);
}

.zielony {
  color: var(--success);
}

.czerwony {
  color: var(--danger);
}

.niebieski {
  color: var(--info);
}

.pomarancz {
  color: var(--accent-dark);
}

.bold,
.boldMax {
  font-weight: 800;
}

.technicalSection {
  gap: 14px;
}

.dataTable {
  width: 100%;
  padding: 16px;
  overflow-x: auto;
}

.invdRow,
.invdRowTitle {
  display: grid;
  grid-template-columns: repeat(5, minmax(88px, 1fr));
  gap: 8px;
  min-width: 620px;
  margin-bottom: 8px;
  text-align: center;
}

.inverterTable .invdRow,
.inverterTable .invdRowTitle {
  grid-template-columns: repeat(4, minmax(88px, 1fr));
  min-width: 480px;
}

.secondaryMeters {
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  min-width: 360px;
}

.invdCol,
.invdColTitle,
.invdColTitle2,
.invdCol2 {
  display: grid;
  place-items: center;
  min-height: 38px;
  padding: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-weight: 700;
}

.invdRowTitle .invdColTitle,
.invdRowTitle .invdColTitle2 {
  color: var(--muted);
  background: #f2f5f9;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.chartDane {
  width: 100%;
  padding: 16px;
}

.chartMenu {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

#chartDate {
  min-height: 42px;
  padding: 0 12px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-weight: 700;
}

.chartNav {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease;
}

.chartNav:hover {
  box-shadow: var(--shadow-1);
}

.charts {
  display: grid;
  gap: 14px;
}

.chartPanel {
  width: 100%;
  height: 340px;
  min-height: 0;
  padding: 14px;
  overflow: hidden;
}

.chartPanelDay {
  height: 280px;
}

.chartPanel canvas {
  width: 100% !important;
  height: 100% !important;
  max-height: none;
}

.chartActions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.produkcjapv,
.eksportpv,
.importspv,
.zuzyciepv,
.produkcjapvy,
.eksportpvy,
.importspvy,
.zuzyciepvy,
.voltR,
.voltS,
.voltT {
  min-height: 40px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius);
  font-size: 0.84rem;
  font-weight: 800;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease;
}

.produkcjapv:hover,
.eksportpv:hover,
.importspv:hover,
.zuzyciepv:hover,
.produkcjapvy:hover,
.eksportpvy:hover,
.importspvy:hover,
.zuzyciepvy:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-1);
}

.cdebug {
  display: block;
  padding: 14px;
  color: var(--muted);
  white-space: pre-line;
  font-size: 0.82rem;
  line-height: 1.45;
  max-height: 260px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes activeFlow {
  0%,
  100% {
    transform: translateY(-50%) scale(1);
  }
  50% {
    transform: translateY(-50%) scale(1.08);
  }
}

@media (max-width: 980px) {
  .analyticsGrid {
    grid-template-columns: 1fr;
  }

  .flowScene {
    --flow-axis: 50%;
    --flow-mobile-pv-start: 70px;
    --flow-mobile-pv-end: 214px;
    --flow-mobile-grid-start: 260px;
    --flow-mobile-grid-end: 404px;
    grid-template-columns: 1fr;
    grid-template-rows: 76px 106px 78px 106px 76px;
    gap: 0;
    min-height: 462px;
    padding: 12px;
  }

  .flowNode,
  .flowPvNode,
  .flowHomeNode,
  .flowGridNode {
    grid-column: 1;
    justify-self: center;
    align-self: center;
    width: min(360px, 100%);
    min-height: 68px;
    padding: 12px;
  }

  .flowScene .flowNode {
    width: min(360px, 100%);
    min-height: 68px;
    padding: 12px;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    grid-template-rows: auto;
    place-items: center;
    gap: 10px;
    text-align: left;
  }

  .flowScene .nodeIcon {
    grid-column: 1;
    grid-row: 1;
    width: 38px;
    height: 38px;
  }

  .flowScene .nodeLabel {
    grid-column: 2;
    grid-row: 1;
    justify-self: start;
    font-size: 0.82rem;
  }

  .flowScene .flowNode strong {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
    white-space: nowrap;
  }

  .flowScene .flowNode .val {
    font-size: 1.35rem;
  }

  .flowScene .flowNode .unit {
    font-size: 0.78rem;
  }

  .flowScene .flowPvNode,
  .flowScene .flowHomeNode,
  .flowScene .flowGridNode {
    grid-column: 1;
    justify-self: center;
    align-self: center;
  }

  .flowScene .flowPvNode {
    grid-row: 1;
  }

  .flowHomeNode {
    grid-row: 3;
    min-height: 72px;
  }

  .flowScene .flowHomeNode {
    grid-row: 3;
    min-height: 72px;
  }

  .flowGridNode {
    grid-row: 5;
  }

  .flowScene .flowGridNode {
    grid-row: 5;
  }

  .flowLine {
    left: calc(50% - 5px);
    right: auto;
    width: 10px;
    height: 130px;
  }

  .flowLinePv {
    top: var(--flow-mobile-pv-start);
  }

  .flowLineGrid {
    top: var(--flow-mobile-grid-start);
  }

  .flowComet {
    left: 50%;
    width: 10px;
    height: 92px;
    transform: translate(-50%, -100%);
    will-change: top, transform;
  }

  .flowCometPv {
    top: var(--flow-mobile-pv-start);
    background: linear-gradient(
      180deg,
      transparent 0%,
      rgba(32, 156, 96, 0.12) 28%,
      rgba(32, 156, 96, 0.28) 62%,
      var(--success) 100%
    );
    transform: translate(-50%, -100%);
    animation-name: cometPvMobile;
  }

  .flowCometGrid,
  .flowCometGrid.is-import {
    left: 50%;
    top: var(--flow-mobile-grid-end);
    background: linear-gradient(
      180deg,
      var(--danger) 0%,
      rgba(216, 59, 59, 0.28) 38%,
      rgba(216, 59, 59, 0.12) 72%,
      transparent 100%
    );
    transform: translate(-50%, 0);
    animation-name: cometGridMobileImport;
  }

  .flowCometGrid.is-export {
    left: 50%;
    top: var(--flow-mobile-grid-start);
    background: linear-gradient(
      180deg,
      transparent 0%,
      rgba(32, 156, 96, 0.12) 28%,
      rgba(32, 156, 96, 0.28) 62%,
      var(--success) 100%
    );
    transform: translate(-50%, -100%);
    animation-name: cometGridMobileExport;
  }
}

@media (max-width: 760px) {
  .appShell {
    width: min(100% - 18px, 1240px);
    padding-top: 10px;
  }

  .appHeader {
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    min-height: 0;
    padding: 10px;
  }

  .headerContext {
    grid-column: 1 / -1;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 6px;
    min-height: 0;
    order: 3;
    font-size: 0.78rem;
  }

  .systemStatus,
  .installationChip {
    min-height: 32px;
    padding: 0 9px;
  }

  .uptimeStatus {
    display: inline;
  }

  .alertInline {
    display: none;
    min-height: 32px;
    max-width: none;
    padding: 0 9px;
  }

  .headerContext.hasAlert .alertInline {
    display: inline-flex;
    flex: 1 1 auto;
  }

  .installationChip {
    margin-left: auto;
  }

  .summaryBand {
    grid-template-columns: 1fr;
  }

  .cycleCard {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .kpiGrid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .summaryBand {
    padding: 0;
  }

  .kpiCard {
    min-height: 86px;
    padding: 11px 8px 10px;
    gap: 5px;
  }

  .kpiCard legend {
    padding: 0 4px;
    font-size: 0.64rem;
  }

  .kpiLabel {
    font-size: 0.68rem;
    line-height: 1.15;
  }

  .kpiCard .eDane,
  .kpiCard .val {
    font-size: clamp(1rem, 5.5vw, 1.35rem);
  }

  .kpiCard .eDane {
    display: grid;
    justify-items: center;
    text-align: center;
    gap: 1px;
  }

  .kpiCard .unit {
    font-size: 0.54rem;
  }

  .energyFlow,
  .flowNode,
  .analyticsPanel,
  .dataTable,
  .chartPanel {
    padding: 16px;
  }

  .cycleCard > div {
    min-height: 112px;
    padding: 12px 6px;
    gap: 5px;
    grid-template-rows: 22px 26px 1fr;
    align-content: start;
  }

  .cycleCard span:first-child,
  .balanceCopy > span,
  .autoconsumptionCard > span {
    font-size: 0.74rem;
    line-height: 1.15;
  }

  .balanceHint {
    display: none;
  }

  .metricNumber,
  .balanceCard .metricNumber,
  .autoconsumptionCard .autoconsumptionValue {
    font-size: clamp(1rem, 5.5vw, 1.35rem) !important;
  }

  .metricUnit {
    font-size: 0.54rem !important;
  }

  .balanceCard {
    min-height: 112px;
    grid-template-rows: 22px 26px 1fr !important;
    border-left-width: 0 !important;
    border-width: 1px !important;
  }

  .balanceCard .balanceValue {
    width: auto;
    padding: 0;
    background: transparent;
    border: 0;
    display: grid;
    gap: 1px;
    justify-self: center;
    justify-items: center;
    justify-content: center;
    text-align: center;
  }

  .autoconsumptionCard .donut {
    position: absolute;
    top: 34px;
    left: 50%;
    transform: translateX(-50%);
    grid-row: auto;
    width: min(76px, 92%);
  }

  #max_produkcja_kiedy,
  .boldMax {
    padding: 4px 6px;
    font-size: 0.68rem;
    grid-row: 2;
  }

  .cycleCard > div:first-child .metricValue,
  .balanceCard .balanceValue {
    position: absolute;
    top: 58px;
    left: 50%;
    transform: translateX(-50%);
    grid-row: auto !important;
  }

  .balanceCopy {
    grid-row: 1 / span 2;
    align-self: start;
  }

  .autoconsumptionCard > span {
    grid-row: 1 / span 2;
    align-self: start;
  }

  .chartPanel,
  .chartPanelDay {
    height: 300px;
  }

  .chartActions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
  }

  .produkcjapv,
  .eksportpv,
  .importspv,
  .zuzyciepv,
  .produkcjapvy,
  .eksportpvy,
  .importspvy,
  .zuzyciepvy {
    min-height: 32px;
    padding: 0 4px;
    font-size: 0.66rem;
  }
}

@media (max-width: 480px) {
  .sideMenu {
    max-width: 100vw;
  }

  .settingsHeader,
  .settings {
    width: 100%;
  }

  .brandSubtitle,
  .logged {
    display: none;
  }

  .headerContext {
    gap: 6px;
    padding-inline: 0;
  }

  .systemStatus {
    width: auto;
    min-width: 32px;
    padding: 0 9px;
    justify-content: center;
  }

  .installationChip {
    max-width: calc(100vw - 112px);
  }

  .loggedUser {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .flowScene {
    --flow-mobile-pv-start: 62px;
    --flow-mobile-pv-end: 196px;
    --flow-mobile-grid-start: 238px;
    --flow-mobile-grid-end: 372px;
    grid-template-rows: 68px 98px 72px 98px 68px;
  }

  .flowLine {
    height: 118px;
  }

  .flowComet {
    height: 84px;
  }

  .flowNode,
  .flowPvNode,
  .flowHomeNode,
  .flowGridNode {
    min-height: 64px;
  }

  .flowScene .flowNode {
    min-height: 64px;
    grid-template-columns: 36px minmax(0, 1fr) auto;
    gap: 8px;
    padding: 10px;
  }

  .flowScene .flowHomeNode {
    min-height: 68px;
  }

  .flowScene .nodeIcon {
    width: 34px;
    height: 34px;
  }

  .flowScene .nodeLabel {
    font-size: 0.78rem;
  }

  .flowScene .flowNode .val {
    font-size: 1.18rem;
  }

  .flowScene .flowNode .unit {
    font-size: 0.72rem;
  }

  .flowCometPv {
    animation-name: cometPvMobile;
  }

  .flowCometGrid,
  .flowCometGrid.is-import {
    animation-name: cometGridMobileImport;
  }

  .flowCometGrid.is-export {
    animation-name: cometGridMobileExport;
  }

  .kpiCard {
    padding: 10px 6px 9px;
  }

  .energyFlow,
  .flowNode,
  .analyticsPanel,
  .chartDane,
  .dataTable,
  .chartPanel {
    padding: 14px;
  }

  .cycleCard > div {
    padding: 10px 5px;
  }

  .daneW {
    grid-template-columns: 1fr;
  }

  .importEksport .daneW {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .produkcjaW .daneW,
  .poborW .daneW {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #chartDate {
    min-width: 0;
    width: 100%;
  }
}

/* Ambient SVG energy-flow scene */
.energyFlow .teslaFlow {
  min-height: 0;
}

.energyFlow .flowScene {
  --ambient-text: var(--text);
  --ambient-muted: var(--muted);
  --ambient-solar: var(--success);
  --ambient-grid: var(--danger);
  --ambient-export: var(--success);
  --ambient-solar-pill: #19d979;
  --ambient-grid-pill: #ff3d3d;
  --ambient-export-pill: #19d979;
  --ambient-wire: rgba(51, 65, 85, 0.48);
  --ambient-glass: rgba(255, 255, 255, 0.82);
  --ambient-border: rgba(15, 23, 42, 0.08);
  --ambient-shadow: 0 24px 70px rgba(15, 23, 42, 0.14);
  --ambient-scene-shiftX: -10%;
  --ambient-scene-shiftY: 7%;
  position: relative;
  display: block;
  min-height: 450px;
  margin: 0;
  padding: 0;
  isolation: isolate;
  border: 1px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
  background:
    radial-gradient(
      circle at 18% 9%,
      color-mix(in srgb, var(--info) 13%, transparent),
      transparent 30%
    ),
    radial-gradient(
      circle at 76% 8%,
      color-mix(in srgb, var(--success) 10%, transparent),
      transparent 25%
    ),
    linear-gradient(145deg, var(--surface), var(--surface-2) 58%, var(--page));
  box-shadow: var(--shadow-1);
}

body[data-theme="dark"] .energyFlow .flowScene {
  --ambient-text: #edf4ff;
  --ambient-muted: #91a3ba;
  --ambient-wire: rgba(210, 225, 245, 0.18);
  --ambient-glass: rgba(5, 10, 18, 0.72);
  --ambient-border: rgba(255, 255, 255, 0.08);
  --ambient-shadow: 0 16px 44px rgba(0, 0, 0, 0.28);
  --ambient-solar-pill: #36f28b;
  --ambient-grid-pill: #ff5c5c;
  --ambient-export-pill: #36f28b;
  --ambient-scene-shiftX: -10%;
  --ambient-scene-shiftY: 7%;
  background:
    radial-gradient(
      circle at 18% 9%,
      rgba(34, 124, 198, 0.14),
      transparent 30%
    ),
    radial-gradient(circle at 76% 8%, rgba(32, 156, 96, 0.1), transparent 25%),
    linear-gradient(145deg, var(--page), var(--surface-2) 58%, var(--surface));
}

.energyFlow .flowScene::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(15, 23, 42, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.035) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), transparent 78%);
}

body[data-theme="dark"] .energyFlow .flowScene::before {
  background:
    linear-gradient(rgba(255, 255, 255, 0.027) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.027) 1px, transparent 1px);
}

.energyFlow .scene-svg {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  overflow: visible;
  transform: translateX(var(--ambient-scene-shiftX))
    translateY(var(--ambient-scene-shiftY));
  transform-origin: center;
}

.energyFlow .scene-svg #leftWall stop:first-child {
  stop-color: #d9e2ee;
}

.energyFlow .scene-svg #leftWall stop:last-child {
  stop-color: #b8c5d4;
}

.energyFlow .scene-svg #rightWall stop:first-child {
  stop-color: #c8d4e2;
}

.energyFlow .scene-svg #rightWall stop:last-child {
  stop-color: #94a3b8;
}

.energyFlow .scene-svg #roofFront stop:first-child {
  stop-color: #788aa4;
}

.energyFlow .scene-svg #roofFront stop:last-child {
  stop-color: #52657d;
}

.energyFlow .scene-svg #roofBack stop:first-child {
  stop-color: #a4b1c3;
}

.energyFlow .scene-svg #roofBack stop:last-child {
  stop-color: #708198;
}

.energyFlow .scene-svg #panelGrad stop:first-child {
  stop-color: #334155;
}

.energyFlow .scene-svg #panelGrad stop:last-child {
  stop-color: #172033;
}

.energyFlow .scene-svg #treeGrad stop:first-child {
  stop-color: #2f8a58;
}

.energyFlow .scene-svg #treeGrad stop:last-child {
  stop-color: #1d5f3d;
}

.energyFlow .scene-svg > ellipse:first-of-type {
  fill: rgba(15, 23, 42, 0.16);
}

.energyFlow .scene-svg > ellipse:nth-of-type(2),
.energyFlow .scene-svg > ellipse:nth-of-type(3) {
  fill: rgba(15, 23, 42, 0.18);
}

body[data-theme="dark"] .energyFlow .scene-svg #leftWall stop:first-child {
  stop-color: #2c3954;
}

body[data-theme="dark"] .energyFlow .scene-svg #leftWall stop:last-child {
  stop-color: #1a2336;
}

body[data-theme="dark"] .energyFlow .scene-svg #rightWall stop:first-child {
  stop-color: #1e293b;
}

body[data-theme="dark"] .energyFlow .scene-svg #rightWall stop:last-child {
  stop-color: #0f172a;
}

body[data-theme="dark"] .energyFlow .scene-svg #roofFront stop:first-child {
  stop-color: #475878;
}

body[data-theme="dark"] .energyFlow .scene-svg #roofFront stop:last-child {
  stop-color: #2a374e;
}

body[data-theme="dark"] .energyFlow .scene-svg #roofBack stop:first-child {
  stop-color: #243147;
}

body[data-theme="dark"] .energyFlow .scene-svg #roofBack stop:last-child {
  stop-color: #151f30;
}

body[data-theme="dark"] .energyFlow .scene-svg #panelGrad stop:first-child {
  stop-color: #243447;
}

body[data-theme="dark"] .energyFlow .scene-svg #panelGrad stop:last-child {
  stop-color: #121a24;
}

body[data-theme="dark"] .energyFlow .scene-svg #treeGrad stop:first-child {
  stop-color: #2d5a3f;
}

body[data-theme="dark"] .energyFlow .scene-svg #treeGrad stop:last-child {
  stop-color: #143020;
}

body[data-theme="dark"] .energyFlow .scene-svg > ellipse:first-of-type {
  fill: rgba(0, 0, 0, 0.24);
}

body[data-theme="dark"] .energyFlow .scene-svg > ellipse:nth-of-type(2),
body[data-theme="dark"] .energyFlow .scene-svg > ellipse:nth-of-type(3) {
  fill: rgba(0, 0, 0, 0.3);
}

.energyFlow .flowScene .node {
  position: absolute;
  z-index: 8;
  display: block;
  width: 140px;
  min-height: 0;
  padding: 14px 15px;
  text-align: left;
  border: 1px solid var(--ambient-border);
  border-radius: 18px;
  background: var(--ambient-glass);
  box-shadow: var(--ambient-shadow);
  backdrop-filter: blur(12px);
}

.energyFlow .flowScene .solar-node {
  top: 54px;
  left: 72%;
  right: auto;
  transform: translateX(-50%);
}

.energyFlow .flowScene .grid-node {
  top: 54px;
  left: 28%;
  right: auto;
  transform: translateX(-50%);
}

.energyFlow .flowScene .home-node {
  top: 54px;
  left: 50%;
  right: auto;
  transform: translateX(-50%);
}

.energyFlow .flowScene .nodeLabel {
  margin-bottom: 5px;
  color: var(--ambient-muted);
  font-size: 12px;
  font-weight: 650;
}

.energyFlow .flowScene .value,
.energyFlow .flowScene .flowNode .val {
  color: var(--ambient-text);
  font-size: 24px;
  font-weight: 850;
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.energyFlow .flowScene .value small,
.energyFlow .flowScene .unit {
  color: var(--ambient-muted);
  font-size: 12px;
  font-weight: 650;
}

.energyFlow .flowScene .flowPvNode .val {
  color: var(--ambient-solar);
}

.energyFlow .flowScene .flowGridNode.is-export .val {
  color: var(--ambient-export);
}

.energyFlow .flowScene .flowGridNode.is-import .val {
  color: var(--ambient-grid);
}

.energyFlow .flowScene .flowGridNode.is-neutral .val {
  color: var(--ambient-muted);
}

.energyFlow .flowScene .flowHomeNode .val {
  color: var(--info);
}

.energyFlow .wire-base {
  fill: none;
  stroke: var(--ambient-wire);
  stroke-width: 5.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 1.2px rgba(15, 23, 42, 0.34));
  transition:
    stroke 0.28s ease,
    opacity 0.28s ease;
}

body[data-theme="dark"] .energyFlow .wire-base {
  filter: drop-shadow(0 0 1.2px rgba(255, 255, 255, 0.12));
}

.energyFlow .win-light {
  opacity: 0;
  transition: opacity 0.35s ease;
}

.energyFlow .win-light.is-lit {
  opacity: 1;
}

.energyFlow .win-light.on {
  opacity: 1;
}

.energyFlow .flowScene.has-solar-flow #wireSolarBase {
  stroke: color-mix(in srgb, var(--ambient-solar) 60%, transparent);
}

.energyFlow .flowScene.has-grid-import-flow #wireGridBase {
  stroke: color-mix(in srgb, var(--ambient-grid) 60%, transparent);
}

.energyFlow .flowScene.has-grid-export-flow #wireGridBase {
  stroke: color-mix(in srgb, var(--ambient-export) 60%, transparent);
}

.energyFlow .flow {
  fill: none;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 8 22;
  opacity: 0;
  filter: none;
  animation: sceneFlow 1.15s linear infinite;
  transition: opacity 0.3s ease;
}

.energyFlow .flow.is-active {
  opacity: 1;
  -webkit-filter: drop-shadow(0 0 1px rgba(15, 23, 42, 0.42))
    drop-shadow(0 0 7px currentColor);
  filter: drop-shadow(0 0 1px rgba(15, 23, 42, 0.42))
    drop-shadow(0 0 7px currentColor);
}

.energyFlow .flow-solar {
  color: var(--ambient-solar-pill);
  stroke: var(--ambient-solar-pill);
}

.energyFlow .flow-grid {
  color: var(--ambient-grid-pill);
  stroke: var(--ambient-grid-pill);
}

.energyFlow .flow-export {
  color: var(--ambient-export-pill);
  stroke: var(--ambient-export-pill);
}

.energyFlow .reverse {
  animation-direction: reverse;
}

@keyframes sceneFlow {
  to {
    stroke-dashoffset: -60;
  }
}

@media (max-width: 760px) {
  .energyFlow .flowScene {
    height: 285px;
    min-height: 285px;
  }

  .energyFlow .scene-svg {
    transform: translateX(calc(var(--ambient-scene-shiftX) - 2%))
      translateY(calc(var(--ambient-scene-shiftY) + 4%)) scale(1.08);
  }

  .energyFlow .flowScene .node {
    width: 96px;
    height: 72px;
    padding: 9px 10px;
    overflow: hidden;
    text-align: center;
  }

  .energyFlow .flowScene .value {
    display: grid;
    justify-items: center;
    gap: 1px;
  }

  .energyFlow .flowScene .value,
  .energyFlow .flowScene .flowNode .val {
    font-size: clamp(1rem, 5.5vw, 1.35rem);
    letter-spacing: 0;
  }

  .energyFlow .flowScene .nodeLabel,
  .energyFlow .flowScene .unit {
    font-size: 0.54rem;
  }

  .metricValue,
  .autoconsumptionCard .donut strong {
    display: grid;
    justify-items: center;
    text-align: center;
    gap: 1px;
  }

  .energyFlow .flowScene .flowGridNode.is-export .nodeLabel,
  .energyFlow .flowScene .flowHomeNode .nodeLabel {
    font-size: 0;
  }

  .energyFlow .flowScene .flowGridNode.is-export .nodeLabel::after,
  .energyFlow .flowScene .flowHomeNode .nodeLabel::after {
    font-size: 0.54rem;
  }

  .energyFlow .flowScene .flowGridNode.is-export .nodeLabel::after {
    content: "Export";
  }

  .energyFlow .flowScene .flowHomeNode .nodeLabel::after {
    content: "Zużycie";
  }

  .balanceCard,
  .balanceCopy,
  .balanceCard .balanceValue {
    justify-items: center;
    text-align: center;
  }

  .energyFlow .flow.is-active {
    -webkit-filter: drop-shadow(0 0 1.5px rgba(15, 23, 42, 0.48))
      drop-shadow(0 0 11px currentColor);
    filter: drop-shadow(0 0 1.5px rgba(15, 23, 42, 0.48))
      drop-shadow(0 0 11px currentColor);
  }

  .energyFlow .flowScene .solar-node {
    top: 14px;
    left: 82%;
    right: auto;
    transform: translateX(-50%);
  }

  .energyFlow .flowScene .grid-node {
    top: 14px;
    left: 18%;
    right: auto;
    transform: translateX(-50%);
  }

  .energyFlow .flowScene .home-node {
    top: 14px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
  }

  /* Widok pionowy: plakietka SVG pod pompą jest ukryta (zastępuje ją dedykowany kafelek HTML) */
  #heatPumpBadge {
    display: none !important;
  }

  /* Dedykowane pole mocy pompy w widoku pionowym – wielkości kafelków Export, Zużycie i Produkcja */
  .energyFlow .flowScene .flowHpNode {
    display: block;
    top: 200px;
    left: 82%;
    right: auto;
    transform: translateX(-50%);
    cursor: pointer;
    text-decoration: none;
  }

  .energyFlow .flowScene .flowHpNode.is-off {
    display: none !important;
  }

  .energyFlow .flowScene .flowHpNode.is-running .val {
    color: #22c55e;
  }

  .energyFlow .flowScene .flowHpNode.is-running {
    border-color: rgba(34, 197, 94, 0.45);
    box-shadow: 0 0 14px rgba(34, 197, 94, 0.22);
  }

  .energyFlow .flowScene .flowHpNode.is-turbo .val {
    color: #f97316;
  }

  .energyFlow .flowScene .flowHpNode.is-turbo {
    border-color: rgba(249, 115, 22, 0.55);
    box-shadow: 0 0 16px rgba(249, 115, 22, 0.32);
  }
}


/* =========================================================
 * POMPA CIEPĹA NA ĹšCIANIE DOMU
 * ========================================================= */

/* Plakietka SVG pod pompą ukryta na obu widokach (zastępuje ją duży kafel) */
#heatPumpBadge {
  display: none !important;
}

/* Duży kafel mocy pompy ciepła na widoku desktopowym (pod pompą ciepła na ścianie) */
@media (min-width: 761px) {
.energyFlow .flowScene .flowHpNode {
  position: absolute;
  z-index: 8;
  display: block;
  bottom: 24px;
  top: auto;
  left: 72%;
  right: auto;
  transform: translateX(-50%);
  cursor: pointer;
  text-decoration: none;
}
}

/* Zasada do wszystkich widoków: jak pompa wyłączona, widok mocy jest ukryty */
.flowHpNode.is-off {
  display: none !important;
}

.energyFlow .flowScene .flowHpNode.is-running .val {
  color: #dcb36c;
}

.energyFlow .flowScene .flowHpNode.is-running {
  border-color: rgba(220, 179, 108, 0.55);
  box-shadow: 0 0 16px rgba(220, 179, 108, 0.28);
}

.energyFlow .flowScene .flowHpNode.is-error .val {
  color: #ef4444;
}

.energyFlow .flowScene .flowHpNode.is-error {
  border-color: rgba(239, 68, 68, 0.55);
  box-shadow: 0 0 18px rgba(239, 68, 68, 0.32);
}

.energyFlow .flowScene .flowHpNode.is-turbo .val {
  color: #f97316;
}

.energyFlow .flowScene .flowHpNode.is-turbo {
  border-color: rgba(249, 115, 22, 0.55);
  box-shadow: 0 0 18px rgba(249, 115, 22, 0.32);
}

.heatPumpLink {
  cursor: pointer;
  outline: none;
  text-decoration: none;
}

.heatPumpLink:focus,
.heatPumpLink:hover {
  outline: none;
}

#heatPump {
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), filter 0.25s ease;
}

.heatPumpLink:hover #heatPump {
  -webkit-filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
  opacity: 0.96;
}

/* Elementy bazowe pompy */
#heatPump .hp-body-left,
#heatPump .hp-body-front,
#heatPump .hp-body-top,
#heatPump .hp-fan-bg,
#heatPump .hp-fan-ring,
#heatPump .hp-fan-rotator path,
#heatPump .hp-fan-rotator circle,
#heatPump .hp-badge-bg,
#heatPump .hp-badge-text {
  transition: fill 0.35s ease, stroke 0.35s ease, filter 0.35s ease, opacity 0.35s ease;
}

#heatPump .hp-fan-rotator {
  transform-origin: 0 0;
}

/* Plakietka z mocÄ… pod pompÄ… */
#heatPump .hp-badge-bg {
  fill: rgba(15, 23, 42, 0.88);
  stroke: rgba(148, 163, 184, 0.35);
  stroke-width: 0.8px;
}

#heatPump .hp-badge-text {
  fill: #94a3b8;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.3px;
  pointer-events: none;
  user-select: none;
}

/* 1. STAN: WYĹÄ„CZONA / IDLE (SZARY) */
#heatPump.is-off .hp-body-left {
  fill: #475569;
}
#heatPump.is-off .hp-body-front {
  fill: #334155;
}
#heatPump.is-off .hp-body-top {
  fill: #64748b;
}
#heatPump.is-off .hp-fan-bg {
  fill: #0f172a;
}
#heatPump.is-off .hp-fan-ring {
  stroke: rgba(148, 163, 184, 0.35);
}
#heatPump.is-off .hp-fan-rotator path {
  stroke: rgba(148, 163, 184, 0.5);
}
#heatPump.is-off .hp-fan-rotator circle {
  fill: #64748b;
}
#heatPump.is-off .hp-badge-bg {
  fill: rgba(15, 23, 42, 0.90);
  stroke: rgba(148, 163, 184, 0.28);
}
#heatPump.is-off .hp-badge-text {
  fill: #94a3b8;
}

/* 2. STAN: PRACA / WORKING (PIASKOWY - ZGODNY Z POMPA32) */
#heatPump.is-running .hp-body-left {
  fill: #a8803e;
}
#heatPump.is-running .hp-body-front {
  fill: #916e32;
}
#heatPump.is-running .hp-body-top {
  fill: #dcb36c;
}
#heatPump.is-running .hp-fan-bg {
  fill: #241a0d;
}
#heatPump.is-running .hp-fan-ring {
  stroke: #e6c587;
}
#heatPump.is-running .hp-fan-rotator path {
  stroke: #f2dab0;
}
#heatPump.is-running .hp-fan-rotator circle {
  fill: #e6c587;
}
#heatPump.is-running .hp-fan-rotator {
  animation: hpFanSpin 1.3s linear infinite;
}
#heatPump.is-running .hp-badge-bg {
  fill: rgba(50, 36, 16, 0.92);
  stroke: #dcb36c;
  stroke-width: 1px;
  filter: drop-shadow(0 0 3px rgba(220, 179, 108, 0.45));
}
#heatPump.is-running .hp-badge-text {
  fill: #f2dab0;
}

/* 4. STAN: BŁĄD (CZERWONY - ZGODNY Z POMPA32) */
#heatPump.is-error .hp-body-left {
  fill: #b91c1c;
}
#heatPump.is-error .hp-body-front {
  fill: #991b1b;
}
#heatPump.is-error .hp-body-top {
  fill: #ef4444;
}
#heatPump.is-error .hp-fan-bg {
  fill: #450a0a;
}
#heatPump.is-error .hp-fan-ring {
  stroke: #f87171;
}
#heatPump.is-error .hp-fan-rotator path {
  stroke: #fca5a5;
}
#heatPump.is-error .hp-fan-rotator circle {
  fill: #f87171;
}
#heatPump.is-error .hp-badge-bg {
  fill: rgba(127, 29, 29, 0.95);
  stroke: #ef4444;
  stroke-width: 1.2px;
  filter: drop-shadow(0 0 4px rgba(239, 68, 68, 0.6));
}
#heatPump.is-error .hp-badge-text {
  fill: #fca5a5;
}

/* 3. STAN: TURBO (POMARAĹCZOWY) */
#heatPump.is-turbo .hp-body-left {
  fill: #ea580c;
}
#heatPump.is-turbo .hp-body-front {
  fill: #c2410c;
}
#heatPump.is-turbo .hp-body-top {
  fill: #f97316;
}
#heatPump.is-turbo .hp-fan-bg {
  fill: #431407;
}
#heatPump.is-turbo .hp-fan-ring {
  stroke: #fb923c;
}
#heatPump.is-turbo .hp-fan-rotator path {
  stroke: #fed7aa;
}
#heatPump.is-turbo .hp-fan-rotator circle {
  fill: #fb923c;
}
#heatPump.is-turbo .hp-fan-rotator {
  animation: hpFanSpin 0.55s linear infinite;
}
#heatPump.is-turbo .hp-badge-bg {
  fill: rgba(124, 45, 18, 0.95);
  stroke: #f97316;
  stroke-width: 1.2px;
  filter: drop-shadow(0 0 4px rgba(249, 115, 22, 0.6));
}
#heatPump.is-turbo .hp-badge-text {
  fill: #fed7aa;
}

@keyframes hpFanSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
