:root {
  --bg: #0e1115;
  --bg-card: rgba(255, 255, 255, 0.028);
  --line: rgba(255, 255, 255, 0.10);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #eef2f6;
  --text-soft: #b8c0cb;
  --text-dim: #8b95a3;
  --shadow: 0 18px 38px rgba(0, 0, 0, 0.28);

  --pv: #e3cc96;
  --pv-soft: #c4a8ee;
  --load: #a8c4ee;
  --battery: #a9d8b8;
  --grid: #d9b6c0;

  --ok: #93d3a5;
  --warn: #f0cf8f;
  --bad: #df9e9e;

  --radius: 0px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(227, 204, 150, 0.05), transparent 26%),
    radial-gradient(circle at bottom right, rgba(168, 196, 238, 0.06), transparent 28%),
    linear-gradient(180deg, #12151a 0%, #0b0d10 100%);
}

*::before,
*::after { box-sizing: border-box; }

.metric-value,
.fact-card strong,
.soc-capacity-chip strong,
.soc-status-line strong,
.stat-tile strong,
.string-card strong,
.phase-card strong,
.summary-tile strong,
.insight-card strong,
.soc-number {
  white-space: nowrap;
}

.app-shell {
  width: min(1540px, calc(100% - 34px));
  margin: 0 auto;
  padding: 20px 0 34px;
}

.hero,
.panel,
.hero-side-card,
.metric-card,
.insight-card,
.soc-card,
.fact-card,
.soc-fact,
.stat-tile,
.string-card,
.phase-card,
.summary-tile {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.035), rgba(255,255,255,0.016));
  box-shadow: var(--shadow);
}

.hero,
.panel,
.hero-side-card,
.metric-card,
.insight-card,
.soc-card,
.fact-card,
.soc-fact,
.stat-tile,
.string-card,
.phase-card,
.summary-tile,
.metric-badge,
.status-pill {
  border-radius: var(--radius);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  padding: 20px;
  margin-bottom: 16px;
}

.hero-copy-wrap { max-width: 960px; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--text-dim);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 12px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(28px, 3.7vw, 44px);
  line-height: 1.02;
}

.hero-copy {
  margin: 10px 0 0;
  color: var(--text-soft);
  line-height: 1.6;
}

.hero-side-card {
  min-width: 240px;
  width: 240px;
  padding: 12px;
  display: grid;
  gap: 10px;
  align-content: start;
}

.hero-side-box {
  display: grid;
  gap: 8px;
}

.hero-side-label {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1;
}

.status-pill,
.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  width: 100%;
  min-height: 42px;
  justify-content: center;
  color: var(--text-soft);
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,0.04);
}

.status-pill .label,
.meta-pill span {
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 16px currentColor;
}

.status-pill.online .dot { background: var(--ok); }
.status-pill.offline .dot { background: var(--bad); }

#lastUpdate {
  display: inline-block;
}

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

.panel {
  padding: 18px;
}

.panel-overview { grid-column: 1 / -1; }
.panel-battery { grid-column: span 4; }
.panel-energy { grid-column: span 4; }
.panel-strings { grid-column: span 4; }
.panel-load { grid-column: span 6; }
.panel-grid { grid-column: span 6; }

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  margin-bottom: 14px;
}
.panel-head h2 { margin: 0; font-size: 18px; }
.panel-head p { margin: 4px 0 0; color: var(--text-dim); font-size: 13px; }

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

.metric-card {
  padding: 16px;
  min-height: 196px;
  overflow: hidden;
}

.metric-pv {
  background: linear-gradient(180deg, rgba(227,204,150,0.50), rgba(255,255,255,0.018));
}
.metric-pv-soft {
  background: linear-gradient(180deg, rgba(196,168,238,0.50), rgba(255,255,255,0.018));
}
.metric-load {
  background: linear-gradient(180deg, rgba(168,196,238,0.50), rgba(255,255,255,0.018));
}
.metric-grid {
  background: linear-gradient(180deg, rgba(217,182,192,0.50), rgba(255,255,255,0.018));
}

.metric-top,
.phase-card div,
.string-card div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.metric-top {
  color: var(--text-soft);
  font-size: 13px;
}

.metric-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 5px 10px;
  min-width: 84px;
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,0.05);
  font-size: 12px;
  color: var(--text-soft);
  white-space: nowrap;
}
.metric-badge.neutral { color: var(--text-dim); }

.metric-value {
  margin-top: 16px;
  font-size: clamp(30px, 3vw, 44px);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.metric-sub {
  margin-top: 4px;
  color: var(--text-dim);
  font-size: 13px;
}

.metric-foot {
  margin-top: 22px;
  color: var(--text-soft);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sparkline {
  width: 100%;
  height: 44px;
  margin-top: 18px;
}

.sparkline path {
  fill: none;
  stroke: rgba(255,255,255,0.94);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

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

.insight-card {
  padding: 14px 16px;
  min-height: 84px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.insight-wide { grid-column: span 2; }

.insight-card span {
  color: var(--text-dim);
  font-size: 13px;
}

.insight-card strong {
  font-size: 22px;
  line-height: 1.15;
}

.battery-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.soc-card {
  padding: 16px;
  background: linear-gradient(180deg, rgba(169,216,184,0.50), rgba(255,255,255,0.018));
  display: grid;
  gap: 14px;
  min-width: 0;
  align-content: start;
}

.soc-ring {
  --soc: 0;
  width: 180px;
  height: 180px;
  margin: 0 auto;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #12151a 60%, transparent 61%),
    conic-gradient(var(--battery) calc(var(--soc) * 1%), rgba(255,255,255,0.12) 0);
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}

.soc-ring-inner { text-align: center; }
.soc-number {
  display: block;
  font-size: 34px;
  font-weight: 700;
}
.soc-ring-inner small { color: var(--text-dim); }

.soc-capacity-chip,
.soc-status-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  background: rgba(11, 13, 16, 0.22);
}

.soc-capacity-chip span,
.soc-status-line span,
.stat-tile span,
.string-card span,
.phase-card span,
.summary-tile span {
  color: var(--text-dim);
  font-size: 13px;
}

.soc-capacity-chip strong,
.soc-status-line strong,
.summary-tile strong,
.phase-card strong,
.string-card strong {
  font-size: 18px;
}

.battery-side {
  display: grid;
  gap: 12px;
  align-content: start;
}

.battery-stack {
  grid-template-columns: 1fr;
}

.fact-card,
.stat-tile,
.string-card,
.phase-card,
.summary-tile {
  padding: 14px;
}

.battery-fact-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  min-height: 64px;
}

.battery-fact-card span {
  color: var(--text-dim);
  font-size: 13px;
}

.battery-fact-card strong {
  font-size: 22px;
}

.stat-tile {
  min-height: 88px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
}

.stat-tile strong {
  margin-top: 12px;
  font-size: 26px;
}

.battery-tile {
  min-height: 146px;
  justify-content: center;
}

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

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

.string-card,
.phase-card {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.string-card h3,
.phase-card h3 {
  margin: 0 0 2px;
  font-size: 17px;
}

.string-card div,
.phase-card div {
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.summary-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.summary-row.single {
  grid-template-columns: minmax(0, 1fr);
}

.summary-tile {
  min-height: 74px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
}

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

.phase-card {
  min-height: 154px;
}

@media (max-width: 1260px) {
  .panel-battery,
  .panel-energy,
  .panel-strings,
  .panel-load,
  .panel-grid {
    grid-column: 1 / -1;
  }

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

  .insight-wide {
    grid-column: span 2;
  }
}

@media (max-width: 900px) {
  .app-shell { width: min(100% - 20px, 1540px); }
  .hero { grid-template-columns: 1fr; }
  .hero-side-card { min-width: 0; }

  .overview-grid,
  .insight-grid,
  .battery-layout,
  .battery-side,
  .stats-grid,
  .string-grid,
  .phase-grid {
    grid-template-columns: 1fr;
  }

  .insight-wide {
    grid-column: span 1;
  }

  .summary-row {
    grid-template-columns: 1fr;
  }

  .soc-ring {
    width: 170px;
    height: 170px;
  }
}
