.energy-dashboard {
  position: relative;
  container-type: inline-size;
  isolation: isolate;
  overflow: hidden;
  margin: 24px 0;
  padding: clamp(18px, 2.2vw, 30px);
  border: 1px solid rgba(73, 185, 214, 0.42);
  border-radius: 20px;
  color: #f4f9fc;
  background:
    radial-gradient(circle at 50% 44%, rgba(0, 174, 202, 0.10), transparent 34%),
    radial-gradient(circle at 92% 10%, rgba(26, 94, 137, 0.18), transparent 28%),
    linear-gradient(145deg, #071923 0%, #091f2b 46%, #06141d 100%);
  box-shadow:
    0 22px 56px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    inset 0 0 50px rgba(11, 133, 161, 0.05);
}
.energy-dashboard::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  opacity: 0.24;
  background-image:
    linear-gradient(rgba(54, 221, 240, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(54, 221, 240, 0.035) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, black, transparent 72%);
}
.energy-dashboard::after {
  content: "";
  position: absolute;
  left: 8%; right: 8%; top: 0;
  height: 1px;
  z-index: -1;
  background: linear-gradient(90deg, transparent, #35dff0 28%, #35dff0 72%, transparent);
  box-shadow: 0 0 18px rgba(53, 223, 240, 0.75);
}
.energy-dashboard[hidden] { display: none !important; }

.energy-dashboard-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 22px;
}
.energy-dashboard-heading .eyebrow {
  margin: 0 0 7px;
  color: #3ce7d1;
  font-size: .76rem;
  font-weight: 850;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.energy-dashboard-heading h2 {
  margin: 0;
  color: #f7fbff;
  font-size: clamp(1.7rem, 3vw, 2.35rem);
  line-height: 1.08;
}
.energy-heading-icon { color: #35dff0; margin-right: 8px; }
.energy-live-status {
  display: flex;
  align-items: center;
  gap: 11px;
  padding-top: 8px;
  color: #d7e2e8;
  font-size: .86rem;
  white-space: nowrap;
}
.energy-live-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #35e767;
  box-shadow: 0 0 13px rgba(53, 231, 103, .75);
}
.energy-live-divider { width: 1px; height: 20px; background: rgba(184, 212, 223, .25); }

/* Mantener siempre las seis métricas en una fila en escritorio real. */
.energy-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}
.energy-metric {
  min-width: 0;
  min-height: 136px;
  padding: 15px 12px;
  border: 1px solid rgba(94, 170, 193, .35);
  border-radius: 14px;
  background:
    linear-gradient(155deg, rgba(19, 46, 60, .88), rgba(8, 27, 37, .94));
  box-shadow: inset 0 1px rgba(255,255,255,.035), 0 8px 20px rgba(0,0,0,.12);
}
.energy-metric-main {
  height: 100%;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}
.energy-metric-icon {
  display: grid;
  place-items: center;
  width: 42px; height: 42px;
  border: 1px solid rgba(53, 223, 240, .72);
  border-radius: 50%;
  color: #38e5ef;
  font-size: 1.25rem;
  text-shadow: 0 0 10px rgba(56,229,239,.30);
  box-shadow: inset 0 0 14px rgba(37, 196, 220, .08);
}
.energy-metric-label {
  min-width: 0;
  color: #e7f0f5;
  font-size: clamp(.70rem, 1.1vw, .84rem);
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.energy-metric-reading {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}
.energy-metric-reading strong {
  color: #fff;
  font-size: clamp(1.32rem, 2.1vw, 1.9rem);
  line-height: .95;
  font-weight: 850;
  white-space: nowrap;
}
.energy-metric-reading span {
  color: #37deed;
  font-size: clamp(.64rem, 1vw, .78rem);
  white-space: nowrap;
}
.energy-metric.state-alarm { border-color: rgba(255, 103, 96, .75); }

/* Flujo siempre horizontal en tablet y escritorio. */
.energy-layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    "flow flow"
    "battery system";
  gap: 12px;
  margin-top: 14px;
}
.energy-flow-panel { grid-area: flow; }
.energy-battery-panel { grid-area: battery; }
.energy-system-panel { grid-area: system; }
.energy-panel {
  min-width: 0;
  border: 1px solid rgba(92, 166, 190, .35);
  border-radius: 14px;
  background: linear-gradient(155deg, rgba(15, 42, 54, .82), rgba(7, 25, 34, .91));
  padding: 15px;
  box-shadow: inset 0 1px rgba(255,255,255,.025);
}
.energy-panel > h3,
.energy-panel-heading-line h3 {
  margin: 0;
  color: #38dfe9;
  font-size: .82rem;
  font-weight: 850;
  letter-spacing: .08em;
  text-align: center;
}
.energy-panel-heading-line { display: flex; align-items: center; gap: 13px; }
.energy-panel-heading-line span { flex: 1; height: 1px; background: linear-gradient(90deg, transparent, rgba(53,223,240,.75)); }
.energy-panel-heading-line span:last-child { background: linear-gradient(90deg, rgba(53,223,240,.75), transparent); }

.energy-flow {
  display: grid;
  grid-template-columns: minmax(82px, 120px) minmax(55px, 1fr) minmax(150px, 190px) minmax(55px, 1fr) minmax(82px, 120px);
  align-items: center;
  gap: 7px;
  min-height: 250px;
  padding: 8px 2px 0;
}
.energy-flow-node { min-width: 0; text-align: center; color: #e4eef2; font-size: .72rem; }
.energy-flow-circle {
  display: grid;
  place-items: center;
  width: clamp(70px, 8.5vw, 98px);
  height: clamp(70px, 8.5vw, 98px);
  margin: 0 auto 10px;
  border: 3px solid rgba(50, 211, 232, .72);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(17, 64, 78, .78), rgba(5, 24, 33, .96));
  color: #37dfee;
  font-size: clamp(1.65rem, 3vw, 2.25rem);
  box-shadow: 0 0 0 7px rgba(16, 120, 149, .13), inset 0 0 24px rgba(45, 212, 235, .10);
}
.energy-flow-line { display: flex; align-items: center; min-width: 0; }
.energy-flow-line i { flex: 1; height: 2px; background: linear-gradient(90deg, rgba(53,223,240,.25), #45deed, rgba(53,223,240,.25)); box-shadow: 0 0 8px rgba(69,222,237,.45); }
.energy-flow-line b { color: #45deed; font-size: 1.65rem; font-weight: 300; }
.energy-flow-center { min-width: 0; text-align: center; }
.energy-power-ring {
  display: grid;
  place-items: center;
  width: clamp(138px, 16vw, 182px);
  height: clamp(138px, 16vw, 182px);
  margin: auto;
  border: 6px solid #39db63;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(10, 42, 50, .98), rgba(4, 20, 28, .99));
  box-shadow: 0 0 0 8px rgba(53,219,99,.13), 0 0 28px rgba(53,219,99,.16), inset 0 0 28px rgba(49,213,234,.08);
}
.energy-power-symbol { color: #38dfe9; font-size: 1.5rem; }
.energy-power-ring strong { color: #fff; font-size: clamp(1.6rem, 3vw, 2.1rem); white-space: nowrap; }
.energy-power-ring small { color: #d6e4e9; font-size: .67rem; }
.energy-operation-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: -9px;
  padding: 7px 15px;
  border: 1px solid rgba(48, 209, 84, .62);
  border-radius: 9px;
  background: rgba(7, 52, 26, .88);
  color: #36ea5c;
  font-size: .78rem;
}
.energy-operation-state.is-alarm { border-color:#ff7069; background:rgba(86,25,22,.82); color:#ff8079; }
.energy-flow-footer {
  margin-top: 1px;
  padding: 10px;
  border: 1px solid rgba(78, 145, 166, .20);
  border-radius: 8px;
  background: rgba(11, 39, 50, .58);
  color: #37dff0;
  text-align: center;
  font-size: .77rem;
}

.energy-battery-list,
.energy-system-list { display: grid; gap: 9px; margin-top: 13px; }
.energy-battery-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 83px;
  padding: 13px;
  border: 1px solid rgba(92, 151, 171, .30);
  border-radius: 10px;
  background: rgba(13, 40, 51, .66);
}
.energy-battery-icon { font-size: 1.65rem; text-align: center; }
.energy-battery-copy { min-width: 0; display: grid; gap: 6px; }
.energy-battery-copy span { color:#e3edf1; font-size:.82rem; }
.energy-battery-copy strong { color:#36e667; font-size:1.45rem; line-height:1; }
.energy-battery-copy strong.muted { color:#bdc8cd; }
.energy-battery-progress { display:grid; grid-template-columns:1fr auto; gap:9px; align-items:center; }
.energy-battery-progress:before { content:""; height:7px; border-radius:9px; background:rgba(98,120,130,.36); }
.energy-battery-progress i { display:none; }
.energy-battery-progress em { color:#c7d4d9; font-size:.68rem; font-style:normal; }
.energy-system-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  min-height: 49px;
  padding: 10px 12px;
  border: 1px solid rgba(92, 151, 171, .30);
  border-radius: 9px;
  background: rgba(13, 40, 51, .66);
}
.energy-system-icon { color:#38dff0; font-size:1.25rem; text-align:center; }
.energy-system-label { color:#e5eef2; font-size:.80rem; min-width:0; }
.energy-system-value { display:flex; align-items:center; gap:6px; font-weight:800; font-size:.78rem; white-space:nowrap; }
.energy-system-value i { width:7px; height:7px; border-radius:50%; background:currentColor; }
.energy-system-value.ok { color:#38e85c; }
.energy-system-value.warning { color:#ffd45c; }
.energy-system-value.error { color:#ff746d; }
.energy-system-value.muted { color:#aeb7bb; }

/* Sólo se apila en pantallas realmente angostas. */
@container (max-width: 720px) {
  .energy-dashboard-header { flex-direction: column; }
  .energy-live-status { padding-top: 0; flex-wrap: wrap; }
  .energy-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .energy-layout-grid { grid-template-columns: 1fr; grid-template-areas: "flow" "battery" "system"; }
}
@container (max-width: 520px) {
  .energy-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .energy-flow { grid-template-columns: 74px 1fr 126px 1fr 74px; min-height: 220px; }
  .energy-flow-circle { width: 64px; height: 64px; }
  .energy-power-ring { width: 122px; height: 122px; }
  .energy-flow-node { font-size: .62rem; }
}
@container (max-width: 380px) {
  .energy-metrics { grid-template-columns: 1fr; }
  .energy-flow { grid-template-columns: 1fr; }
  .energy-flow-line { width: 50px; margin: auto; transform: rotate(90deg); }
}


/* Energy V1.3: iconografía SVG centrada y representativa */
.energy-heading-icon {
  display: inline-grid;
  place-items: center;
  width: 1.05em;
  height: 1.05em;
  vertical-align: -0.12em;
}
.energy-heading-icon svg,
.energy-metric-icon svg,
.energy-flow-circle svg,
.energy-battery-icon svg,
.energy-system-icon svg,
.energy-flow-footer svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.energy-metric-icon {
  align-self: center;
  justify-self: center;
  padding: 9px;
  line-height: 0;
}
.energy-metric-icon svg { width: 28px; height: 28px; }
.energy-metric-icon text {
  fill: currentColor;
  stroke: none;
  font: 700 15px system-ui, sans-serif;
}
.energy-flow-circle { padding: clamp(16px, 2vw, 24px); line-height: 0; }
.energy-flow-circle svg { width: 100%; height: 100%; }
.energy-battery-icon, .energy-system-icon {
  display: grid;
  place-items: center;
  line-height: 0;
  color: #38dff0;
}
.energy-battery-icon svg { width: 30px; height: 30px; }
.energy-system-icon svg { width: 22px; height: 22px; }
.energy-flow-footer { display: flex; align-items: center; justify-content: center; gap: 7px; }
.energy-flow-footer svg { width: 17px; height: 17px; flex: 0 0 auto; }

/* Energy Dashboard V1.3.1 — centrado óptico de iconos */
.energy-metric-icon,
.energy-battery-icon,
.energy-system-icon,
.energy-flow-circle,
.energy-power-symbol {
  box-sizing: border-box;
  padding: 0 !important;
  line-height: 1 !important;
  text-align: center !important;
  vertical-align: middle;
}

.energy-metric-icon {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 62px !important;
  height: 62px !important;
  flex: 0 0 62px !important;
}

.energy-metric-icon svg,
.energy-battery-icon svg,
.energy-system-icon svg,
.energy-flow-circle svg,
.energy-power-symbol svg {
  display: block !important;
  margin: auto !important;
  flex: 0 0 auto;
  transform-origin: center;
}

/* Tamaño uniforme de los dibujos superiores */
.energy-metric-icon svg {
  width: 31px !important;
  height: 31px !important;
}

/* Centrado de red eléctrica y carga/equipo */
.energy-flow-node {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  min-width: 0;
}

.energy-flow-circle {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 94px !important;
  height: 94px !important;
  margin: 0 auto 12px !important;
}

.energy-flow-circle svg {
  width: 48px !important;
  height: 48px !important;
}

.energy-flow-node > span,
.energy-flow-node > small,
.energy-flow-node > div:not(.energy-flow-circle) {
  width: 100%;
  text-align: center;
}

/* Círculo central */
.energy-power-ring {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
}

.energy-power-symbol {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 40px;
  height: 32px;
  margin: 0 auto;
}

.energy-power-symbol svg {
  width: 30px !important;
  height: 30px !important;
}

/* Iconos inferiores */
.energy-battery-icon {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 52px !important;
  height: 52px !important;
  margin: 0 auto !important;
}

.energy-battery-icon svg {
  width: 30px !important;
  height: 30px !important;
}

.energy-system-icon {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 42px !important;
  height: 42px !important;
}

.energy-system-icon svg {
  width: 23px !important;
  height: 23px !important;
}

/* Centrado del icono informativo */
.energy-flow-footer {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px;
  text-align: center !important;
}

.energy-flow-footer svg {
  display: block;
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
}

/* =========================================================
   ENERGY METRICS V1.4
   Tarjetas superiores verticales, centradas y equilibradas
   ========================================================= */

.energy-metrics {
  display: grid !important;
  grid-template-columns: repeat(6, minmax(130px, 1fr)) !important;
  gap: 12px !important;
}

.energy-metric {
  position: relative;
  min-width: 0;
  min-height: 190px !important;
  padding: 16px 12px 14px !important;
  overflow: hidden;
  border: 1px solid rgba(55, 190, 220, 0.38) !important;
  border-radius: 14px !important;
  background:
    radial-gradient(
      circle at 50% 12%,
      rgba(20, 160, 195, 0.10),
      transparent 35%
    ),
    linear-gradient(
      180deg,
      rgba(7, 37, 52, 0.94),
      rgba(4, 26, 39, 0.98)
    ) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.035),
    0 10px 24px rgba(0, 0, 0, 0.18) !important;
}

.energy-metric::before {
  content: "";
  position: absolute;
  top: 0;
  left: 24%;
  right: 24%;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(42, 224, 244, 0.92),
    transparent
  );
  box-shadow: 0 0 10px rgba(42, 224, 244, 0.45);
}

.energy-metric::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 36%;
  right: 36%;
  height: 2px;
  border-radius: 999px;
  background: rgba(42, 224, 244, 0.78);
  box-shadow: 0 0 9px rgba(42, 224, 244, 0.4);
}

.energy-metric-main {
  height: 100%;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 0 !important;
  text-align: center !important;
}

.energy-metric-main > div:last-child {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.energy-metric-icon {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 66px !important;
  height: 66px !important;
  flex: 0 0 66px !important;
  margin: 2px auto 13px !important;
  padding: 0 !important;
  border: 1px solid rgba(39, 222, 241, 0.65) !important;
  border-radius: 50% !important;
  background:
    radial-gradient(
      circle,
      rgba(28, 157, 184, 0.14),
      rgba(4, 28, 40, 0.78)
    ) !important;
  color: #32e3f4 !important;
  font-size: 1.65rem !important;
  line-height: 1 !important;
  text-align: center !important;
  box-shadow:
    inset 0 0 18px rgba(27, 192, 220, 0.08),
    0 0 12px rgba(27, 192, 220, 0.12);
}

.energy-metric-icon svg {
  display: block !important;
  width: 32px !important;
  height: 32px !important;
  margin: auto !important;
}

.energy-metric-label {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #eef7fa !important;
  font-size: 0.82rem !important;
  font-weight: 500;
  line-height: 1.25;
  text-align: center;
}

.energy-metric-label::after {
  content: "";
  display: block;
  position: absolute;
}

.energy-metric-reading {
  position: relative;
  width: 100%;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 5px !important;
  margin-top: 15px !important;
  padding-top: 13px;
  text-align: center !important;
}

.energy-metric-reading::before {
  content: "";
  position: absolute;
  top: 0;
  left: 43%;
  right: 43%;
  height: 3px;
  border-radius: 999px;
  background: #29dff1;
  box-shadow: 0 0 8px rgba(41, 223, 241, 0.55);
}

.energy-metric-reading strong {
  display: block;
  color: #ffffff !important;
  font-size: clamp(1.6rem, 2vw, 2.15rem) !important;
  font-weight: 800 !important;
  line-height: 1 !important;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.energy-metric-reading span {
  display: block;
  min-height: 17px;
  color: #2edff0 !important;
  font-size: 0.82rem !important;
  line-height: 1.1;
  white-space: nowrap;
}

/* Adaptación sin deformar las tarjetas */
@media (max-width: 1180px) {
  .energy-metrics {
    grid-template-columns: repeat(3, minmax(150px, 1fr)) !important;
  }
}

@media (max-width: 700px) {
  .energy-metrics {
    grid-template-columns: repeat(2, minmax(135px, 1fr)) !important;
  }

  .energy-metric {
    min-height: 180px !important;
  }
}

@media (max-width: 430px) {
  .energy-metrics {
    grid-template-columns: 1fr !important;
  }
}
