/* ============================================================
   BATTERY DISPATCH MODEL — styles
   Reuses the global slate/steel-teal tokens defined in styles.css
   (--bg, --ink, --accent, --mono …). All selectors are .bd-*.
   ============================================================ */

.bd {
  --bd-charge: oklch(0.58 0.10 235);   /* buy / charge — cool blue */
  --bd-discharge: oklch(0.60 0.15 35); /* sell / discharge — warm */
  --bd-cap: oklch(0.55 0.08 165);      /* capacity revenue */
  --bd-anc: oklch(0.62 0.10 95);       /* ancillary revenue */
  font-family: var(--sans);
  color: var(--ink);
}

/* ---------- top bar ---------- */
.bd-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
}
.bd-bar-left { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.bd-bar-brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  letter-spacing: 0.08em; color: var(--ink);
}
.bd-bar-dot { width: 7px; height: 7px; background: var(--accent); display: inline-block; }
.bd-bar-crumb { font-family: var(--mono); font-size: 11px; color: var(--ink-mute); }
.bd-bar-sep { color: var(--line); margin-right: 6px; }
.bd-reset {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em;
  color: var(--ink-dim); background: var(--bg-2);
  border: 1px solid var(--line); padding: 7px 12px; cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.bd-reset:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- hero ---------- */
.bd-hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 32px;
  align-items: end;
  margin-bottom: 26px;
}
.bd-eyebrow {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 10px;
}
.bd-title {
  font-size: 30px; font-weight: 700; line-height: 1.08;
  margin: 0 0 12px; letter-spacing: -0.01em;
}
.bd-lede { font-size: 13px; line-height: 1.55; color: var(--ink-dim); max-width: 56ch; margin: 0; }
.bd-hero-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

/* ---------- stat tiles ---------- */
.bd-stat {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-top: 2px solid var(--ink-mute);
  padding: 12px 13px;
}
.bd-stat--good { border-top-color: var(--ok); }
.bd-stat--bad { border-top-color: var(--bad); }
.bd-stat-label {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-mute); margin-bottom: 6px;
}
.bd-stat-value { font-family: var(--mono); font-size: 21px; font-weight: 600; color: var(--ink); line-height: 1.05; }
.bd-stat--good .bd-stat-value { color: var(--ok); }
.bd-stat--bad .bd-stat-value { color: var(--bad); }
.bd-stat-sub { font-size: 10.5px; color: var(--ink-mute); margin-top: 5px; }

/* ---------- main grid ---------- */
.bd-grid { display: grid; grid-template-columns: 300px 1fr; gap: 24px; align-items: start; }

/* ---------- config column ---------- */
.bd-config {
  position: sticky; top: 16px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  padding: 16px 16px 20px;
}
.bd-section-tag {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--accent);
  padding-bottom: 7px; margin: 18px 0 12px;
  border-bottom: 1px solid var(--line-soft);
}
.bd-section-tag:first-child { margin-top: 0; }

.bd-ctrl { margin-bottom: 15px; }
.bd-ctrl-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.bd-ctrl-label { font-size: 11.5px; color: var(--ink-dim); }
.bd-ctrl-value { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--ink); }
.bd-ctrl-unit { color: var(--ink-mute); font-weight: 400; font-size: 11px; margin-left: 1px; }
.bd-ctrl-hint { font-size: 10px; color: var(--ink-mute); margin-top: 5px; line-height: 1.4; }

.bd-range {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 3px; background: var(--bg-3);
  outline: none; cursor: pointer; border-radius: 0;
}
.bd-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; background: var(--accent);
  border: 2px solid var(--bg-2); cursor: pointer; border-radius: 50%;
}
.bd-range::-moz-range-thumb {
  width: 14px; height: 14px; background: var(--accent);
  border: 2px solid var(--bg-2); cursor: pointer; border-radius: 50%;
}

/* ---------- results column ---------- */
.bd-results { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.bd-panel { background: var(--bg-2); border: 1px solid var(--line); padding: 18px 20px 20px; }
.bd-panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.bd-panel-head h2 { font-size: 15px; font-weight: 600; margin: 0; }
.bd-panel-meta { font-family: var(--mono); font-size: 10.5px; color: var(--ink-mute); }

/* ---------- week chart ---------- */
.bd-chart-wrap { width: 100%; }
.bd-week-chart {
  width: 100%; height: 220px; display: block;
  background: var(--bg); border: 1px solid var(--line-soft);
}
.bd-daygrid { stroke: var(--line-soft); stroke-width: 1; }
.bd-mean { stroke: var(--ink-mute); stroke-width: 1; stroke-dasharray: 4 4; opacity: 0.7; }
.bd-price-line { fill: none; stroke: var(--ink-dim); stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.bd-dot-charge { fill: var(--bd-charge); }
.bd-dot-discharge { fill: var(--bd-discharge); }

.bd-chart-axis { position: relative; height: 16px; margin-top: 2px; }
.bd-chart-axis span {
  position: absolute; transform: translateX(-50%);
  font-family: var(--mono); font-size: 9.5px; color: var(--ink-mute);
}
.bd-chart-axis span:first-child { transform: translateX(0); }
.bd-chart-axis span:last-child { transform: translateX(-100%); }

.bd-legend {
  display: flex; gap: 18px; flex-wrap: wrap; margin-top: 12px;
  font-size: 11px; color: var(--ink-dim);
}
.bd-legend span { display: inline-flex; align-items: center; gap: 6px; }
.bd-key { width: 10px; height: 10px; display: inline-block; border-radius: 2px; }
.bd-key-charge { background: var(--bd-charge); border-radius: 50%; }
.bd-key-discharge { background: var(--bd-discharge); border-radius: 50%; }
.bd-key-mean { background: var(--ink-mute); height: 2px; width: 14px; border-radius: 0; }
.bd-key-arb { background: var(--accent); }
.bd-key-cap { background: var(--bd-cap); }
.bd-key-anc { background: var(--bd-anc); }
.bd-key-total { background: var(--ink); }

/* ---------- stat rows ---------- */
.bd-stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 16px; }
.bd-stat-row--econ { margin-top: 0; margin-bottom: 18px; }

/* ---------- revenue stack ---------- */
.bd-revstack { display: flex; flex-direction: column; gap: 14px; }
.bd-revbar { display: flex; height: 30px; border: 1px solid var(--line); overflow: hidden; background: var(--bg); }
.bd-revseg { height: 100%; transition: width 0.25s ease; }
.bd-revseg--arb { background: var(--accent); }
.bd-revseg--cap { background: var(--bd-cap); }
.bd-revseg--anc { background: var(--bd-anc); }
.bd-revlegend { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; }
.bd-revitem { display: grid; grid-template-columns: 14px 1fr auto auto; align-items: center; gap: 8px; font-size: 12px; }
.bd-revitem-label { color: var(--ink-dim); }
.bd-revitem-val { font-family: var(--mono); font-weight: 600; color: var(--ink); }
.bd-revitem-pct { font-family: var(--mono); font-size: 11px; color: var(--ink-mute); width: 36px; text-align: right; }
.bd-revitem--total { border-top: 1px solid var(--line-soft); padding-top: 6px; margin-top: 2px; }
.bd-revitem--total .bd-revitem-label { color: var(--ink); font-weight: 600; }

/* ---------- DCF table ---------- */
.bd-table-scroll { overflow-x: auto; }
.bd-table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 11px; }
.bd-table th, .bd-table td {
  padding: 6px 8px; text-align: right; white-space: nowrap;
  border-bottom: 1px solid var(--line-soft);
}
.bd-table thead th { color: var(--ink-mute); font-weight: 500; border-bottom: 1px solid var(--line); }
.bd-th-label { text-align: left !important; color: var(--ink-dim); position: sticky; left: 0; background: var(--bg-2); }
.bd-table thead .bd-th-label { color: var(--ink-mute); }
.bd-table td { color: var(--ink); }
.bd-tr-em td { font-weight: 600; }
.bd-tr-em td, .bd-tr-em .bd-th-label { border-top: 1px solid var(--line-soft); }
.bd-tr-fcf td { font-weight: 700; border-top: 1px solid var(--ink-mute); border-bottom: 0; }
.bd-tr-fcf .bd-th-label { color: var(--ink); }
.bd-neg { color: var(--bad); }

/* ---------- prompts ---------- */
.bd-prompts { margin: 0 0 16px; padding-left: 18px; }
.bd-prompts li { font-size: 12.5px; line-height: 1.55; color: var(--ink-dim); margin-bottom: 7px; }
.bd-prompts b { color: var(--ink); }
.bd-caveat {
  font-size: 11.5px; line-height: 1.55; color: var(--ink-mute);
  background: var(--bg); border-left: 2px solid var(--accent);
  padding: 11px 14px;
}
.bd-caveat b { color: var(--ink-dim); }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .bd-hero { grid-template-columns: 1fr; gap: 18px; align-items: start; }
  .bd-grid { grid-template-columns: 1fr; }
  .bd-config { position: static; }
}
@media (max-width: 680px) {
  .bd-hero-stats { grid-template-columns: 1fr; }
  .bd-stat-row { grid-template-columns: 1fr 1fr; }
  .bd-revlegend { grid-template-columns: 1fr; }
  .bd-title { font-size: 24px; }
}
