﻿:root {
  color-scheme: light;
  --bg: #eef4f8;
  --panel: #ffffff;
  --ink: #102a43;
  --muted: #5d7285;
  --line: #cbdbe7;
  --navy: #0b2945;
  --brand-blue: #2c91c4;
  --brand-orange: #f47a22;
  --green: #13784a;
  --green-bg: #edfdf4;
  --red: #bf3030;
  --red-bg: #fff0f0;
  --blue: #255edb;
  --amber: #a7650f;
  --amber-bg: #fff7e8;
}

* { box-sizing: border-box; }

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

h1, h2, h3, p { margin: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 14px 20px;
  background: linear-gradient(110deg, #081d31, #123e60);
  border-bottom: 3px solid var(--brand-orange);
  box-shadow: 0 4px 14px rgba(8, 29, 49, .18);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand img {
  width: 112px;
  height: 48px;
  object-fit: contain;
}

.topbar h1 { color: #fff; }

h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }

#subtitle {
  margin-top: 4px;
  color: #c9dce9;
  font-size: 13px;
}

.connection-leds {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 7px;
  color: #c9dce9;
  font-size: 10px;
  font-weight: 700;
}

.connection-leds span { display: inline-flex; align-items: center; gap: 5px; }
.connection-leds i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d23b3b;
  box-shadow: 0 0 0 2px rgba(210, 59, 59, .22);
}
.connection-leds i.ready {
  background: #3dd37d;
  box-shadow: 0 0 0 2px rgba(61, 211, 125, .22);
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.topbar .badge:not(.ok):not(.bad) {
  color: #dceaf3;
  border-color: rgba(255, 255, 255, .32);
  background: rgba(255, 255, 255, .08);
}

.section-head h2 { color: var(--navy); }

.layout {
  display: grid;
  gap: 14px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 14px;
}

.load-overview {
  overflow: hidden;
  padding: 16px;
  border-color: #b8d8ec;
  background: linear-gradient(135deg, #fafdff 0%, #eef7ff 58%, #f9fcff 100%);
}

/* Palet kelompok data memperjelas asal telemetry tanpa badge status. */
.ami-theme-panel { border-top: 4px solid #1c9bc4; background: linear-gradient(135deg, #fff, #edfaff); }
.dlm-theme-panel { border-top: 4px solid #356fc5; background: linear-gradient(135deg, #fff, #f0f5ff); }
.ev-theme-card { border-top-color: #1fb878 !important; background: linear-gradient(145deg, #fff, #effcf5); }
.specific-theme-card { border-top-color: #f17a28 !important; background: linear-gradient(145deg, #fff, #fff5ec); }
.ami-theme-panel .section-head h2 { color: #16799b; }
.dlm-theme-panel .section-head h2 { color: #285da9; }
.ev-theme-card h3, .ev-theme-card .data-group-title { color: #167d50; }
.specific-theme-card h3, .specific-theme-card .data-group-title { color: #b35b1d; }

/* Adaptasi komposisi rangkuman Adaptive EV: seluruh nilai tetap dari MQTT. */
.panel.adaptive-summary { padding: 14px; border-radius: 6px; background: linear-gradient(135deg, #fbfdff, #edf6ff); }
.adaptive-summary-grid { width: 100%; display: grid; grid-template-columns: minmax(270px, 2.1fr) minmax(300px, 1.65fr) minmax(300px, 1fr); align-items: center; gap: 22px; }
.adaptive-card { border: 1.5px solid #cfe1ff; border-radius: 16px; background: rgba(255,255,255,.96); box-shadow: 0 5px 18px rgba(44,105,180,.06); }
.adaptive-capacity { min-height: 280px; padding: 20px 20px 17px; }
.adaptive-heading { display: flex; align-items: center; gap: 15px; color: #12366f; font-size: clamp(17px,1.55vw,25px); font-weight: 700; line-height: 1.2; }
.adaptive-heading img { width: 55px; height: 55px; object-fit: contain; }
.adaptive-capacity-value { display: block; margin-top: 7px; text-align: center; color: #12366f; font-size: clamp(48px,5vw,68px); letter-spacing: -2px; line-height: 1.08; }
.adaptive-caption { display: block; margin-top: 3px; text-align: center; color: #344f7e; font-size: clamp(15px,1.35vw,21px); }
.adaptive-progress { height: 14px; margin: 17px 0 15px; overflow: hidden; border-radius: 30px; background: #e0e8f7; }
.adaptive-progress i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg,#079d59,#20b65c); transition: width .35s ease; }
.adaptive-stats { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid #d8e5f8; padding-top: 12px; text-align: center; color: #243e70; font-size: 15px; }
.adaptive-stats span + span { border-left: 1.5px solid #b9cbea; }
.adaptive-stats b { display: block; margin-top: 3px; color: #12366f; font-size: clamp(25px,2.4vw,36px); }
.adaptive-stats span:last-child b { color: #07843e; }
.adaptive-building { position: relative; min-height: 315px; display: grid; place-items: center; align-content: center; text-align: center; padding: 8px 0; }
.adaptive-building img { width: min(205px, 80%); height: 190px; object-fit: contain; }
.adaptive-building strong { display: block; margin-top: -13px; color: #12366f; font-size: clamp(40px,4vw,59px); line-height: 1; }
.adaptive-building span { margin-top: 5px; color: #243f70; font-size: clamp(15px,1.35vw,21px); }
.adaptive-arrow { position: absolute; left: -28px; top: 50%; width: 28px; height: 5px; background: #1681e8; }
.adaptive-arrow::after { position: absolute; top: -5px; right: -1px; border-top: 8px solid transparent; border-bottom: 8px solid transparent; border-left: 11px solid #1681e8; content: ''; }
.adaptive-loads { display: flex; flex-direction: column; gap: 19px; }
.adaptive-load { display: flex; min-height: 106px; align-items: center; gap: 17px; padding: 12px 18px; }
.adaptive-load > img, .adaptive-non-ev-top > img { width: 100px; height: 82px; object-fit: contain; }
.adaptive-divider { width: 2px; height: 78px; flex: 0 0 2px; background: currentColor; opacity: .65; }
.adaptive-load span, .adaptive-non-ev-top span { display: block; font-size: clamp(18px,1.7vw,25px); font-weight: 700; }
.adaptive-load strong, .adaptive-non-ev-top strong { display: inline-block; margin-top: 4px; font-size: clamp(36px,3.5vw,54px); line-height: 1; }
.adaptive-load small, .adaptive-non-ev-top small { margin-left: 5px; color: #405574; font-size: 12px; font-weight: 700; }
.adaptive-ev { color: #078747; border-color: #70d99b; background: linear-gradient(110deg, #f0fff6, #e4f8ec); }
.adaptive-non-ev { color: #12366f; border-color: #a9bee4; background: linear-gradient(110deg, #f8faff, #edf3ff); }
.adaptive-non-ev { display: block; min-height: 190px; padding: 15px 18px; }
.adaptive-non-ev-top { display: flex; align-items: center; gap: 17px; }
.adaptive-detail { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: baseline; margin: 10px 0 0 107px; color: #173b78; font-size: clamp(14px,1.25vw,18px); }
.adaptive-detail b { color: #12366f; font-size: clamp(17px,1.55vw,22px); }
.adaptive-detail em { color: #405574; font-size: 15px; font-style: normal; }

@media (max-width: 1000px) {
  .adaptive-summary-grid { grid-template-columns: 1fr 1fr; }
  .adaptive-building { grid-column: 1 / -1; grid-row: 2; min-height: 165px; }
  .adaptive-arrow { display: none; }
}

@media (max-width: 590px) {
  .adaptive-summary { padding: 12px; }
  .adaptive-summary-grid { grid-template-columns: 1fr; gap: 13px; }
  .adaptive-building { grid-column: auto; grid-row: auto; min-height: 155px; }
}

.overview-head { margin-bottom: 8px; }
.overview-head h2 { font-size: 14px; }
.overview-head .muted { display: block; margin-top: 3px; }

.overview-flow {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 56px minmax(190px, .82fr) 56px minmax(210px, 1fr);
  align-items: center;
  gap: 0;
}

.overview-capacity,
.overview-house,
.overview-load {
  border: 1px solid #c8deee;
  border-radius: 14px;
  background: rgba(255, 255, 255, .92);
}

.overview-capacity {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 7px 10px;
  padding: 13px;
  box-shadow: 0 4px 14px rgba(25, 101, 147, .08);
}

.overview-icon { width: 45px; height: 48px; align-self: center; }
.overview-icon img { width: 100%; height: 100%; object-fit: contain; }
.overview-card-copy span,
.overview-load span,
.overview-house span { display: block; color: var(--navy); font-weight: 700; }
.overview-card-copy strong { display: block; margin: 2px 0; color: #123e82; font-size: 30px; line-height: 1; }
.overview-card-copy small { color: var(--muted); font-size: 11px; }

.overview-progress { grid-column: 1 / -1; height: 11px; overflow: hidden; border-radius: 99px; background: #dbe9f5; }
.overview-progress i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #16aa66, #46c780); transition: width .35s ease; }
.overview-capacity-foot { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 11px; }
.overview-capacity-foot b { display: block; margin-top: 2px; color: var(--navy); font-size: 16px; }
.overview-capacity-foot span:last-child b { color: var(--green); }

.overview-connector { position: relative; height: 4px; margin: 0 7px; background: #1686d9; }
.overview-connector::after { position: absolute; top: -6px; right: -1px; width: 0; height: 0; border-top: 8px solid transparent; border-bottom: 8px solid transparent; border-left: 11px solid #1686d9; content: ''; }
.to-loads { background: #6685aa; }
.to-loads::after { border-left-color: #6685aa; }

.overview-house { position: relative; min-height: 164px; padding: 12px 20px 18px; text-align: center; border: 0; background: transparent; }
.house-icon { display: block; width: 112px; height: 104px; margin: 0 auto -8px; object-fit: contain; }
.overview-house strong { display: block; color: #123e82; font-size: 33px; line-height: 1; }
.overview-house span { margin-top: 3px; color: #234a78; font-size: 12px; }

.overview-loads { display: grid; gap: 12px; }
.overview-load { display: grid; grid-template-columns: 59px 1fr; align-items: center; gap: 10px; min-height: 72px; padding: 10px 13px; }
.overview-load-icon { width: 54px; height: 42px; object-fit: contain; }
.overview-load strong { display: block; margin-top: 3px; color: #123e82; font-size: 26px; line-height: 1; }
.overview-load small { margin-left: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.ev-load { border-color: #8bdfb0; background: linear-gradient(135deg, #f3fff8, #e0f9ea); }
.ev-load strong { color: #108446; }
.non-ev-load { border-color: #c5d2e5; background: linear-gradient(135deg, #f9fbff, #edf3fb); }
.non-ev-load { min-height: 142px; }
.non-ev-copy { position: relative; padding-bottom: 51px; }
.non-ev-breakdown { position: absolute; right: 0; bottom: 0; left: 0; display: grid; gap: 3px; padding-top: 6px; border-top: 1px solid #c8d5e7; }
.non-ev-breakdown span { display: grid; grid-template-columns: 1fr auto auto; align-items: baseline; gap: 7px; color: #28486e; font-size: 11px; font-weight: 600; }
.non-ev-breakdown b { color: #183d70; font-size: 14px; }
.non-ev-breakdown em { color: #5d7285; font-size: 11px; font-style: normal; }

@media (max-width: 900px) {
  .overview-flow { grid-template-columns: 1fr; gap: 10px; }
  .overview-connector { display: none; }
  .overview-house { min-height: 145px; max-width: 310px; margin: 0 auto; }
  .overview-loads { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .load-overview { padding: 12px; }
  .overview-loads { grid-template-columns: 1fr; }
  .overview-card-copy strong, .overview-house strong { font-size: 28px; }
}

.panel,
.meter-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 2px 8px rgba(26, 67, 96, .05);
}

.compact-panel {
  padding: 8px 10px;
}

.compact-panel .section-head {
  margin-bottom: 7px;
}

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

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.muted,
.meter-head p,
.health-card small,
.metric-grid span,
.status-grid span,
.dlm-target span,
.dlm-target small {
  color: var(--muted);
  font-size: 12px;
}

.data-group-title {
  margin: 14px 0 7px;
  color: var(--accent);
  font-size: 13px;
}

.ami-manual-card summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  color: var(--navy);
  font-size: 16px;
  font-weight: 700;
}
.ami-manual-card summary small { color: var(--muted); font-size: 12px; font-weight: 400; }
.ami-manual-card > .muted { display: block; margin: 12px 0; }


.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
  overflow-wrap: anywhere;
  text-align: center;
}

.badge.ok {
  color: var(--green);
  border-color: #9fd5b7;
  background: var(--green-bg);
}

.badge.bad {
  color: var(--red);
  border-color: #f0aaa7;
  background: var(--red-bg);
}

.small-button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  border-color: #9fc8df;
  background: #edf8fd;
  color: #17648e;
  font-weight: 700;
  cursor: pointer;
}

.small-button.danger {
  color: #a13f12;
  border-color: #f6b080;
  background: #fff3e9;
}

.small-button:hover {
  filter: brightness(.97);
}

.status-grid,
.health-grid,
.metric-grid,
.meter-grid,
.control-grid,
.reset-grid,
.split {
  display: grid;
  gap: 10px;
}

.status-grid {
  grid-template-columns: 1.1fr 1.2fr 1fr 1fr 0.8fr 1.6fr;
}

.status-grid div,
.metric-grid div,
.health-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fbfcff;
}

.compact-panel.status-grid div,
.compact-panel .health-card {
  padding: 6px 8px;
}

.compact-panel.status-grid strong,
.compact-panel .health-card strong {
  margin-top: 3px;
  font-size: 13px;
}

.compact-panel .health-card small {
  margin-top: 2px;
  font-size: 11px;
}

.device-status-row {
  display: grid;
  grid-template-columns: minmax(180px, .8fr) repeat(4, minmax(190px, 1fr));
  gap: 8px;
  overflow-x: auto;
}

.device-status-row .summary-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-left: 5px solid var(--brand-blue);
  border-radius: 6px;
  padding: 6px 8px;
  background: #fbfcff;
}

.device-status-row .summary-card span {
  color: var(--muted);
  font-size: 12px;
}

.device-status-row .summary-card strong {
  display: block;
  margin-top: 3px;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.status-grid strong,
.metric-grid strong,
.health-card strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.health-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.health-card {
  border-left: 5px solid var(--line);
}

.health-card.ok { border-left-color: var(--green); }
.health-card.bad { border-left-color: var(--red); }

.health-card span,
.health-card small {
  display: block;
}

.meter-grid {
  grid-template-columns: minmax(280px, 460px);
}

.meter-card {
  border-left: 5px solid var(--line);
}

.meter-card.ok { border-left-color: var(--green); }
.meter-card.bad { border-left-color: var(--red); }

.metric-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.metric-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric-grid.one { grid-template-columns: 1fr; }
.metric-grid.compact { gap: 8px; }
.metric-grid.compact div { padding: 8px; }
.metric-grid.compact strong { font-size: 17px; }

.meter-ami-panel .metric-grid {
  max-width: none;
}

.meter-card .small-button {
  width: 100%;
  margin-top: 10px;
}

.control-grid {
  grid-template-columns: minmax(180px, 1fr) auto;
  align-items: end;
  margin-bottom: 12px;
}

.control-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.control-field span,
.write-mode {
  color: var(--muted);
  font-size: 12px;
}

.control-field select,
.control-field input {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.write-mode {
  margin-top: 8px;
}

.write-mode strong {
  color: var(--ink);
}

.reset-grid {
  grid-template-columns: minmax(140px, 1fr) minmax(140px, auto);
  align-items: center;
  margin-bottom: 12px;
}

.subsection-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 10px;
}

.reset-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.split {
  grid-template-columns: 1fr 1fr;
}

.dlm-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 12px;
}

.dlm-flow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.dlm-summary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.dlm-step {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px;
  background: #fbfcff;
}

.dlm-step span,
.dlm-feedback span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.dlm-step strong,
.dlm-feedback strong {
  display: block;
  margin-top: 5px;
  font-size: 16px;
}

/* Arus tersisa adalah nilai utama untuk keputusan charging EV. */
.dlm-available {
  display: grid;
  align-content: center;
  gap: 3px;
  min-height: 78px;
  border: 0;
  padding: 13px;
  color: #fff;
  background: linear-gradient(145deg, #2187ad, #175a8b);
}

.dlm-available span,
.dlm-available small {
  color: #e7f7ff;
}

.dlm-available strong {
  margin-top: 0;
  color: #fff;
  font-size: 26px;
  line-height: 1.05;
}

.dlm-available small {
  font-size: 12px;
  font-weight: 600;
}

.dlm-target {
  display: grid;
  align-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  border-color: #8dc6e4;
  background: linear-gradient(145deg, #edf8fd, #fff7ef);
}

.dlm-target strong {
  font-size: 44px;
  line-height: 1;
}

.dlm-feedback {
  margin-top: 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.dlm-feedback strong {
  font-size: 22px;
}

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

.accounting-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcff;
}

.accounting-card:first-child { border-top: 4px solid var(--brand-blue); }
.accounting-card:last-child { border-top: 4px solid var(--brand-orange); }

.metric-wide { grid-column: 1 / -1; }

.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.events {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
  font-family: Consolas, 'Courier New', monospace;
  font-size: 12px;
}

.event-row {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #fbfcff;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 1180px) {
  .status-grid,
  .meter-grid,
  .control-grid,
  .reset-grid,
  .metric-grid.four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dlm-main,
  .split,
  .accounting-grid {
    grid-template-columns: 1fr;
  }

  .dlm-flow {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar,
  .section-head,
  .meter-head {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .brand img {
    width: 90px;
    height: 40px;
  }

  .status-grid,
  .health-grid,
  .meter-grid,
  .control-grid,
  .reset-grid,
  .metric-grid.two,
  .metric-grid.four {
    grid-template-columns: 1fr;
  }


  .dlm-flow {
    grid-template-columns: 1fr;
  }

  .dlm-target strong {
    font-size: 34px;
  }
}

.config-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(140px, auto);
  gap: 10px;
  align-items: end;
}

.autel-config-panel .control-field {
  margin: 0;
}

.autel-config-panel .small-button {
  min-height: 34px;
}

@media (max-width: 720px) {
  .config-row {
    grid-template-columns: 1fr;
  }
}

.manual-write-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto;
  gap: 8px;
  align-items: end;
  margin-top: 10px;
}

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

.modbus-config-grid fieldset {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcff;
}

.modbus-config-grid legend {
  padding: 0 6px;
  color: var(--navy);
  font-weight: 700;
}

.modbus-config-grid .control-field {
  margin: 0;
}

.modbus-config-grid input,
.modbus-config-grid select {
  min-height: 34px;
}

@media (max-width: 1180px) {
  .modbus-config-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .modbus-config-grid fieldset {
    grid-template-columns: 1fr;
  }
}

.manual-write-row .control-field {
  margin: 0;
}

.manual-write-row input {
  min-height: 34px;
}

@media (max-width: 720px) {
  .manual-write-row {
    grid-template-columns: 1fr;
  }
}

/* Infografik DLM: komposisi rumah, aliran beban, dan kartu konsumsi. */
.panel.adaptive-summary {
  position: relative;
  overflow: hidden;
  padding: 30px 20px;
  border: 0;
  border-radius: 20px;
  background:
    radial-gradient(circle at 50% 48%, rgba(207, 229, 255, .7), transparent 31%),
    linear-gradient(135deg, #f8fbff, #eef5ff 58%, #fafcff);
  box-shadow: inset 0 0 0 1px #e1ebf8, 0 12px 32px rgba(47, 91, 145, .08);
}
.overview-head { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.adaptive-summary-grid { grid-template-columns: minmax(270px, 1.06fr) minmax(310px, .96fr) minmax(330px, 1.03fr); gap: clamp(28px, 4vw, 70px); min-height: 470px; }
.adaptive-card { border-width: 2px; border-radius: 22px; box-shadow: 0 10px 25px rgba(42, 80, 133, .08); }
.adaptive-capacity { min-height: 420px; padding: 30px 26px 22px; border-color: #dbe6f5; background: rgba(255, 255, 255, .88); }
.adaptive-heading { gap: 18px; color: #093c87; font-size: clamp(22px, 2vw, 30px); }
.diagram-home-icon { position: relative; width: 88px; height: 68px; flex: 0 0 88px; border-radius: 4px 4px 2px 2px; background: #063b86; clip-path: polygon(12% 47%, 50% 7%, 88% 47%, 80% 47%, 80% 96%, 57% 96%, 57% 68%, 43% 68%, 43% 96%, 20% 96%, 20% 47%); }
.diagram-home-icon::after { position: absolute; top: 5px; right: 8px; width: 9px; height: 24px; border-radius: 3px; background: #0961bd; content: ''; }
.adaptive-capacity-value { margin-top: 17px; color: #073b86; font-size: clamp(54px, 5.3vw, 76px); }
.adaptive-caption { margin-top: 4px; color: #0a3f89; font-size: clamp(18px, 1.7vw, 26px); }
.adaptive-progress { position: relative; height: 28px; margin: 27px 0 23px; background: #e2ebf7; }
.adaptive-progress i { background: linear-gradient(90deg, #50ca64, #27ad57); }
.adaptive-progress b { position: absolute; top: 50%; right: -1px; transform: translateY(-50%); padding: 7px 12px; border-radius: 12px; color: #078443; font-size: 19px; line-height: 1; background: #dff8e6; }
.adaptive-stats { padding-top: 17px; color: #0a3e87; font-size: clamp(17px, 1.45vw, 23px); }
.adaptive-stats b { margin-top: 8px; color: #093e89; font-size: clamp(32px, 3vw, 48px); }
.adaptive-stats span + span { border-left-color: #cbdcf2; }
.adaptive-building { min-height: 470px; padding: 38px 0 20px; }
.adaptive-building .adaptive-arrow { left: clamp(-66px, -4vw, -28px); width: clamp(46px, 5vw, 75px); height: 10px; border-radius: 8px; background: #1266ce; }
.adaptive-building .adaptive-arrow::after { top: -7px; right: -3px; border-top-width: 12px; border-bottom-width: 12px; border-left-width: 16px; border-left-color: #1266ce; }
.diagram-house { position: relative; width: min(270px, 89%); height: 230px; margin: 0 auto 8px; border: 10px solid #1266c7; border-top: 0; border-radius: 2px 2px 12px 12px; background: linear-gradient(145deg, #fff 16%, #e8f2ff); box-shadow: inset 0 0 0 8px rgba(222, 236, 255, .8), 0 12px 18px rgba(55, 105, 168, .12); }
.diagram-house::before { position: absolute; z-index: 1; top: -88px; left: -25px; width: calc(100% + 50px); height: 118px; border-top: 14px solid #1266c7; border-radius: 50% 50% 0 0; transform: skewY(-34deg); transform-origin: center; content: ''; }
.diagram-house::after { position: absolute; top: 35px; left: 50%; width: 54px; height: 54px; transform: translateX(-50%); border-radius: 7px; background: linear-gradient(135deg, #8fc5ff, #4c9df0); box-shadow: 64px 0 #6aaef3, -64px 0 #6aaef3; content: ''; }
.diagram-house i { position: absolute; z-index: 2; bottom: 18px; width: 29px; height: 46px; border-radius: 4px 4px 0 0; background: #0c5dbc; }
.diagram-house i:nth-child(1) { left: 25px; }.diagram-house i:nth-child(2) { left: 68px; }.diagram-house i:nth-child(3) { right: 68px; }.diagram-house i:nth-child(4) { right: 25px; }
.adaptive-building strong { z-index: 3; margin-top: 0; color: #073b86; font-size: clamp(48px, 4.7vw, 69px); }
.adaptive-building span { color: #093e89; font-size: clamp(18px, 1.6vw, 25px); }
.diagram-appliances { display: flex; justify-content: center; gap: 14px; margin-top: 25px; color: #0754a9; font-size: 34px; line-height: 1; filter: saturate(1.25); }
.adaptive-loads { position: relative; gap: 34px; }
.adaptive-loads::before { position: absolute; z-index: 0; top: 50%; left: clamp(-76px, -5vw, -42px); width: clamp(42px, 5vw, 76px); height: 112px; transform: translateY(-50%); border: 10px solid #1670da; border-right: 0; border-radius: 18px 0 0 18px; content: ''; }
.adaptive-loads::after { position: absolute; z-index: 1; top: calc(50% - 16px); left: clamp(-25px, -1.4vw, -12px); width: 0; height: 0; border-top: 16px solid transparent; border-bottom: 16px solid transparent; border-left: 21px solid #1670da; content: ''; }
.adaptive-load { position: relative; z-index: 2; min-height: 170px; padding: 20px 24px; gap: 19px; }
.adaptive-load > img, .adaptive-non-ev-top > img { width: 122px; height: 106px; }
.adaptive-divider { height: 108px; background: currentColor; }
.adaptive-load span, .adaptive-non-ev-top span { font-size: clamp(22px, 1.85vw, 29px); }
.adaptive-load strong, .adaptive-non-ev-top strong { font-size: clamp(46px, 4.1vw, 63px); }
.adaptive-load small, .adaptive-non-ev-top small { font-size: clamp(15px, 1.2vw, 20px); }
.adaptive-ev { border-color: #67d483; background: linear-gradient(135deg, #fbfffc, #e8f9ed); }
.adaptive-non-ev { min-height: 250px; padding: 20px 24px; border-color: #ff7b0a; background: linear-gradient(135deg, #fff, #fff6ed); }
.adaptive-detail { margin: 16px 0 0 130px; padding-top: 12px; border-top: 1px solid #e1e8f2; font-size: clamp(16px, 1.4vw, 21px); }
.adaptive-detail b { font-size: clamp(21px, 1.8vw, 28px); }
.adaptive-detail em { font-size: clamp(14px, 1.2vw, 18px); }

@media (max-width: 1100px) {
  .adaptive-summary-grid { grid-template-columns: 1fr 1fr; }
  .adaptive-building { grid-column: 1 / -1; grid-row: 2; }
  .adaptive-building .adaptive-arrow, .adaptive-loads::before, .adaptive-loads::after { display: none; }
}

@media (max-width: 620px) {
  .panel.adaptive-summary { padding: 16px 12px; }
  .adaptive-summary-grid { grid-template-columns: 1fr; min-height: 0; gap: 20px; }
  .adaptive-capacity, .adaptive-building, .adaptive-load, .adaptive-non-ev { min-height: auto; }
  .adaptive-building { grid-column: auto; grid-row: auto; padding: 75px 0 24px; }
  .adaptive-loads { gap: 18px; }
  .adaptive-loads::before, .adaptive-loads::after { display: none; }
  .adaptive-detail { margin-left: 0; }
}

/* Versi ringkas: fokus pada angka dan hirarki informasi, tanpa ornamen yang bertabrakan. */
.panel.adaptive-summary {
  padding: 22px;
  border: 1px solid #d8e5f3;
  border-radius: 14px;
  background: linear-gradient(135deg, #fbfdff, #edf5ff);
}
.adaptive-summary-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  align-items: center;
  gap: 24px;
  min-height: 0;
}
.adaptive-card { border-radius: 16px; box-shadow: 0 4px 14px rgba(34, 78, 130, .06); }
.adaptive-capacity { min-height: 292px; padding: 22px 20px 17px; }
.adaptive-heading { gap: 12px; font-size: 22px; }
.diagram-home-icon { width: 48px; height: 42px; flex-basis: 48px; }
.adaptive-capacity-value { margin-top: 13px; font-size: 54px; }
.adaptive-caption { font-size: 18px; }
.adaptive-progress { height: 18px; margin: 20px 0 16px; }
.adaptive-progress b { padding: 4px 8px; border-radius: 8px; font-size: 13px; }
.adaptive-stats { padding-top: 12px; font-size: 16px; }
.adaptive-stats b { margin-top: 5px; font-size: 32px; }

.adaptive-building { min-height: 292px; padding: 50px 0 12px; }
.adaptive-building .adaptive-arrow { left: -36px; width: 34px; height: 6px; }
.adaptive-building .adaptive-arrow::after { top: -5px; border-top-width: 8px; border-bottom-width: 8px; border-left-width: 11px; }
.diagram-house { width: 172px; height: 145px; margin-bottom: 6px; border-width: 7px; border-radius: 2px 2px 8px 8px; box-shadow: inset 0 0 0 5px rgba(222,236,255,.8), 0 8px 16px rgba(55,105,168,.1); }
.diagram-house::before { top: -56px; left: -17px; width: calc(100% + 34px); height: 75px; border-top-width: 10px; }
.diagram-house::after { top: 24px; width: 34px; height: 34px; border-radius: 4px; box-shadow: 44px 0 #6aaef3, -44px 0 #6aaef3; }
.diagram-house i { bottom: 11px; width: 20px; height: 28px; }
.diagram-house i:nth-child(1) { left: 16px; }.diagram-house i:nth-child(2) { left: 44px; }.diagram-house i:nth-child(3) { right: 44px; }.diagram-house i:nth-child(4) { right: 16px; }
.adaptive-building strong { font-size: 48px; }
.adaptive-building span { font-size: 18px; }
.diagram-appliances { display: none; }

.adaptive-loads { gap: 18px; }
.adaptive-loads::before, .adaptive-loads::after { display: none; }
.adaptive-load { min-height: 108px; padding: 13px 18px; gap: 13px; }
.adaptive-load > img, .adaptive-non-ev-top > img { width: 78px; height: 70px; }
.adaptive-divider { height: 64px; }
.adaptive-load span, .adaptive-non-ev-top span { font-size: 20px; }
.adaptive-load strong, .adaptive-non-ev-top strong { font-size: 40px; }
.adaptive-load small, .adaptive-non-ev-top small { font-size: 12px; }
.adaptive-non-ev { min-height: 166px; padding: 14px 18px; }
.adaptive-detail { grid-template-columns: 1fr auto auto; gap: 9px; margin: 8px 0 0 84px; padding-top: 7px; font-size: 15px; }
.adaptive-detail b { font-size: 18px; }.adaptive-detail em { font-size: 12px; }

@media (max-width: 640px) {
  .panel.adaptive-summary { padding: 14px; }
  .adaptive-summary-grid { grid-template-columns: 1fr; }
  .adaptive-building .adaptive-arrow { display: none; }
}

/* Ikon pusat menggunakan aset gedung agar konsisten dengan bahasa visual dashboard. */
.adaptive-building { padding: 18px 0 12px; }
.adaptive-building .summary-building-icon {
  display: block;
  width: 190px;
  height: 190px;
  margin: 0 auto -34px;
  object-fit: contain;
}
.adaptive-building strong { position: relative; z-index: 1; margin-top: 0; }

/* Jalur daya: panah masuk ke gedung dan dua panah keluar ke tiap kelompok beban. */
.adaptive-building .adaptive-arrow {
  left: -46px;
  width: 46px;
  height: 36px;
  border-radius: 0;
  background: #1670da;
  clip-path: polygon(0 42%, 62% 42%, 62% 0, 100% 50%, 62% 100%, 62% 58%, 0 58%);
}
.adaptive-building .adaptive-arrow::after { display: none; }
.adaptive-loads { overflow: visible; }
.adaptive-arrow-out {
  position: absolute;
  z-index: 1;
  left: -46px;
  display: block;
  width: 46px;
  height: 36px;
  background: #1670da;
  clip-path: polygon(0 42%, 62% 42%, 62% 0, 100% 50%, 62% 100%, 62% 58%, 0 58%);
}
.adaptive-arrow-out-ev { top: 36px; }
.adaptive-arrow-out-non-ev { bottom: 65px; }

@media (max-width: 640px) {
  .adaptive-arrow-out { display: none; }
}

@media (max-width: 960px) {
  .adaptive-building .adaptive-arrow, .adaptive-arrow-out { display: none; }
}

/* Konektor SVG berada di lapisan sendiri sehingga tidak pernah menutupi isi kartu. */
.adaptive-summary-grid { position: relative; isolation: isolate; }
.adaptive-capacity, .adaptive-building, .adaptive-loads { position: relative; z-index: 1; }
.dlm-connector-svg {
  position: absolute;
  z-index: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  --dlm-flow-color: #1670da;
}
.dlm-connector-path {
  fill: none;
  stroke: var(--dlm-flow-color);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 10 9;
  filter: drop-shadow(0 1px 1px rgba(11, 70, 145, .12));
}
#dlmArrowHead { display: none; }

@media (max-width: 960px) {
  .dlm-connector-svg { display: none; }
}

/* JavaScript menentukan sendiri kapan ketiga kolom masih membentuk koridor aman. */
.dlm-connector-svg { display: block; }
