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

:root {
  --teal: #1D9E75;
  --teal-light: #E1F5EE;
  --teal-mid: #5DCAA5;
  --teal-dark: #085041;
  --navy: #0D1B2A;
  --slate: #4A6580;
  --amber: #F5A623;
  --red: #E24B4A;
  --surface: #F0F4F8;
  --border: rgba(0,0,0,0.1);
  --text: #0D1B2A;
  --text-muted: #4A6580;
  --text-faint: #8FA3B5;
  --white: #ffffff;
  --radius: 8px;
  --radius-lg: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface: #111C27;
    --border: rgba(255,255,255,0.1);
    --text: #E8F0F7;
    --text-muted: #8FA3B5;
    --text-faint: #4A6580;
    --white: #182535;
    --navy: #E8F0F7;
  }
}

body {
  font-family: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Layout ── */
.app-header {
  background: var(--navy);
  color: #E8F0F7;
  padding: 0 2rem;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.app-header .logo { font-size: 15px; font-weight: 600; letter-spacing: -0.02em; color: #fff; }
.app-header .logo span { color: var(--teal-mid); }
.app-header .network-badge {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-faint);
  background: rgba(255,255,255,0.07);
  padding: 4px 10px;
  border-radius: 99px;
}

.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: calc(100vh - 56px);
}

/* ── Sidebar ── */
.sidebar {
  background: var(--white);
  border-right: 0.5px solid var(--border);
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow-y: auto;
}

.section-head {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 10px;
}

.field { margin-bottom: 10px; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.field input:not([type=checkbox]), .field select {
  width: 100%;
  padding: 7px 10px;
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
.field input:not([type=checkbox]):focus, .field select:focus { border-color: var(--teal); }
.field input[type=checkbox] {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--teal);
  cursor: pointer;
}
.field select {
  width: 100%;
}
.gst-toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
  cursor: pointer;
}
.radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
}
.field .hint { font-size: 11px; color: var(--text-faint); margin-top: 3px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.icp-lookup-row {
  grid-template-columns: 1fr auto;
  align-items: center;
}
.icp-lookup-row .action-btn {
  white-space: nowrap;
}
.radio-inline-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
}
.radio-inline-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
  cursor: pointer;
}
/* ── Tariff rows ── */
.tariff-header {
  display: grid;
  grid-template-columns: 72px 72px 1fr 28px;
  gap: 6px;
  font-size: 11px;
  color: var(--text-faint);
  padding: 0 0 4px 0;
}
.tariff-row {
  display: grid;
  grid-template-columns: 72px 72px 1fr 28px;
  gap: 6px;
  align-items: center;
  margin-bottom: 5px;
}
.tariff-row input {
  padding: 5px 7px;
  font-size: 12px;
}
.del-btn {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 4px;
  border-radius: var(--radius);
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.del-btn:hover { color: var(--red); background: #FCEBEB; }
.add-tariff-btn {
  width: 100%;
  padding: 7px;
  background: none;
  border: 0.5px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  transition: background 0.15s;
}
.add-tariff-btn:hover { background: var(--surface); }

/* ── Plan picker ── */
.plan-toggle-btn {
  font-size: 11px;
  color: var(--teal);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  font-weight: 600;
}
.plan-toggle-btn:hover { text-decoration: underline; }
.plan-toggle-btn.is-active {
  text-decoration: underline;
  color: var(--text);
}
.action-btn {
  font-size: 11px;
  font-weight: 600;
  color: var(--teal);
  background: none;
  border: 1px solid var(--teal);
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
}
.action-btn:hover {
  background: rgba(93, 202, 165, 0.12);
}
.plan-check-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
  padding: 6px 0;
  cursor: pointer;
  border-bottom: 0.5px solid var(--border);
  user-select: none;
}
.plan-check-label.is-current-plan {
  background: rgba(93, 202, 165, 0.08);
}
.plan-check-label:last-child { border-bottom: none; }
.plan-compare-option {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}
.plan-compare-option span {
  flex: 1;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
}
.plan-check-label input[type=checkbox] {
  width: 14px;
  height: 14px;
  accent-color: var(--teal);
  flex-shrink: 0;
  cursor: pointer;
}

/* ── Run button ── */
.run-btn {
  width: 100%;
  padding: 11px;
  background: var(--teal);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  transition: opacity 0.15s;
  letter-spacing: 0.01em;
}
.run-btn:hover { opacity: 0.88; }
.run-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Main panel ── */
.main {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow-y: auto;
}

/* ── Metric cards ── */
.results-context {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 2px;
}
.gst-mode-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--teal-dark);
  background: var(--teal-light);
  border: 0.5px solid rgba(8, 80, 65, 0.2);
}
.gst-results-toggle {
  font-size: 12px;
  color: var(--text-muted);
}

.optimized-controls {
  display: grid;
  gap: 6px;
  margin: 2px 0 10px;
}

.optimized-controls-title {
  font-size: 12px;
  color: var(--text-muted);
}

.optimized-controls span {
  font-size: 12px;
  color: var(--text);
  min-width: 120px;
  text-align: right;
}

.optimized-sweet-spot-control {
  margin-top: 2px;
  display: grid;
  gap: 6px;
}

.optimized-sweet-spot-row {
  display: grid;
  grid-template-columns: 120px 1fr 120px;
  align-items: center;
  gap: 10px;
}

.optimized-sweet-spot-row span {
  min-width: 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 11px;
}

.optimized-dual-range {
  position: relative;
  height: 40px;
  display: flex;
  align-items: center;
}

.optimized-dual-range-thumb-value {
  position: absolute;
  top: -8px;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--text);
  background: var(--white);
  border: 0.5px solid var(--border);
  border-radius: 999px;
  padding: 1px 6px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 4;
}

.optimized-dual-range-track,
.optimized-dual-range-fill {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 4px;
  transform: translateY(-50%);
  border-radius: 999px;
}

.optimized-dual-range-track {
  background: rgba(143, 163, 181, 0.35);
}

.optimized-dual-range-fill {
  left: 0;
  right: auto;
  width: 100%;
  background: var(--teal);
}

.optimized-dual-range input[type=range] {
  position: absolute;
  left: 0;
  width: 100%;
  margin: 0;
  background: none;
  -webkit-appearance: none;
  appearance: none;
  pointer-events: none;
}

.optimized-dual-range input[type=range]::-webkit-slider-runnable-track {
  height: 4px;
  background: transparent;
}

.optimized-dual-range input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  pointer-events: auto;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--white);
  border: 2px solid var(--teal);
  margin-top: -5px;
  cursor: pointer;
}

.optimized-dual-range input[type=range]::-moz-range-track {
  height: 4px;
  background: transparent;
}

.optimized-dual-range input[type=range]::-moz-range-thumb {
  pointer-events: auto;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--white);
  border: 2px solid var(--teal);
  cursor: pointer;
}

#optimized-sweet-spot-threshold {
  width: 100%;
  accent-color: var(--teal);
}

.optimized-sweet-spot-value {
  justify-self: end;
  font-size: 12px;
  color: var(--text);
  font-weight: 600;
}

.optimized-hidden-control {
  display: none;
}

.optimized-chart-card {
  margin-bottom: 20px;
  padding: 14px;
  border-radius: 10px;
  border: 0.5px solid var(--border);
  background:
    radial-gradient(120% 120% at 100% 0%, rgba(29, 158, 117, 0.12), transparent 52%),
    var(--surface);
}

.optimized-chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.optimized-chart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.optimized-chart-subtitle {
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-muted);
}

.optimized-chart-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.optimized-chart-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border: 0.5px solid var(--border);
  border-radius: 999px;
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.5);
}

.optimized-chart-canvas-wrap {
  position: relative;
  width: 100%;
  height: 240px;
}

.optimized-chart-canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.sweet-spot-summary {
  margin-bottom: 15px;
  padding: 12px;
  background: rgba(212, 241, 165, 0.15);
  border-left: 3px solid #a5d47a;
  border-radius: 4px;
}

.sweet-spot-summary-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

.sweet-spot-summary-body {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

.sweet-spot-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.sweet-spot-item {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  position: relative;
  padding: 10px 12px;
  border: 0.5px solid rgba(90, 122, 0, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}
.sweet-spot-item-current {
  border-color: rgba(29, 158, 117, 0.55);
  box-shadow: 0 0 0 1px rgba(29, 158, 117, 0.18);
  background: rgba(93, 202, 165, 0.12);
}

.sweet-spot-copy {
  min-width: 0;
  flex: 1 1 auto;
}

.sweet-spot-rank {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(29, 158, 117, 0.12);
  color: var(--teal-dark);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sweet-spot-current-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(29, 158, 117, 0.2);
  color: #0f5c45;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sweet-spot-name {
  padding-right: 84px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.sweet-spot-meta {
  margin-top: 2px;
  padding-right: 84px;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 14px;
}

.sweet-spot-meta .sweet-spot-stat {
  min-width: 86px;
}

.sweet-spot-capacity {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 20px;
  line-height: 1;
  font-weight: 700;
  color: var(--text);
}

.sweet-spot-capacity i {
  font-size: 1em;
  line-height: 1;
  color: var(--teal-mid);
}

.sweet-spot-meta-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 2px;
  min-width: 0;
}

.sweet-spot-meta-line {
  white-space: nowrap;
  line-height: 1.2;
}

.sweet-spot-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px 10px;
  margin-top: 8px;
}

.sweet-spot-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.ss-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}

.ss-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.ss-value-nowrap {
  white-space: nowrap;
}

.ss-value.saving {
  color: var(--teal);
}

.ss-value.saving-swapped {
  color: var(--text);
}

.ss-value.with-battery-swapped {
  color: var(--teal);
}

.ss-value-vs-save {
  color: var(--teal);
}

.ss-value-vs-more {
  color: var(--red);
}

.ss-value-vs-neutral {
  color: var(--text-muted);
}

.sweet-spot-action {
  position: absolute;
  top: 10px;
  right: 12px;
  flex-shrink: 0;
  align-self: auto;
  margin-left: 0;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.metric {
  background: var(--white);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}
.metric .m-label { font-size: 11px; color: var(--text-faint); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em; }
.metric .m-value { font-size: 24px; font-weight: 500; color: var(--text); line-height: 1; }
.metric .m-sub { font-size: 11px; color: var(--text-faint); margin-top: 4px; }
.metric.accent .m-value { color: var(--teal); }
.metric-summary {
  grid-column: 1 / -1;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.45;
}
.metric-summary strong {
  color: var(--text);
  font-weight: 600;
}

/* ── Panels ── */
.panel {
  background: var(--white);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}
.panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 7px;
}
.panel-title i { color: var(--teal); }

/* ── Battery config panel (controls + stats side by side) ── */
.bat-config-layout {
  display: block;
  padding: 12px;
}
.bat-config-controls { display: flex; flex-direction: column; gap: 8px; }
.bat-advanced {
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 8px 10px;
}
.bat-advanced > summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  list-style: none;
}
.bat-advanced > summary::-webkit-details-marker {
  display: none;
}
.bat-advanced > summary::before {
  content: '▸';
  margin-right: 6px;
  color: var(--text-faint);
}
.bat-advanced[open] > summary::before {
  content: '▾';
}
.bat-advanced .field-row {
  margin-top: 8px;
}
.bat-config-layout .bat-stats {
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
}

/* ── Battery viz ── */
.battery-wrap { display: flex; align-items: center; gap: 20px; }
.battery-shell {
  width: 160px;
  height: 52px;
  border: 2px solid var(--border);
  border-radius: 7px;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.battery-shell::after {
  content: '';
  position: absolute;
  right: -9px;
  top: 50%;
  transform: translateY(-50%);
  width: 7px;
  height: 22px;
  background: var(--border);
  border-radius: 0 4px 4px 0;
}
.battery-fill {
  height: 100%;
  background: var(--teal);
  border-radius: 5px;
  width: 0%;
  transition: width 1s ease;
}
.battery-fill.low { background: var(--blue); }
.battery-fill.empty { background: var(--teal); }
.battery-pct-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
  pointer-events: none;
}
.battery-caption { font-size: 11px; color: var(--text-faint); margin-top: 5px; text-align: center; }
.bat-stats { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.bat-stat {
  padding: 7px 10px;
  border-bottom: 0.5px solid var(--border);
  border-right: 0.5px solid var(--border);
  font-size: 12px;
}
.bat-stat:nth-child(2n) { border-right: none; }
.bat-stat:nth-last-child(-n+2) { border-bottom: none; }
.bat-stat .bs-key { color: var(--text-faint); margin-bottom: 2px; }
.bat-stat .bs-val { font-weight: 500; color: var(--text); }

/* ── Tabs ── */
.tabs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 0.5px solid var(--border);
  margin-bottom: 1rem;
}
.tabs-left {
  display: flex;
  gap: 0;
  min-width: 0;
}
.tabs-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  padding-bottom: 6px;
}
.tab-btn {
  padding: 7px 14px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s;
}
.tab-btn.active { color: var(--teal); border-bottom-color: var(--teal); font-weight: 600; }
.tab-btn:hover:not(.active) { color: var(--text); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Rankings table ── */
.rankings-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rankings-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 10px 10px;
  border-bottom: 0.5px solid var(--border);
}
.rankings-table td { padding: 10px; border-bottom: 0.5px solid var(--border); }
.rankings-table tr:last-child td { border-bottom: none; }
.rankings-table tr.winner td { background: var(--teal-light); }
.rankings-table tr.winner td:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.rankings-table tr.winner td:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.rank-num { font-weight: 600; color: var(--text-faint); }
.rank-num.first { color: var(--teal-dark); }
.supplier-name { font-weight: 500; }
.plan-name { font-size: 12px; color: var(--text-muted); }
.plan-detail { font-size: 11px; color: var(--text-faint); margin-top: 3px; }
.th-note { font-size: 10px; font-weight: 400; color: var(--text-faint); display: block; margin-top: 2px; }
.cost-delta { display: block; font-size: 11px; font-weight: 400; color: var(--text-faint); margin-top: 2px; }
.cost-cell { font-weight: 500; }
.no-battery-cell { color: var(--text-faint); }
.saving-cell { color: var(--teal); font-weight: 500; }
.swapped-saving-cell { color: var(--text); }
.swapped-with-battery-cell { color: var(--teal); font-weight: 500; }
.saving-cell-with-action {
  white-space: normal;
}
.saving-cell-with-action > span {
  display: block;
  white-space: nowrap;
}
.saving-cell-with-action .action-btn {
  display: inline-block;
  margin-top: 6px;
  margin-left: 0;
}
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 99px;
}
.badge.best { background: #9FE1CB; color: var(--teal-dark); }
.badge.flat { background: var(--surface); color: var(--text-faint); }
.elbow-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 99px;
  border: 0.5px solid #f1d47a;
  background: #fff4cc;
  color: #7a5a00;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
}
.sweet-spot-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 99px;
  border: 0.5px solid #d4f1a5;
  background: #f4ffcc;
  color: #5a7a00;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
}

/* ── Monthly bars ── */
.monthly-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; align-items: flex-end; }
.month-col { text-align: center; }
.month-bar-wrap { height: 80px; display: flex; align-items: flex-end; justify-content: center; }
.month-bar { width: 100%; background: var(--teal-mid); border-radius: 3px 3px 0 0; min-height: 4px; transition: height 0.6s ease; }
.month-bar.winter { background: var(--teal); }
.month-label { font-size: 10px; color: var(--text-faint); margin-top: 4px; }
.month-val { font-size: 11px; font-weight: 500; color: var(--text-muted); margin-top: 2px; }

/* ── Insights ── */
.insight-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 0.5px solid var(--border);
  font-size: 13px;
  gap: 12px;
}
.insight-row:last-child { border-bottom: none; }
.insight-key { color: var(--text-muted); flex-shrink: 0; }
.insight-val { font-weight: 500; text-align: right; }
.insight-val.positive { color: var(--teal); }
.insights-top-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.88fr);
  gap: 14px;
  align-items: start;
}
.insights-summary-panel {
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--white);
  overflow: hidden;
}
.insights-summary-table-wrap {
  padding: 8px 10px 0;
  overflow-x: auto;
}
.insights-summary-table {
  table-layout: auto;
  min-width: 760px;
}
.insights-summary-table th {
  white-space: normal;
}
.insights-summary-table td {
  white-space: normal;
  vertical-align: top;
}
@media (min-width: 1200px) {
  .insights-summary-table th:first-child,
  .insights-summary-table td:first-child {
    width: 34%;
  }
  .insights-summary-table th:nth-child(2),
  .insights-summary-table td:nth-child(2),
  .insights-summary-table th:nth-child(3),
  .insights-summary-table td:nth-child(3),
  .insights-summary-table th:nth-child(4),
  .insights-summary-table td:nth-child(4),
  .insights-summary-table th:nth-child(5),
  .insights-summary-table td:nth-child(5),
  .insights-summary-table th:nth-child(6),
  .insights-summary-table td:nth-child(6) {
    width: 13%;
    white-space: nowrap;
  }
}
.insights-rankings-panel {
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--white);
  overflow: hidden;
}
.insights-rankings-table {
  width: 96%;
  margin: 0 auto;
}
.insights-rankings-table th:first-child,
.insights-rankings-table td:first-child {
  min-width: 280px;
}
.insights-rankings-table th:nth-child(2),
.insights-rankings-table th:nth-child(3),
.insights-rankings-table th:nth-child(4),
.insights-rankings-table td:nth-child(2),
.insights-rankings-table td:nth-child(3),
.insights-rankings-table td:nth-child(4) {
  width: 118px;
  white-space: nowrap;
}
.insights-rankings-table td:nth-child(2),
.insights-rankings-table td:nth-child(3),
.insights-rankings-table td:nth-child(4) {
  vertical-align: top;
}
.insights-summary-panel .insight-row {
  padding-left: 12px;
  padding-right: 12px;
}
.insights-installer-promo {
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(165deg, #f8fff8 0%, #eef8ff 100%);
  padding: 16px;
  display: grid;
  gap: 10px;
}
.insights-installer-promo-media {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.7);
  border: 0.5px solid rgba(29, 158, 117, 0.18);
}
.insights-installer-promo-icon-wrap {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #1d9e75 0%, #5dcaa5 100%);
  color: #fff;
  flex-shrink: 0;
}
.insights-installer-promo-icon-wrap i {
  font-size: 22px;
  line-height: 1;
}
.insights-installer-promo-chip {
  padding: 3px 8px;
  border-radius: 999px;
  border: 0.5px solid rgba(90, 122, 0, 0.22);
  background: #fff;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}
.insights-installer-promo-eyebrow {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--teal-dark);
}
.insights-installer-promo-title {
  margin: 0;
  font-size: 20px;
  line-height: 1.1;
  color: var(--text);
}
.insights-installer-promo-copy {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
}
.insights-installer-promo-cta {
  justify-self: start;
}
.insights-rankings-body {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 420px;
  padding: 8px 10px;
}

/* ── Best case recommendation ── */
.bestcase-compare-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.bestcase-card {
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  padding: 14px;
}
.bestcase-title {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 6px;
}
.bestcase-headline {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.bestcase-summary {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 10px;
}
.bestcase-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.bestcase-item {
  border: 0.5px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  padding: 8px 10px;
  display: grid;
  gap: 3px;
}
.bestcase-item span {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}
.bestcase-item strong {
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
}
.bestcase-note {
  font-size: 12px;
  color: var(--text-muted);
  border-top: 0.5px solid var(--border);
  padding-top: 8px;
}

/* ── Energy infographic ── */
.energy-infographic {
  margin-top: 12px;
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--white);
  overflow: hidden;
}
.info-title {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border-bottom: 0.5px solid var(--border);
}
.info-note {
  padding: 10px 14px;
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.5;
  background: var(--white);
  border-bottom: 0.5px solid var(--border);
}
.info-block {
  padding: 10px 14px;
  border-bottom: 0.5px solid var(--border);
}
.info-block:last-child { border-bottom: none; }
.info-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.info-arrows {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 10px;
  color: var(--text-faint);
}
.info-arrows span {
  white-space: normal;
}
.stack-bar {
  width: 100%;
  height: 22px;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  background: var(--surface);
  border: 0.5px solid var(--border);
}
.seg {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.seg-label {
  display: inline-block;
  padding: 0 6px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
  white-space: nowrap;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}
.seg-grid { background: #d97706; }
.seg-battery { background: var(--teal); }
.seg-peak-grid { background: #4b79b1; }
.seg-charge { background: var(--teal); }
.seg-peak-grid .seg-label {
  color: #fff;
}
.info-meta {
  margin-top: 7px;
  font-size: 11px;
  color: var(--text-faint);
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.info-meta-grid-blue {
  color: #4b79b1;
}

/* ── TOU infographic ── */
.tou-infographic {
  margin-top: 12px;
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--white);
  overflow: hidden;
}
.tou-infographic-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px 0;
}
.tou-infographic-head .info-title {
  margin-bottom: 0;
  flex: 1 1 auto;
}
.tou-infographic-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 6px 12px 0;
}
.tou-band-captions {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  font-size: 10px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.tou-day-type-label {
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.tou-day-type-control-static .tou-day-type-static {
  font-size: 12px;
  color: var(--text-muted);
  padding-top: 4px;
}
.tou-grid {
  padding: 8px 12px;
  display: grid;
  gap: 10px;
}
.timeline-band-captions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 6px;
  font-size: 10px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.tou-24h-wrap {
  padding: 10px 12px 8px;
}
.tou-24h-wrap + .info-block,
.tou-24h-wrap + .tou-legend {
  margin-top: 0;
}
.tou-subhead {
  font-size: 10px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.tou-24h-line {
  width: 100%;
  height: 24px;
  border-radius: 999px;
  border: 0.5px solid var(--border);
  overflow: hidden;
  display: flex;
  background: var(--surface);
}
.tou-slot {
  flex: 1 1 0;
  height: 100%;
  display: block;
  border-right: none;
}
.tou-slot:last-child { border-right: none; }
.tou-slot-fill {
  height: 100%;
  width: 100%;
}
.tou-slot-fill.peak { background: #e39a3e; }
.tou-slot-fill.shoulder { background: #6f98c8; }
.tou-slot-fill.cheap { background: #39b58a; }
.tou-24h-ticks {
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-faint);
}
.tou-source-key {
  margin-top: 6px;
  display: flex;
  gap: 14px;
  font-size: 10px;
  color: var(--text-faint);
}
.tou-load-bars {
  margin-top: 6px;
  height: 68px;
  border: 0.5px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.04), transparent 60%);
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}
.tou-load-col {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
}
.tou-load-grid,
.tou-load-battery {
  width: 100%;
}
.tou-load-grid {
  background: #5f7f9d;
}
.tou-load-battery {
  background: var(--teal);
}
.tou-key-chip.key-load-line {
  background: #183a5a;
}
.timeline-combined-wrap {
  padding: 0 12px 10px;
}
.timeline-band-captions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 6px;
  font-size: 10px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.timeline-line-key {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 6px;
  font-size: 10px;
  color: var(--text-muted);
}
.timeline-line-key-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.timeline-line-key-swatch {
  width: 16px;
  height: 0;
  border-top: 3px solid transparent;
  border-radius: 999px;
  display: inline-block;
}
.timeline-line-key-swatch.grid {
  border-top-color: #4b79b1;
}
.timeline-line-key-swatch.forecast {
  border-top-color: #1d4f8c;
  border-top-style: dashed;
}
.timeline-frame {
  display: block;
}
.timeline-combined {
  border: 0.5px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}
.timeline-band {
  display: flex;
  align-items: flex-end;
  width: 100%;
}
.timeline-band-labels {
  align-items: stretch;
  min-height: 22px;
  background: rgba(0, 0, 0, 0.015);
  border-bottom: 0.5px solid var(--border);
}
.timeline-period-label {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  min-width: 0;
  padding: 2px 6px;
  font-size: 11px;
  line-height: 1.1;
  color: var(--text-muted);
  border-right: 0.5px solid rgba(0, 0, 0, 0.04);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.timeline-period-label:last-child {
  border-right: none;
}
.timeline-period-label.peak {
  background: rgba(215, 139, 46, 0.24);
}
.timeline-period-label.shoulder {
  background: rgba(75, 121, 177, 0.22);
}
.timeline-period-label.cheap {
  background: rgba(57, 181, 138, 0.24);
}
.timeline-period-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}
.timeline-period-rate {
  font-size: 10px;
  color: var(--text-faint);
}
.timeline-band-soc {
  position: relative;
  height: 60px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.03), transparent 60%);
}
.soc-edge-labels {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}
.soc-edge-label {
  position: absolute;
  left: 6px;
  padding: 1px 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(70, 85, 102, 0.10);
  color: var(--text-muted);
  font-size: 8px;
  line-height: 1;
}
.soc-edge-label.top {
  top: 4px;
}
.soc-edge-label.bottom {
  bottom: 4px;
}
.soc-edge-label-pct {
  font-weight: 600;
}
.timeline-load-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  pointer-events: none;
}
.timeline-load-line {
  fill: none;
  stroke: #1d4f8c;
  stroke-width: 2;
  stroke-dasharray: 6 3;
  vector-effect: non-scaling-stroke;
  shape-rendering: geometricPrecision;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.35));
}
.timeline-grid-consumption-line {
  fill: none;
  stroke: #4b79b1;
  stroke-width: 2.8;
  vector-effect: non-scaling-stroke;
  shape-rendering: geometricPrecision;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.5));
}
.soc-24h-line {
  width: 100%;
  height: 72px;
  border: 0.5px solid var(--border);
  border-radius: 8px;
  background:
    linear-gradient(to top, rgba(0, 0, 0, 0.03), transparent 60%),
    linear-gradient(to right, transparent 0 24.5%, rgba(0, 0, 0, 0.035) 24.5% 25%, transparent 25% 49.5%, rgba(0, 0, 0, 0.035) 49.5% 50%, transparent 50% 74.5%, rgba(0, 0, 0, 0.035) 74.5% 75%, transparent 75% 100%);
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}
.soc-slot {
  flex: 1 1 0;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 1px;
  min-width: 0;
  position: relative;
  z-index: 3;
}
.soc-slot::before {
  content: "";
  position: absolute;
  inset: 6px 18% 6px 18%;
  border: 1px solid rgba(70, 85, 102, 0.22);
  border-radius: 8px 8px 4px 4px;
  background: rgba(255, 255, 255, 0.72);
}
.soc-slot::after {
  content: "";
  position: absolute;
  top: 6px;
  left: 42%;
  right: 42%;
  height: 3px;
  border-radius: 999px;
  background: rgba(70, 85, 102, 0.22);
}
.soc-slot-fill {
  width: 100%;
  border-radius: 6px 6px 0 0;
  position: relative;
  z-index: 1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.soc-slot.state-peak .soc-slot-fill {
  background: linear-gradient(to top, #d78b2e, #f0b35c);
}
.soc-slot.state-shoulder .soc-slot-fill {
  background: linear-gradient(to top, #4b79b1, #7e9fc6);
}
.soc-slot.state-cheap .soc-slot-fill {
  background: linear-gradient(to top, #39b58a, #67c8a4);
}
.tou-legend {
  padding: 0 12px 12px;
  display: grid;
  gap: 6px;
}
.tou-legend-section {
  margin-top: 8px;
  border-top: 0.5px solid var(--border);
}
.tou-legend-header {
  padding: 10px 12px 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}
.dispatch-footer-grid {
  padding: 10px 14px 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.dispatch-footer-card {
  border: 0.5px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.02);
}
.dispatch-footer-card .info-label {
  margin-bottom: 6px;
}
.dispatch-footer-card .info-arrows {
  margin-bottom: 6px;
}
.dispatch-footer-card .info-meta {
  margin-top: 6px;
}
.tou-legend-item {
  display: grid;
  grid-template-columns: minmax(260px, 3fr) minmax(86px, 1fr) minmax(102px, 1fr) minmax(102px, 1fr) minmax(102px, 1fr) minmax(118px, 1fr);
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-faint);
}
.tou-legend-head {
  font-weight: 600;
  color: var(--text-muted);
  padding-bottom: 2px;
}
.tou-legend-item > span:first-child {
  white-space: nowrap;
}
.tou-legend-item > span:first-child .tou-dot {
  margin-right: 6px;
}
.tou-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.tou-dot.peak { background: #d78b2e; }
.tou-dot.shoulder { background: #4b79b1; }
.tou-dot.cheap { background: var(--teal); }
.tou-name {
  font-size: 11px;
  color: var(--text-muted);
}
.tou-rate {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.tou-rate.peak {
  color: #6b3b00;
  background: #ffe7c8;
}
.tou-rate.shoulder {
  color: #244668;
  background: #dde9f5;
}
.tou-rate.cheap {
  color: var(--teal-dark);
  background: #d9f1e8;
}
.tou-mini {
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* ── Calculation breakdown ── */
.calc-breakdown {
  margin-top: 14px;
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.calc-title {
  background: var(--surface);
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: baseline;
  gap: 8px;
  border-bottom: 0.5px solid var(--border);
}
.calc-subtitle {
  font-weight: 400;
  color: var(--text-faint);
  font-size: 11px;
}
.calc-step {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 14px;
  font-size: 12px;
  border-bottom: 0.5px solid var(--border);
  gap: 12px;
}
.calc-step:last-child { border-bottom: none; }
.calc-section {
  background: var(--surface);
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-faint);
  border-bottom: 0.5px solid var(--border);
}
.powerflow-figure {
  padding: 16px 18px;
  border-bottom: 0.5px solid var(--border);
  background: var(--white);
}
.powerflow-svg {
  width: 100%;
  max-width: 55rem;
  height: auto;
  display: block;
  margin: 0 auto;
  overflow: visible;
}
.pf-box {
  stroke-width: 1;
}
.pf-grid {
  fill: #eaf2fb;
  stroke: #4b79b1;
}
.pf-battery {
  fill: #e5f5ef;
  stroke: #1d9e75;
}
.pf-home {
  fill: #fff1e2;
  stroke: #d97706;
}
.pf-box-title {
  font-size: 14px;
  font-weight: 600;
  fill: var(--text-muted);
}
.pf-box-value {
  font-size: 12.5px;
  font-weight: 500;
  fill: var(--text);
}
.pf-grid-text {
  fill: #4b79b1;
}
.pf-battery-text {
  fill: #1d9e75;
}
.pf-home-text {
  fill: #d97706;
}
.pf-box-detail {
  font-size: 8.5px;
  font-weight: 500;
  fill: var(--text-faint);
}
.pf-flow {
  stroke-width: 2;
  fill: none;
}
.pf-label-bg {
  fill: #f8fbff;
  opacity: 0.94;
}
.pf-grid-home {
  color: #4b79b1;
  stroke: currentColor;
}
.pf-grid-battery {
  color: #318f74;
  stroke: currentColor;
}
.pf-battery-home {
  color: #1d9e75;
  stroke: currentColor;
}
.pf-flow-label {
  font-size: 0.9rem;
  font-weight: 700;
  fill: #2a3648;
}
.pf-flow-detail {
  font-size: 0.74rem;
  font-weight: 500;
  fill: #2f3d50;
}
.pf-flow-subdetail {
  font-size: 0.74rem;
  font-weight: 500;
  fill: #2f3d50;
}
.pf-flow-total {
  font-weight: 700;
  fill: #151f2d;
}
.pf-flow-split {
  letter-spacing: 0;
  text-decoration: none;
}
.pf-flow-split .pf-inline-label {
  fill: #2f3d50;
  font-weight: 600;
}
.pf-flow-split .pf-inline-value {
  fill: #1a2332;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.pf-inline-value-end {
  text-anchor: end;
}
.pf-flow-split .pf-inline-value.pf-inline-value-key {
  fill: var(--teal);
}
.pf-flow-label-grid-home .pf-inline-label { fill: #18253a; }
.pf-flow-label-grid-battery .pf-inline-label { fill: #1a8f5a; }
.pf-flow-label-battery-home .pf-inline-label { fill: #1a8f5a; }
.pf-flow-detail.pf-flow-split .pf-inline-label,
.pf-flow-detail.pf-flow-split .pf-inline-value,
.pf-flow-subdetail.pf-flow-split .pf-inline-label,
.pf-flow-subdetail.pf-flow-split .pf-inline-value {
  font-weight: 500;
}
.pf-flow-total.pf-flow-split .pf-inline-label,
.pf-flow-total.pf-flow-split .pf-inline-value {
  font-weight: 700;
}
.pf-footnote {
  font-size: 0.73rem;
  font-weight: 500;
  fill: #2b3a4f;
}
.pf-footnote-positive {
  font-weight: 700;
}
.pf-flow-card {
  fill: #ffffff;
  stroke: none;
}
.pf-flow-card-home {
  stroke: #c2cdda;
  stroke-width: 1;
}
.pf-flow-divider {
  stroke: #b8c3d1;
  stroke-width: 0.8;
}
.pf-footnote-card {
  fill: #ffffff;
  stroke: #c2cdda;
  stroke-width: 1;
}
.pf-footnote-divider {
  stroke: #c8d1dc;
  stroke-width: 0.8;
  stroke-dasharray: 1.2 1.8;
}
.pf-footnote-icon-ring {
  fill: #eaf6ef;
  stroke: #1a8f5a;
  stroke-width: 1;
}
.pf-footnote-icon {
  fill: #1a8f5a;
  font-size: 7px;
  font-weight: 700;
  dominant-baseline: middle;
}
.pf-footnote-label {
  fill: #1b8858;
  font-weight: 700;
}
.pf-footnote-value {
  fill: #1e2a3a;
  font-weight: 500;
}
.pf-footnote-annual {
  fill: #4a5a70;
  font-weight: 500;
}

/* Simplified Power Flow Diagram - Compact Layout */
.powerflow-figure {
  width: 100%;
}

.powerflow-diagram {
  position: relative;
  margin: 0 auto 10px;
  background: white;
  border-radius: 8px;
  width: min(760px, 100%);
}

.powerflow-svg {
  width: 100%;
  height: auto;
  display: block;
  min-height: 160px;
}

/* Single SVG powerflow styles */
.pf-svg-node {
  stroke-width: 2;
}

.pf-svg-node-grid {
  fill: #f7fbff;
  stroke: #4b79b1;
}

.pf-svg-node-battery {
  fill: #f4fbf8;
  stroke: #1d9e75;
}

.pf-svg-node-home {
  fill: #fff9f1;
  stroke: #d97706;
}

.pf-svg-connector {
  stroke: #4b79b1;
  stroke-width: 2.25;
  fill: none;
  stroke-linecap: round;
}

.pf-svg-label-bg {
  fill: #ffffff;
  stroke: #4b79b1;
  stroke-width: 1;
}

.pf-svg-flow-label {
  font-size: 10px;
  font-weight: 700;
  fill: #4b79b1;
}

.pf-svg-connector-battery-home {
  stroke: #1d9e75;
}

.pf-svg-label-bg-battery-home {
  stroke: #1d9e75;
}

.pf-svg-flow-label-battery-home {
  fill: #1d9e75;
}

.pf-svg-node-title {
  font-size: 11px;
  font-weight: 700;
  fill: #1a2d44;
}

.pf-svg-node-subtitle {
  font-size: 10px;
  fill: #6b7b8f;
}

.pf-svg-node-value {
  font-size: 11px;
  font-weight: 700;
}

.pf-svg-node-value-grid {
  fill: #4b79b1;
}

.pf-svg-node-value-battery {
  fill: #1d9e75;
}

.pf-svg-node-value-home {
  fill: #d97706;
}

/* Flow legend: explains the two energy paths */
.pf-flow-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px 14px;
  margin-top: 4px;
  background: #fafbfc;
  border-radius: 0 0 8px 8px;
  font-size: 12px;
}

.pf-flow-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.pf-flow-label {
  font-weight: 600;
  color: #0d1b2a;
  min-width: 60px;
}

.pf-flow-direct .pf-flow-label {
  color: #4b79b1;
}

.pf-flow-delayed .pf-flow-label {
  color: #1d9e75;
}

.pf-flow-amount {
  font-weight: 700;
  color: #0d1b2a;
  min-width: 80px;
}

.pf-flow-note {
  color: #6b7b8f;
  font-size: 11px;
}

@media (min-width: 601px) {
  .powerflow-diagram {
    margin-bottom: 0;
  }

  .powerflow-svg {
    min-height: 180px;
  }
}

.pf-connector {
  fill: none;
  stroke-linecap: round;
}

.pf-label-bg {
  fill: white;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.05));
}

.pf-label {
  font-size: 11px;
  font-weight: 600;
  fill: #4a5a70;
  pointer-events: none;
}

.pf-label-grid-home {
  fill: #4b79b1;
}

.pf-label-grid-battery {
  fill: #1d9e75;
}

.pf-label-battery-home {
  fill: #d97706;
}

/* Detail cards grid */
.powerflow-detail-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 240px));
  justify-content: center;
  width: min(780px, 100%);
  margin: 0 auto 20px;
  gap: 14px;
}

.pf-detail-card {
  background: white;
  border: 1px solid #c2cdda;
  border-radius: 8px;
  padding: 12px;
  font-size: 12px;
  line-height: 1.4;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.pf-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  padding-bottom: 8px;
  border-bottom: 1px solid #c2cdda;
  margin-bottom: 8px;
}

.pf-card-title {
  color: #2a3648;
  font-size: 13px;
}

.pf-card-header .pf-card-value {
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
}

.pf-card-rows {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
}

.pf-card-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  font-size: 11px;
}

.pf-card-label {
  color: #6b7b8f;
  flex: 0 0 auto;
}

.pf-card-value {
  color: #2a3648;
  font-weight: 500;
  text-align: right;
}

.pf-card-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 6px;
  border-top: 1px solid #e0e6ed;
  font-weight: 600;
  color: #2a3648;
  font-size: 11px;
}

/* Results panel */
.powerflow-results-panel {
  margin-top: 16px;
  width: min(780px, 100%);
  margin-left: auto;
  margin-right: auto;
}

.powerflow-footnote-card {
  border: 1px solid #c2cdda;
  background: #ffffff;
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.powerflow-footnote-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 12px;
  color: #2b3a4f;
}

.powerflow-footnote-row-saving {
  border-top: 1px dashed #c8d1dc;
  padding-top: 8px;
}

.powerflow-footnote-label {
  color: #1b8858;
  font-weight: 700;
}

.powerflow-footnote-value {
  color: #1e2a3a;
  font-weight: 600;
  text-align: right;
}

.pf-footnote-annual {
  font-size: 10px;
  color: #6b7b8f;
}

/* Mobile responsive */
@media (max-width: 600px) {
  .powerflow-diagram {
    position: relative;
    min-height: auto;
  }

  .powerflow-svg {
    display: block;
    min-height: 160px;
  }

  .pf-flow-legend {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 16px;
  }

  .pf-flow-item {
    flex: 0 0 calc(50% - 8px);
  }

  .powerflow-detail-cards {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}
.pf-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  padding-bottom: 6px;
  border-bottom: 1px solid #c2cdda;
  flex-shrink: 0;
}
.pf-card-title {
  color: #2a3648;
  font-size: 12px;
}
.pf-card-header .pf-card-value {
  color: var(--teal);
  font-size: 11px;
  font-weight: 700;
}

.pf-card-title-group {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}

.pf-card-title-subtext {
  color: #6b7b8f;
  font-size: 10px;
  font-weight: 500;
  line-height: 1.2;
}
.pf-card-rows {
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow: hidden;
  flex: 1;
}
.pf-card-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  font-size: 11px;
  flex-shrink: 0;
}
.pf-card-label {
  color: #2f3d50;
  font-weight: 500;
  min-width: 65px;
  flex-shrink: 0;
}
.pf-card-row .pf-card-value {
  color: #1a2332;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
  flex: 1;
  font-size: 10px;
}
.pf-card-total {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  padding-top: 4px;
  border-top: 1px solid #c2cdda;
  color: #151f2d;
  flex-shrink: 0;
}
.pf-card-total .pf-card-label {
  font-weight: 700;
}
.pf-card-total .pf-card-value {
  text-align: right;
  flex: 1;
  font-size: 10px;
}
.calc-equation { background: var(--surface); }
.calc-total { background: var(--surface); font-weight: 600; }
.cs-key { color: var(--text-muted); flex-shrink: 0; }
.cs-val { text-align: right; font-weight: 500; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.cs-note { font-weight: 400; font-size: 11px; color: var(--text-faint); }
.cs-limit { color: var(--amber); font-size: 12px; }
.notice {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border-left: 3px solid var(--teal);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ── Empty state ── */
.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-faint);
  font-size: 13px;
}
.empty i { font-size: 36px; display: block; margin-bottom: 10px; color: var(--text-faint); }

/* ── Loading ── */
.loading { text-align: center; padding: 1rem; color: var(--text-faint); font-size: 13px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .monthly-grid { grid-template-columns: repeat(6, 1fr); }
  .optimized-chart-head { flex-direction: column; }
  .optimized-chart-meta { justify-content: flex-start; }
  .optimized-chart-canvas-wrap { height: 210px; }
  .sweet-spot-list { grid-template-columns: 1fr; }
  .sweet-spot-item { flex-direction: column; }
  .sweet-spot-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sweet-spot-action {
    position: static;
    top: auto;
    right: auto;
    align-self: flex-end;
    margin-left: 0;
  }
  .powerflow-figure { padding: 14px; }
  .pf-box-title { font-size: 12px; }
  .pf-box-value { font-size: 10px; }
  .pf-flow-label { font-size: 0.84rem; }
  .pf-flow-detail { font-size: 0.68rem; }
  .pf-flow-subdetail { font-size: 0.68rem; }
  .pf-footnote { font-size: 0.69rem; }
  .pf-flow-divider,
  .pf-footnote-divider { stroke-width: 0.7; }
  .info-meta { flex-direction: column; gap: 4px; }
  .tou-24h-line {
    height: 22px;
  }
  .timeline-band-tou {
    height: 20px;
  }
  .timeline-band-soc {
    height: 60px;
  }
  .timeline-band-labels {
    min-height: 18px;
  }
  .timeline-period-label {
    font-size: 8px;
    padding: 2px 4px;
  }
  .tou-source-key {
    flex-direction: column;
    gap: 3px;
  }
  .tou-load-bars {
    height: 56px;
  }
  .soc-24h-line {
    height: 60px;
  }
  .dispatch-footer-grid {
    padding: 10px 12px 12px;
    grid-template-columns: 1fr;
  }
  .bestcase-compare-grid {
    grid-template-columns: 1fr;
  }
  .tabs {
    flex-direction: column;
    align-items: stretch;
  }
  .tabs-left {
    overflow-x: auto;
  }
  .tabs-right {
    margin-left: 0;
    justify-content: flex-end;
  }
  .insights-top-layout {
    grid-template-columns: 1fr;
  }
  .soc-axis {
    font-size: 8px;
  }
  .tou-legend-item {
    grid-template-columns: minmax(180px, 1fr) repeat(5, minmax(72px, auto));
    row-gap: 2px;
    column-gap: 8px;
  }
  .info-arrows {
    flex-direction: column;
    gap: 2px;
    margin-bottom: 7px;
  }
}
