:root {
  --green: #59ad7d;
  --green2: #4fc28d;
  --blue: #69b6de;
  --pink: #e97f9d;
  --orange: #ef9d65;
  --bg: #eef5f6;
  --text: #48515a;
  --muted: #9aa8b5;
  --flow: #ffe073;
  --flow-strong: #ffcc33;
  --flow-eps: var(--blue);
  --card: #ffffff;
  --border: #e5eef1;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.topbar {
  height: 82px;
  background: var(--green);
  display: grid;
  grid-template-columns: 260px 1fr 220px;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.logo-circle {
  width: 42px;
  height: 42px;
  background: #ffffff22;
  border: 2px solid #ffffff99;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.brand-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: .5px;
}

.brand-subtitle {
  font-size: 10px;
  opacity: .85;
}

.nav {
  height: 100%;
  display: flex;
  justify-content: center;
  gap: 12px;
}

.nav-item {
  border: 0;
  background: transparent;
  color: #fff;
  min-width: 110px;
  padding: 12px 16px;
  font-size: 15px;
  cursor: pointer;
  border-radius: 6px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.nav-item.active {
  background: rgba(255, 255, 255, .18);
}

.nav-item:focus-visible {
  outline: 2px solid rgba(255, 255, 255, .72);
  outline-offset: 2px;
}

@media (hover: hover) and (pointer: fine) {
  .nav-item:hover {
    background: rgba(255, 255, 255, .18);
  }
}

.right-status {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 18px;
  padding: 7px 12px;
  background: rgba(255, 255, 255, .18);
  font-size: 13px;
  white-space: nowrap;
}

.status-ok {
  background: #0ca969;
}

.status-error {
  background: #d9534f;
}

.status-wait {
  background: rgba(255, 255, 255, .18);
}

.refresh-info {
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #0ca969;
  border-color: rgba(255, 255, 255, .24);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 9px;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  opacity: .52;
  transition: opacity .15s ease, background .15s ease;
}

.refresh-icon {
  display: block;
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.refresh-info:hover,
.refresh-info:focus-visible {
  background: #0b8f5a;
  opacity: .9;
}

.refresh-info:disabled {
  cursor: wait;
  opacity: .32;
}

.page {
  padding: 10px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.card {
  background: var(--card);
  min-height: 165px;
  box-shadow: 0 1px 2px #0000000d;
}

.card-header {
  color: #fff;
  padding: 10px 12px;
  font-weight: 700;
  border-radius: 5px 5px 0 0;
}

.solar .card-header {
  background: var(--blue);
}

.battery-card .card-header {
  background: var(--pink);
}

.feed .card-header {
  background: var(--orange);
}

.consumption-card .card-header {
  background: var(--green2);
}

.card-body {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 22px 24px;
}

.icon {
  font-size: 54px;
  width: 80px;
  height: 80px;
  flex: 0 0 80px;
  display: grid;
  place-items: center;
  text-align: center;
}

.card-icon-img {
  display: block;
  flex: 0 0 auto;
  width: 70px;
  height: 70px;
  object-fit: contain;
}

.grid-card-icon-img {
  width: 68px;
  height: 68px;
}

.house-card-icon-img {
  width: 70px;
  height: 70px;
}

.battery-ui {
  --battery-level: 0%;
  --battery-width: 52px;
  --battery-height: 76px;
  --battery-border: 4px;
  --battery-radius: 6px;
  --battery-stroke: #3f464d;
  --battery-cap-width: 24px;
  --battery-cap-height: 9px;
  --battery-body-top: 8px;
  position: relative;
  width: var(--battery-width);
  height: var(--battery-height);
  margin: 0 auto;
}

.battery-ui-card {
  --battery-width: 44px;
  --battery-height: 64px;
  --battery-cap-width: 16px;
  --battery-cap-height: 7px;
  --battery-body-top: 7px;
}

.battery-ui-cap {
  position: absolute;
  top: 0;
  left: 50%;
  width: var(--battery-cap-width);
  height: var(--battery-cap-height);
  transform: translateX(-50%);
  background: #f8fafc;
  border: var(--battery-border) solid var(--battery-stroke);
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
}

.battery-ui-body {
  position: absolute;
  inset: var(--battery-body-top) 0 0;
  overflow: hidden;
  background: #f8fafc;
  border: var(--battery-border) solid var(--battery-stroke);
  border-radius: var(--battery-radius);
}

.battery-ui-fill {
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 2px;
  height: var(--battery-level);
  min-height: 2px;
  background: linear-gradient(90deg, #00c853 0 72%, #35e66f 72% 100%);
  border-radius: 2px;
  transition: height .35s ease;
}

.metric-list {
  margin-left: auto;
  text-align: right;
}

.metric-list div {
  margin-bottom: 14px;
}

.metric-list strong {
  display: block;
  font-size: 26px;
  line-height: 1.1;
}

.metric-list span {
  color: var(--muted);
  font-size: 15px;
}

.system {
  background: #fff;
  min-height: calc(100vh - 280px);
  padding: 18px 22px 28px;
  overflow: hidden;
}

.system-head {
  display: flex;
  align-items: center;
  gap: 30px;
  margin-bottom: 8px;
}

.system-head h2 {
  margin: 0;
  font-size: 21px;
}

#lastUpdate {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

#lastUpdate.last-update-error {
  color: #d9534f;
}

#lastUpdate.last-update-web {
  color: rgba(47, 128, 100, 0.72);
}

#lastUpdate.last-update-web.last-update-error {
  color: #d9534f;
}

.diagram-wrap {
  --diagram-scale: 1;
  --diagram-width: 900px;
  --diagram-height: 590px;
  position: relative;
  width: var(--diagram-width);
  max-width: 100%;
  height: var(--diagram-height);
  margin: 0 auto;
  overflow: hidden;
}

.diagram-canvas {
  position: relative;
  width: 900px;
  height: 540px;
  transform: scale(var(--diagram-scale));
  transform-origin: top left;
}

.node {
  position: absolute;
  z-index: 2;
}

.node-icon {
  font-size: 62px;
  color: var(--green);
}

.pv-icon {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
}

.pv-icon-img {
  display: block;
  width: 72px;
  height: 72px;
  object-fit: contain;
}

.grid-icon {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
}

.grid-icon-img {
  display: block;
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.load-icon {
  width: 70px;
  height: 70px;
  display: grid;
  place-items: center;
  margin: 0 auto;
}

.load-icon-img {
  display: block;
  width: 70px;
  height: 70px;
  object-fit: contain;
}

.node strong {
  font-size: 26px;
  display: inline-block;
  min-width: 72px;
}

.node span {
  display: block;
  color: var(--muted);
  font-size: 15px;
  margin-top: 4px;
}

.pv-node {
  top: 18px;
  left: 300px;
  display: flex;
  gap: 16px;
  align-items: center;
  font-size: 20px;
}

.pv-readings {
  line-height: 1.15;
}

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

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

.pv-small strong {
  min-width: 0;
  margin-right: 3px;
  font-size: inherit;
  font-weight: inherit;
  color: var(--muted);
}

.pv-small span {
  display: inline;
  margin: 0;
  font-size: inherit;
  color: var(--muted);
}

.pv-total {
  margin-top: 6px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.pv-total strong {
  min-width: 78px;
  font-size: 25px;
  font-weight: 800;
  color: var(--text);
}

.battery {
  top: 200px;
  left: 40px;
  text-align: center;
}

.battery-icon {
  width: 64px;
  height: 84px;
  display: grid;
  place-items: center;
}

.battery-readings {
  margin-top: 4px;
}

.inverter {
  top: 205px;
  left: 365px;
  text-align: center;
}

.inverter-box {
  width: 108px;
  height: 108px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  box-shadow: 0 0 35px #9ad9b5;
  display: grid;
  place-items: center;
}

.inverter-icon {
  display: block;
  width: auto;
  height: 108px;
  max-width: 108px;
  object-fit: contain;
}

.mode {
  display: none;
}

.grid {
  top: 220px;
  right: 100px;
  text-align: center;
}

.grid-readings {
  margin-top: 4px;
}

/* Chỉnh chỗ số 2: ngôi nhà nằm giữa, ngay dưới mũi tên đi xuống */
.load {
  top: 415px;
  left: 332px;
  width: 170px;
  text-align: center;
}

.load-readings {
  margin-top: 4px;
}

.flow {
  position: absolute;
  z-index: 1;
  display: none;
  overflow: hidden;
  pointer-events: none;
}

.flow.active {
  display: block;
}

/* Chỉnh chỗ số 1: bỏ nền/thanh vàng phía sau, chỉ giữ mũi tên chạy */
.flow::before {
  display: none;
}

.flow span {
  position: absolute;
  top: 8px;
  width: 18px;
  height: 18px;
  border-top: 5px solid var(--flow);
  border-right: 5px solid var(--flow);
  transform: rotate(45deg);
  filter: drop-shadow(0 0 2px #ffffff);
  opacity: .92;
  animation: arrowMoveX 1.2s linear infinite;
}

.flow.eps span {
  border-top-color: var(--flow-eps);
  border-right-color: var(--flow-eps);
}

.flow.reverse span {
  transform: rotate(225deg);
  animation-name: arrowMoveXReverse;
}

.flow.vertical span {
  left: 8px;
  transform: rotate(135deg);
  animation-name: arrowMoveY;
}

.flow.vertical-up span {
  left: 8px;
  transform: rotate(-45deg);
  animation-name: arrowMoveYReverse;
}

.flow span:nth-child(1) { animation-delay: 0s; }
.flow span:nth-child(2) { animation-delay: -.2s; }
.flow span:nth-child(3) { animation-delay: -.4s; }
.flow span:nth-child(4) { animation-delay: -.6s; }
.flow span:nth-child(5) { animation-delay: -.8s; }
.flow span:nth-child(6) { animation-delay: -1s; }

.flow-battery-to-inverter {
  top: 255px;
  left: 135px;
  width: 230px;
  height: 35px;
}

.flow-pv-to-inverter {
  top: 90px;
  left: 402px;
  width: 35px;
  height: 110px;
}

.flow-grid-to-inverter {
  top: 260px;
  left: 475px;
  width: 245px;
  height: 35px;
}

.flow-inverter-to-grid {
  top: 305px;
  left: 460px;
  width: 385px;
  height: 35px;
}

/* Trục mũi tên đi xuống đặt đúng giữa inverter và ngôi nhà */
.flow-inverter-to-load {
  top: 313px;
  left: 402px;
  width: 35px;
  height: 97px;
}

.raw {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.raw pre {
  max-height: 320px;
  overflow: auto;
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px;
  border-radius: 8px;
  font-size: 13px;
}

.data-page,
.config-page {
  background: #fff;
  min-height: calc(100vh - 112px);
  padding: 14px;
}

.data-toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.data-field {
  display: grid;
  gap: 5px;
}

.data-field span {
  color: var(--muted);
  font-size: 12px;
}

.data-field select,
.data-field input {
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  background: #fff;
  padding: 0 10px;
  font-size: 15px;
}

.month-picker {
  display: grid;
  grid-template-columns: 42px 150px 42px;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: visible;
}

.month-combo {
  position: relative;
  min-width: 0;
  background: #fff;
}

.month-display {
  width: 100%;
  height: 38px;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 10px;
  font-size: 15px;
  cursor: pointer;
}

.calendar-mark {
  width: 14px;
  height: 14px;
  border: 2px solid #111;
  border-radius: 2px;
  position: relative;
  flex: 0 0 auto;
}

.calendar-mark::before {
  content: "";
  position: absolute;
  left: -2px;
  right: -2px;
  top: 2px;
  border-top: 2px solid #111;
}

.month-popover {
  position: absolute;
  top: calc(100% + 7px);
  left: 50%;
  z-index: 20;
  width: 290px;
  transform: translateX(-50%);
  border: 1px solid #b9c0c7;
  background: #fff;
  box-shadow: 0 8px 22px #00000014;
  padding: 14px;
}

.year-stepper {
  height: 34px;
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
  border: 1px solid var(--border);
  background: #f1f1f1;
  margin-bottom: 10px;
}

.year-stepper span {
  text-align: center;
  color: var(--text);
  font-size: 15px;
}

.year-nav {
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--green);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.year-nav:hover {
  background: #e7f3ed;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px 10px;
}

.month-choice {
  height: 34px;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: #222;
  font-size: 14px;
  cursor: pointer;
}

.month-choice:hover {
  background: #eef5ff;
}

.month-choice.active {
  background: #4f6df1;
  color: #fff;
  outline: 2px solid #ffb000;
}


.month-nav {
  border: 0;
  background: var(--green);
  color: #fff;
  font-size: 28px;
  cursor: pointer;
}

.chart-panel {
  position: relative;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.chart-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.chart-head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 500;
  color: var(--text);
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-toggle {
  cursor: pointer;
  user-select: none;
}

.legend-toggle.is-hidden {
  opacity: .38;
}

.chart-legend i {
  width: 12px;
  height: 12px;
  display: inline-block;
  border-radius: 2px;
}

.legend-inverter {
  background: #58b236;
}

.legend-evn {
  background: #5b8def;
}

.legend-kwh {
  background: #5b8def;
}

.legend-money {
  background: #f4a340;
}

.legend-savings {
  background: #14b8a6;
}

.monthly-chart-panel {
  margin-top: 26px;
}

.monthly-chart-head {
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.monthly-legend {
  justify-content: center;
  margin: -2px 0 6px;
}

.range-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
}

.range-option {
  height: 34px;
  border: 0;
  border-right: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 0 12px;
  font-size: 13px;
  cursor: pointer;
}

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

.range-option.active,
.range-option:hover {
  background: var(--green);
  color: #fff;
}

.chart-wrap {
  width: 100%;
  overflow-x: auto;
}

.chart-canvas {
  position: relative;
  width: 100%;
  min-width: 900px;
  height: 430px;
}

.bar-chart {
  width: 100% !important;
  min-width: 0;
  height: 100% !important;
  display: block;
}

.monthly-chart-canvas {
  min-width: 760px;
  height: 390px;
}

.chart-empty {
  display: none;
  color: var(--muted);
  text-align: center;
  padding: 24px 0;
}

.savings-panel {
  margin-top: 24px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.savings-head {
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
}

.savings-head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 500;
  color: var(--text);
}

.page-size-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.page-size-control select {
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  padding: 0 8px;
}

.savings-table-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.savings-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  background: #fff;
}

.savings-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: auto;
}

.savings-table th,
.savings-table td {
  border-bottom: 1px solid #e5e7eb;
  padding: 10px clamp(8px, 1.4vw, 14px);
  text-align: right;
  white-space: nowrap;
}

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

.savings-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
}

.savings-table tfoot td {
  border-bottom: 0;
  background: #eef7f3;
  color: var(--text);
  font-weight: 800;
}

.savings-table tfoot .savings-total-highlight {
  color: #0f766e;
  font-size: 16px;
  font-weight: 900;
}

.savings-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.page-nav {
  width: 34px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.page-nav:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.empty-page {
  color: var(--muted);
  padding: 18px;
}

@keyframes arrowMoveX {
  from { left: -25px; }
  to { left: calc(100% + 25px); }
}

@keyframes arrowMoveXReverse {
  from { left: calc(100% + 25px); }
  to { left: -25px; }
}

@keyframes arrowMoveY {
  from { top: -25px; }
  to { top: calc(100% + 25px); }
}

@keyframes arrowMoveYReverse {
  from { top: calc(100% + 25px); }
  to { top: -25px; }
}

@media (max-width: 1100px) {
  .topbar {
    grid-template-columns: 1fr auto;
    height: auto;
    gap: 8px 12px;
    padding: 8px 12px;
  }

  .nav {
    order: 3;
    grid-column: 1 / -1;
    height: auto;
    overflow-x: visible;
    justify-content: stretch;
    gap: 8px;
  }

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

  .nav-item {
    min-width: 0;
  }

  .cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .diagram-wrap {
    --diagram-scale: .86;
    --diagram-width: 774px;
    --diagram-height: 510px;
  }
}

@media (max-width: 720px) {
  .topbar {
    padding: 6px 10px;
    gap: 6px 10px;
  }

  .brand {
    gap: 8px;
  }

  .logo-circle {
    width: 34px;
    height: 34px;
    font-size: 13px;
  }

  .brand-title {
    font-size: 20px;
  }

  .brand-subtitle {
    font-size: 11px;
  }

  .pill {
    padding: 5px 9px;
    font-size: 12px;
  }

  .refresh-info {
    height: 28px;
    padding: 0 7px;
    gap: 4px;
    font-size: 11px;
  }

  .refresh-icon {
    width: 13px;
    height: 13px;
    flex-basis: 13px;
  }

  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 0;
  }

  .nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow-x: visible;
    gap: 6px;
    height: auto;
    padding-bottom: 0;
  }

  .nav-item {
    min-width: 0;
    padding: 8px 6px;
    font-size: 12px;
  }

  .card {
    min-height: auto;
  }

  .card-header {
    padding: 8px 9px;
    font-size: 13px;
  }

  .card-body {
    flex-direction: row;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 16px;
  }

  .icon {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
  }

  .card-icon-img,
  .grid-card-icon-img,
  .house-card-icon-img {
    width: 34px;
    height: 34px;
  }

  .battery-ui-card {
    --battery-width: 26px;
    --battery-height: 38px;
    --battery-border: 2px;
    --battery-cap-width: 14px;
    --battery-cap-height: 5px;
    --battery-body-top: 5px;
    --battery-radius: 4px;
  }

  .metric-list {
    min-width: 0;
    margin-left: auto;
    text-align: right;
  }

  .metric-list div {
    margin-bottom: 6px;
  }

  .metric-list strong {
    font-size: 18px;
  }

  .metric-list span {
    font-size: 12px;
  }

  .system {
    padding: 14px 8px;
  }

  .system-head {
    flex-wrap: wrap;
    gap: 8px 16px;
  }

  .diagram-wrap {
    --diagram-scale: 1;
    --diagram-width: 100%;
    --diagram-height: 465px;
  }

  .diagram-canvas {
    width: 100%;
    height: 465px;
    transform: none;
  }

  .node-icon {
    font-size: 50px;
  }

  .node strong {
    min-width: 58px;
    font-size: 20px;
  }

  .node span {
    font-size: 13px;
  }

  .pv-node {
    top: 8px;
    left: 50%;
    gap: 10px;
    transform: translateX(-50%);
  }

  .pv-small strong {
    min-width: 0;
    font-size: inherit;
  }

  .pv-small span {
    font-size: inherit;
  }

  .pv-total {
    font-size: 18px;
  }

  .pv-total strong {
    min-width: 64px;
    font-size: 23px;
  }

  .battery {
    top: 170px;
    left: 0;
  }

  .battery-icon {
    width: 58px;
    height: 76px;
  }

  .battery-icon .battery-ui {
    --battery-width: 46px;
    --battery-height: 68px;
  }

  .inverter {
    top: 158px;
    left: 50%;
    transform: translateX(-50%);
  }

  .inverter-box {
    width: 92px;
    height: 92px;
  }

  .inverter-icon {
    height: 92px;
    max-width: 92px;
  }

  .grid {
    top: 170px;
    right: 0;
    text-align: center;
  }

  .grid-readings {
    margin-top: 2px;
  }

  .load {
    top: 330px;
    left: 50%;
    width: 155px;
    transform: translateX(-50%);
  }

  .flow-battery-to-inverter {
    top: 205px;
    left: 78px;
    width: calc(50% - 128px);
    min-width: 52px;
  }

  .flow-pv-to-inverter {
    top: 92px;
    left: calc(50% - 18px);
    width: 35px;
    height: 60px;
    min-width: 0;
  }

  .flow-grid-to-inverter,
  .flow-inverter-to-grid {
    top: 205px;
    left: calc(50% + 50px);
    width: calc(50% - 128px);
    min-width: 52px;
  }

  .flow-inverter-to-load {
    top: 250px;
    left: calc(50% - 18px);
    width: 35px;
    height: 86px;
  }
}

@media (max-width: 560px) {
  .data-toolbar {
    align-items: stretch;
  }

  .data-field {
    width: 100%;
  }

  .month-picker {
    grid-template-columns: 42px minmax(0, 1fr) 42px;
  }

  .month-popover {
    left: 0;
    width: min(290px, calc(100vw - 28px));
    transform: none;
  }

  .chart-panel {
    padding-top: 8px;
  }

  .chart-head {
    gap: 8px;
    margin-bottom: 4px;
  }

  .chart-head h2 {
    font-size: 20px;
  }

  .chart-canvas {
    min-width: 640px;
    height: 340px;
  }

  .monthly-chart-head {
    justify-content: center;
  }

  .monthly-chart-canvas {
    min-width: 620px;
    height: 340px;
  }

  .range-toggle {
    width: 100%;
  }

  .range-option {
    flex: 1;
    padding: 0 6px;
  }

  .savings-table-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .savings-table {
    font-size: 12px;
  }

  .savings-table th,
  .savings-table td {
    padding: 8px 7px;
  }

  .savings-pagination {
    justify-content: center;
  }

  .page-size-control {
    justify-content: center;
  }

  .diagram-wrap {
    --diagram-width: 100%;
    --diagram-height: 465px;
  }
}

@media (max-width: 460px) {
  .diagram-wrap {
    --diagram-width: 100%;
    --diagram-height: 445px;
  }

  .diagram-canvas {
    height: 445px;
  }

  .node-icon {
    font-size: 44px;
  }

  .node strong {
    min-width: 50px;
    font-size: 18px;
  }

  .pv-small strong {
    min-width: 0;
    font-size: inherit;
  }

  .node span {
    font-size: 12px;
  }

  .pv-small span {
    font-size: inherit;
  }

  .battery {
    top: 164px;
  }

  .grid {
    top: 164px;
  }

  .inverter {
    top: 154px;
  }

  .flow-battery-to-inverter {
    left: 66px;
    width: calc(50% - 112px);
  }

  .flow-grid-to-inverter,
  .flow-inverter-to-grid {
    left: calc(50% + 45px);
    width: calc(50% - 112px);
  }
}

@media (max-width: 400px) {
  .topbar {
    padding: 6px 8px;
  }

  .logo-circle {
    width: 30px;
    height: 30px;
    font-size: 12px;
  }

  .brand-title {
    font-size: 18px;
  }

  .brand-subtitle {
    display: none;
  }

  .right-status {
    gap: 6px;
  }

  .nav-item {
    padding: 7px 4px;
    font-size: 11px;
  }

  .diagram-wrap {
    --diagram-width: 100%;
    --diagram-height: 435px;
  }

  .diagram-canvas {
    height: 435px;
  }

  .battery {
    left: -2px;
  }

  .grid {
    right: -2px;
  }

  .flow-battery-to-inverter {
    left: 58px;
    width: calc(50% - 102px);
  }

  .flow-grid-to-inverter,
  .flow-inverter-to-grid {
    left: calc(50% + 43px);
    width: calc(50% - 102px);
  }
}
