/* ═══════════════════════════════════════════════════════════
   Energy flow — isometric scene, chips, inverter + self-sufficiency
   Loaded AFTER portal.css. Reuses .flow-card, .flow-card__header,
   .flow-card__title and .flow-card__time from portal.css.
═══════════════════════════════════════════════════════════ */

.flow-row {
  --chip-bg: #FFFFFF;
  --chip-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
  --tile-bg: rgba(15, 23, 42, 0.04);
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr);
  gap: var(--sp-5);
  margin-bottom: var(--sp-6);
  align-items: stretch;
}
[data-theme="dark"] .flow-row {
  --chip-bg: #182235;
  --chip-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
  --tile-bg: rgba(255, 255, 255, 0.05);
}
.flow-row > .flow-card { margin-bottom: 0; }

/* ── Scene card ─────────────────────────────────────────── */
.flow-card--scene {
  padding: var(--sp-5) var(--sp-6) var(--sp-4);
  display: flex;
  flex-direction: column;
}
.flow-card--scene .flow-card__header {
  align-items: flex-start;
  gap: var(--sp-4);
  margin-bottom: var(--sp-1);
}
.flow-card__sub {
  margin: 4px 0 0;
  font-size: var(--text-xs);
  color: var(--ink-500);
}
.flow-hero {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}
.flow-hero__main { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.flow-hero__val {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.flow-hero__lbl { font-size: var(--text-sm); color: var(--ink-500); }

.flow-stage {
  position: relative;
  width: 100%;
  max-width: 780px;
  aspect-ratio: 800 / 520;
  margin: auto;            /* centres the scene in any spare height */
}
.flow-stage svg.svx-scene {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* ── Chips (Corner badges matching SVG leader lines) ───── */
.flow-chips-wrap {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.flow-chip {
  position: absolute;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 6px 11px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  min-width: 84px;
  max-width: 124px;
  pointer-events: auto;
  box-sizing: border-box;
  cursor: default;
  transition: transform 0.2s, box-shadow 0.2s, background 0.3s, border-color 0.3s;
}

[data-theme="dark"] .flow-chip {
  background: rgba(18, 25, 40, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.13);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.flow-chip__top {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 2px;
  line-height: 1;
}

.flow-chip__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.3s, box-shadow 0.3s;
}

.flow-chip--grid .flow-chip__dot { background: #3B82F6; box-shadow: 0 0 6px rgba(59, 130, 246, 0.6); }
.flow-chip--grid.is-export .flow-chip__dot { background: #10B981; box-shadow: 0 0 6px rgba(16, 185, 129, 0.6); }
.flow-chip--pv .flow-chip__dot { background: #F59E0B; box-shadow: 0 0 6px rgba(245, 158, 11, 0.6); }
.flow-chip--batt .flow-chip__dot { background: #22C55E; box-shadow: 0 0 6px rgba(34, 197, 94, 0.6); }
.flow-chip--batt.is-discharging .flow-chip__dot { background: #EAB308; box-shadow: 0 0 6px rgba(234, 179, 8, 0.6); }
.flow-chip--batt.is-off .flow-chip__dot { background: #94A3B8; box-shadow: none; }
.flow-chip--load .flow-chip__dot { background: #8B5CF6; box-shadow: 0 0 6px rgba(139, 92, 246, 0.6); }

.flow-chip__label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-500);
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flow-chip__body {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

.flow-chip__val {
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flow-chip__arrow {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-400);
  line-height: 1;
  opacity: 0.55;
}

/* 4-Corner Positions (Mathematical match with SVG leader lines) */
.flow-chip--grid {
  left: 2.5%;
  top: 9%;
}

.flow-chip--pv {
  right: 2.5%;
  top: 9%;
}

.flow-chip--batt {
  left: 2.5%;
  top: 55%;
}

.flow-chip--load {
  right: 2.5%;
  top: 61%;
}

/* ── Side column ────────────────────────────────────────── */
.flow-side { display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; }
.flow-mini {
  padding: clamp(14px, 1.5vw, 20px);
  border-radius: 16px;
  background: var(--bg-card);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.07);
}
.flow-side #inverter-card { border-top: 2px solid var(--brand); }
.flow-side #selfsuff-card { border-top: 2px solid #3B82F6; }
.flow-side .flow-mini:first-child { flex: 1; }
.flow-side .flow-mini__head { gap: 10px; margin-bottom: var(--sp-4); }
.flow-side .flow-mini__title { font-size: 13px; letter-spacing: -0.01em; }
.flow-mini__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-3); }
.flow-mini__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--ink);
}
.flow-badge {
  font-size: 11px; font-weight: 600;
  padding: 3px 10px; border-radius: var(--radius-full);
  background: rgba(100, 116, 139, 0.14); color: var(--ink-500);
}
.flow-badge.is-line    { background: rgba(22, 163, 74, 0.14); color: #15803D; }
.flow-badge.is-solar   { background: rgba(245, 158, 11, 0.16); color: #B45309; }
.flow-badge.is-battery { background: rgba(99, 102, 241, 0.16); color: #4F46E5; }
[data-theme="dark"] .flow-badge.is-line    { background: rgba(34, 197, 94, 0.14); color: #86EFAC; }
[data-theme="dark"] .flow-badge.is-solar   { background: rgba(245, 158, 11, 0.14); color: #FCD34D; }
[data-theme="dark"] .flow-badge.is-battery { background: rgba(99, 102, 241, 0.16); color: #A5B4FC; }

.inv-main { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.inv-overline {
  display: block;
  margin-bottom: 5px;
  color: var(--ink-500);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.inv-big { font-family: var(--font-display); font-size: clamp(30px, 3vw, 40px); font-weight: 700; line-height: 1; color: var(--ink); letter-spacing: -0.045em; font-variant-numeric: tabular-nums; }
.inv-big small { font-size: var(--text-base); font-weight: 500; color: var(--ink-500); margin-left: 2px; }
.inv-sub { margin-top: 6px; font-size: var(--text-xs); color: var(--ink-500); }
.inv-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--sp-3); }
.inv-tile { background: transparent; border-top: 1px solid var(--glass-border); padding: 9px 0; display: flex; flex-direction: column; gap: 3px; }
.inv-tile span { font-size: 10px; color: var(--ink-500); }
.inv-tile b { font-family: var(--font-display); font-size: 12px; color: var(--ink); font-variant-numeric: tabular-nums; }
.inv-foot { margin-top: var(--sp-3); font-size: 11px; color: var(--ink-500); }

.ss-period { color: var(--ink-500); font-size: 9px; font-weight: 700; letter-spacing: 0.13em; }
.ss-summary { display: grid; grid-template-columns: minmax(0, .75fr) minmax(0, 1.25fr); gap: var(--sp-3); align-items: center; }
.ss-score { min-width: 0; }
.ss-score__value { display: block; color: var(--ink); font-family: var(--font-display); font-size: clamp(27px, 3vw, 36px); font-weight: 700; line-height: 1; letter-spacing: -0.045em; font-variant-numeric: tabular-nums; }
.ss-score__label { display: block; margin-top: 5px; color: var(--ink-500); font-size: 9.5px; line-height: 1.25; }
.ss-details { min-width: 0; }
.ss-details p { margin: 0 0 10px; color: var(--ink-500); font-size: 10.5px; line-height: 1.4; }
.ss-progress { height: 6px; overflow: hidden; border-radius: var(--radius-full); background: var(--ink-100); }
.ss-progress__fill { display: block; width: 0; height: 100%; border-radius: inherit; background: #197A40; transition: width 0.7s var(--ease-out); }
[data-theme="dark"] .ss-progress__fill { background: #4ADE80; }
.ss-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--sp-3); margin-top: var(--sp-4); }
.ss-row { min-width: 0; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; border-top: 1px solid var(--glass-border); padding: 9px 0 0; font-size: 10px; color: var(--ink-500); }
.ss-row b { color: var(--ink); font-family: var(--font-display); font-size: 11px; font-variant-numeric: tabular-nums; }

/* ── Progress rings ─────────────────────────────────────── */
.ring { position: relative; flex-shrink: 0; }
.ring--sm { width: 84px; height: 84px; }
.ring--lg { width: 108px; height: 108px; }
.ring svg { display: block; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring__bg { fill: none; stroke: var(--ink-100); stroke-width: 9; }
.ring__fg {
  fill: none; stroke: #F59E0B; stroke-width: 9; stroke-linecap: round;
  stroke-dasharray: 0 1000;
  transition: stroke-dasharray 0.8s var(--ease-out), stroke 0.3s;
}
.ring__fg--brand { stroke: var(--brand); }
.ring__fg.is-high { stroke: #EF4444; }
.ring__txt {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; line-height: 1.1;
}
.ring__txt b { font-family: var(--font-display); font-size: var(--text-base); color: var(--ink); }
.ring__txt span { font-size: 9.5px; color: var(--ink-500); }
.ring__txt .ring__big { font-size: 19px; letter-spacing: -0.02em; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1000px) {
  .flow-row { grid-template-columns: 1fr; }
  .flow-side { display: grid; grid-template-columns: 1fr 1fr; }
  .flow-side .flow-mini:first-child { flex: none; }
}
@media (max-width: 640px) {
  .flow-side { grid-template-columns: 1fr; }
  .flow-mini { padding: var(--sp-4); }
  .flow-card--scene { padding: var(--sp-4); }
  .flow-card--scene .flow-card__header { flex-direction: column; align-items: flex-start; gap: var(--sp-2); }
  .flow-hero { align-items: flex-start; }
  .ring--lg { width: 96px; height: 96px; }
  .flow-hero__val { font-size: var(--text-2xl); }

  .flow-stage {
    max-width: 100%;
    aspect-ratio: 800 / 520;
    margin: 0 auto;
  }
  .flow-chip {
    padding: 4px 7px;
    min-width: 68px;
    max-width: 96px;
    border-radius: 11px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  }
  .flow-chip__dot {
    width: 5px;
    height: 5px;
  }
  .flow-chip__label {
    font-size: 9px;
  }
  .flow-chip__val {
    font-size: 11.5px;
  }
  .flow-chip__arrow {
    font-size: 11px;
  }
  .flow-chip--grid {
    left: 1.5%;
    top: 7%;
  }
  .flow-chip--pv {
    right: 1.5%;
    top: 7%;
  }
  .flow-chip--batt {
    left: 1.5%;
    top: 54%;
  }
  .flow-chip--load {
    right: 1.5%;
    top: 60%;
  }
}

@media (max-width: 380px) {
  .ss-summary { grid-template-columns: minmax(0, .65fr) minmax(0, 1.35fr); }
  .ss-metrics { gap: 0 var(--sp-2); }
  .ss-row { font-size: 9px; }
  .flow-chip {
    padding: 3px 6px;
    min-width: 60px;
    max-width: 82px;
    border-radius: 9px;
  }
  .flow-chip__label {
    font-size: 8px;
  }
  .flow-chip__val {
    font-size: 10.5px;
  }
  .flow-chip__arrow {
    display: none;
  }
  .flow-chip--grid {
    left: 1%;
    top: 5%;
  }
  .flow-chip--pv {
    right: 1%;
    top: 5%;
  }
  .flow-chip--batt {
    left: 1%;
    top: 55%;
  }
  .flow-chip--load {
    right: 1%;
    top: 62%;
  }
}
