/* ═══════════════════════════════════════════════════════════════
   COST & TOKEN METER — pools, charts, leaderboards, alerts
   ═══════════════════════════════════════════════════════════════ */

/* ── BUDGET POOLS ──────────────────────────────────────── */
.pool-grid {
  gap: 0;
  border-top: 1px solid var(--b2);
}
.pool {
  padding: 18px 20px 16px;
  border-right: 1px solid var(--b2);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}
.pool:last-child { border-right: 0; }
.pool.warn::before, .pool.err::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.pool.warn::before { background: var(--hold); }
.pool.err::before { background: var(--fail); }

.pool-head {
  display: flex; align-items: baseline; justify-content: space-between;
}
.pool-name {
  font-family: var(--sans);
  font-size: 18px; font-weight: 600;
  letter-spacing: -0.02em;
}
.pool-q {
  font-size: 9px;
  color: var(--t3);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.pool-ring-wrap {
  position: relative;
  width: 120px; height: 120px;
  margin: 4px auto 4px;
}
.pool-ring { width: 100%; height: 100%; }
.ring-bg {
  fill: none; stroke: var(--b2); stroke-width: 6;
}
.ring-fg {
  fill: none; stroke: var(--t1); stroke-width: 6;
  stroke-linecap: butt;
  transition: stroke-dasharray 0.6s ease;
}
.pool.warn .ring-fg { stroke: var(--hold); }
.pool.err .ring-fg { stroke: var(--fail); }
/* a pool under its alert is a quantity, not a state: white .72 like .load-fill */
.pool.ok .ring-fg { stroke: color-mix(in srgb, var(--t1) 72%, transparent); }
.pool-pct {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.pool-pct-num {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 28px;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--t1);
  font-variant-numeric: tabular-nums;
}
.pool.warn .pool-pct-num { color: var(--hold); }
.pool.err .pool-pct-num { color: var(--fail); }
.pool-pct-num sub { font-size: 12px; color: var(--t3); margin-left: 1px; font-weight: 400; }
.pool-pct-lbl {
  font-size: 9px;
  color: var(--t3);
  letter-spacing: 0.2em;
}

.pool-stats {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 11px;
  padding: 10px 0;
  border-top: 1px dashed var(--b2);
}

.pool-bar {
  height: 6px;
  background: var(--s2);
  border: 1px solid var(--b2);
  border-radius: 2px;
  position: relative;
}
.pool-bar-fill {
  position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, var(--t1) 72%, transparent);
}
.pool.warn .pool-bar-fill { background: var(--hold); }
.pool.err .pool-bar-fill { background: var(--fail); }
/* the alert threshold is a marker, not a state: white, the pool itself turns hold */
.pool-bar-alert {
  position: absolute;
  top: -2px; bottom: -2px;
  width: 1px;
  background: var(--t1);
}
.pool-bar-alert::before {
  content: ""; position: absolute;
  top: -3px; left: -2px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--t1);
}

/* ── FORECAST PANEL ────────────────────────────────────── */
.forecast-num {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 56px;
  letter-spacing: -0.04em;
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
}
.forecast-lbl {
  font-size: 9px;
  letter-spacing: 0.2em;
  margin-top: 6px;
}
.forecast-bar {
  height: 14px;
  background: var(--s2);
  border: 1px solid var(--b2);
  border-radius: 2px;
  position: relative;
  overflow: visible;
}
.forecast-bar-fill {
  height: 100%;
  background: var(--t1);
  position: relative;
  z-index: 1;
}
.forecast-bar-fill.over { background: var(--fail); }
.forecast-bar-over {
  position: absolute;
  top: 0; bottom: 0; left: 100%;
  background: var(--fail);
  border-left: 1px dashed var(--bg);
  z-index: 2;
}
.forecast-scen {
  display: flex; flex-direction: column; gap: 8px;
  font-size: 12px;
}
.scen-row {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: center;
  gap: 10px;
}
/* scenarios are series: filled, ring, dim — no colour */
.scen-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.scen-dot.lyr-1 { background: var(--t3); }
.scen-dot.lyr-2 { background: var(--t1); }
.scen-dot.lyr-3 { box-shadow: inset 0 0 0 1.5px var(--t1); }
.scen-name { color: var(--t2); }
.scen-val {
  font-weight: 700;
  font-size: 13px;
  color: var(--t1);
}
.forecast-alert {
  margin-top: 14px;
  padding: 8px 10px;
  border: 1px solid color-mix(in oklch, var(--fail) 45%, transparent);
  border-radius: var(--r-c);
  background: var(--fail-wash);
  color: var(--fail);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
}

/* ── MODEL TABLE / STACK BAR ───────────────────────────── */
.stack-bar {
  height: 14px;
  background: var(--s2);
  border: 1px solid var(--b2);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
  margin-bottom: 12px;
}
/* models are series: white in steps, hatched, a --bg seam between segments */
.stack-seg {
  position: absolute;
  top: 0; bottom: 0;
  box-shadow: inset -1px 0 0 var(--bg);
}
.stack-seg.lyr-0 { background: var(--t1); }
.stack-seg.lyr-1 { background: color-mix(in srgb, var(--t1) 55%, transparent); }
.stack-seg.lyr-2 { background: var(--t2); }
.stack-seg.lyr-3 { background: repeating-linear-gradient(135deg, var(--t2) 0 2px, transparent 2px 5px); }
.stack-legend {
  display: flex; flex-wrap: wrap; gap: 14px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--t1);
  letter-spacing: 0.04em;
}
.leg-item { display: inline-flex; align-items: center; gap: 6px; }
.leg-swatch {
  width: 10px; height: 10px;
  border-radius: 2px;
  display: inline-block;
}
.leg-swatch.lyr-0 { background: var(--t1); }
.leg-swatch.lyr-1 { background: color-mix(in srgb, var(--t1) 55%, transparent); }
.leg-swatch.lyr-2 { background: var(--t2); }
.leg-swatch.lyr-3 { background: repeating-linear-gradient(135deg, var(--t2) 0 2px, transparent 2px 5px); box-shadow: inset 0 0 0 1px var(--t3); }

.model-row td { padding: 10px 14px; }
.mdl-name { font-size: 12px; font-weight: 700; color: var(--t1); }
.mdl-prov { font-size: 10px; letter-spacing: 0.08em; }
.mdl-share {
  position: relative;
  height: 8px;
  background: var(--s2);
  border: 1px solid var(--b2);
  display: flex; align-items: center;
}
.mdl-share-fill {
  position: absolute; inset: 0 auto 0 0;
  background: var(--t1);
}
.mdl-share-num {
  position: relative;
  z-index: 1;
  margin-left: auto;
  margin-right: 6px;
  font-size: 10px;
  color: var(--t1);
  mix-blend-mode: difference;
  filter: invert(1);
}

/* ── FACTORY LEADERBOARD ──────────────────────────────── */
.fac-row {
  display: grid;
  grid-template-columns: 24px 1fr 1.2fr 70px 50px;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--b1);
}
.fac-row:last-child { border-bottom: 0; }
.fac-rank {
  font-size: 11px;
  color: var(--t3);
  letter-spacing: 0.1em;
}
.fac-info { display: flex; flex-direction: column; gap: 2px; }
.fac-name {
  font-weight: 600;
  color: var(--t1);
  font-size: 13px;
}
.fac-sub {
  font-size: 10px;
  letter-spacing: 0.06em;
}
.fac-bar {
  height: 10px;
  background: var(--s2);
  border: 1px solid var(--b2);
  border-radius: 2px;
  position: relative;
}
.fac-bar-fill {
  position: absolute; inset: 0 auto 0 0;
  background: color-mix(in srgb, var(--t1) 72%, transparent);
}
/* the top spender is highlighted with full white, not red: rank is not an error */
.fac-row:first-child .fac-bar-fill { background: var(--t1); }
.fac-spend {
  text-align: right;
  font-size: 13px;
  font-weight: 700;
  color: var(--t1);
}
.fac-trend {
  text-align: right;
  font-size: 10px;
  letter-spacing: 0.05em;
}

/* ── EXPENSIVE RUNS ────────────────────────────────────── */
.exp-row td { padding: 9px 12px; }
.exp-task {
  font-weight: 500;
  color: var(--t1);
  line-height: 1.3;
  margin-bottom: 2px;
  font-size: 12px;
}
.exp-meta {
  font-size: 10px;
  color: var(--t3);
  letter-spacing: 0.04em;
}

/* ── ALERTS ────────────────────────────────────────────── */
.alert-row {
  display: grid;
  grid-template-columns: 14px 1fr auto auto;
  gap: 14px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--b1);
}
.alert-row:last-child { border-bottom: 0; }
.alert-row.fire {
  background: color-mix(in oklch, var(--fail) 6%, transparent);
}
/* .run = armed rule, watching: live white with glow; .err = firing, --fail,
   no glow and no blink */
.alert-pip {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--t1);
  box-shadow: var(--glow);
}
.alert-pip.err {
  background: var(--fail);
  box-shadow: none;
}
.alert-info { display: flex; flex-direction: column; gap: 2px; }
.alert-name {
  font-weight: 600;
  color: var(--t1);
  font-size: 13px;
}
.alert-cond {
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--t3);
}
.alert-status {
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--t3);
}
.alert-status.err-text { color: var(--fail); font-weight: 700; }
