/* ─────────────────────────────────────────────────────────────────────────
   Operforma — Chart system
   Required: [data-chart] on the container.
   Imports the chart-scope tokens from colors_and_type.css.
   Editorial restraint: hairlines, mono figures, indigo for the conclusion.
   ───────────────────────────────────────────────────────────────────────── */

.ch {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Header — title + unit hint ──────────────────────────────────────── */
.ch-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}
.ch-title {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--indigo);
}
.ch-unit {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--soft);
}

/* ── Row — label · plot · figure ─────────────────────────────────────── */
.ch-row {
  display: grid;
  grid-template-columns: 88px 1fr 96px;
  align-items: center;
  gap: 16px;
}
.ch-row-label {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--soft);
}
.ch-row-label.is-target { color: var(--indigo); font-weight: 500; }
.ch-row-figure {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-align: right;
}
.ch-row-figure.is-target { color: var(--indigo); }
.ch-row-figure.is-muted  { color: var(--soft); font-weight: 400; }

/* ── Plot regions ────────────────────────────────────────────────────── */
.ch-plot {
  position: relative;
  height: 22px;
}
.ch-plot--tall { height: 64px; }
.ch-plot--bar  { height: 22px; }

/* ── Bar (used in dimension, allocation, ladder) ─────────────────────── */
.ch-bar {
  display: flex;
  height: 22px;
  background: transparent;
  /* sit inside ch-plot, can be width:N% to share an axis */
}
.ch-bar-seg {
  border-right: 1px solid var(--paper);
  position: relative;
}
.ch-bar-seg:last-child { border-right: none; }

/* Series fills — grey series for current, indigo series for target */
.ch-fill-1 { background: var(--chart-grey-1); }
.ch-fill-2 { background: var(--chart-grey-2); }
.ch-fill-3 { background: var(--chart-grey-3); }
.ch-fill-i1 { background: var(--chart-indigo-1); }
.ch-fill-i2 { background: var(--chart-indigo-2); }
.ch-fill-i3 { background: var(--chart-indigo-3); }

/* End-cap tick — extends 6px above/below to mark the value endpoint */
.ch-bar.is-stroke {
  height: 2px;
  margin-top: 10px;
  background: var(--chart-grey-1);
  position: relative;
}
.ch-bar.is-stroke.is-target { background: var(--chart-indigo-1); }
.ch-bar.is-stroke::before,
.ch-bar.is-stroke::after {
  content: '';
  position: absolute;
  top: -5px;
  width: 1px;
  height: 12px;
  background: inherit;
}
.ch-bar.is-stroke::before { left: 0; }
.ch-bar.is-stroke::after  { right: 0; }

/* ── Axis ticks (below the plot) ─────────────────────────────────────── */
.ch-axis {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.ch-tick {
  position: absolute;
  top: 100%;
  width: 1px;
  height: 4px;
  background: var(--chart-axis);
  margin-top: 2px;
}
.ch-tick-label {
  position: absolute;
  top: 100%;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 9px;
  letter-spacing: 0.04em;
  color: var(--soft);
  transform: translateX(-50%);
  white-space: nowrap;
}
.ch-tick-label.is-target { color: var(--indigo); font-weight: 500; }

/* ── Footer — Δ summary row ──────────────────────────────────────────── */
.ch-foot {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-top: 10px;
  border-top: 1px solid var(--chart-grid);
}
.ch-foot-label {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--soft);
}
.ch-foot-figure {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--indigo);
}

/* ── Legend (used in allocation) ─────────────────────────────────────── */
.ch-legend {
  display: flex;
  gap: 16px 22px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid var(--chart-grid);
}
.ch-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--ink);
}
.ch-legend-swatch {
  display: block;
  width: 14px;
  height: 10px;
  flex-shrink: 0;
}
.ch-legend-hours {
  font-family: var(--font-mono);
  font-weight: 500;
  margin-left: 4px;
  color: var(--soft);
}
.ch-legend-hours.is-target { color: var(--indigo); }

/* ── Table chart ─────────────────────────────────────────────────────── */
.ch-table {
  width: 100%;
  border-collapse: collapse;
}
.ch-table th {
  text-align: left;
  padding: 9px 14px 9px 0;
  border-bottom: 1px solid var(--chart-rule);
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--soft);
}
.ch-table th.is-num { text-align: right; padding: 9px 14px; }
.ch-table th.is-target { color: var(--indigo); font-weight: 500; padding: 9px 0 9px 14px; }
.ch-table td {
  padding: 12px 14px 12px 0;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 14px;
  color: var(--ink);
}
.ch-table td.is-num {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.02em;
  color: var(--soft);
  padding: 12px 14px;
}
.ch-table td.is-target {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.02em;
  color: var(--indigo);
  text-align: right;
  padding: 12px 0 12px 14px;
}

/* ── Sparkline ───────────────────────────────────────────────────────── */
.ch-spark-headline {
  display: flex;
  align-items: flex-end;
  gap: 18px;
}
.ch-spark-figure {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 28px;
  letter-spacing: -0.01em;
  color: var(--indigo);
  line-height: 1;
}
.ch-spark-svg {
  flex: 1;
  height: 64px;
  display: block;
}

/* ── Ladder ──────────────────────────────────────────────────────────── */
.ch-ladder {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--chart-grid);
  align-items: end;
}
.ch-ladder-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}
.ch-ladder-price {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.02em;
  color: var(--ink);
}
.ch-ladder-price.is-anchor { color: var(--indigo); }
.ch-ladder-bar {
  width: 100%;
  background: var(--chart-grey-2);
}
.ch-ladder-bar.is-anchor { background: var(--chart-indigo-1); }
.ch-ladder-bar.is-anchor-light { background: var(--chart-indigo-2); }
.ch-ladder-foot {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-top: 8px;
  width: 100%;
  border-top: 1px solid var(--chart-grid);
}
.ch-ladder-foot.is-anchor { border-top-color: var(--indigo); }
.ch-ladder-tier {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--soft);
}
.ch-ladder-tier.is-anchor { color: var(--indigo); }
.ch-ladder-name {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 13px;
  letter-spacing: -0.005em;
  color: var(--ink);
}

/* ── Slope chart ─────────────────────────────────────────────────────── */
.ch-slope {
  display: grid;
  grid-template-columns: minmax(80px, max-content) 1fr minmax(80px, max-content);
  align-items: stretch;
  gap: 0;
  padding: 16px 0 28px;
}
.ch-slope-col {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0;
  padding: 0 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--soft);
}
.ch-slope-col.is-target { color: var(--indigo); border-left: 1px solid var(--chart-grid); }
.ch-slope-col.is-current { border-right: 1px solid var(--chart-grid); text-align: right; }
.ch-slope-row {
  display: flex;
  align-items: center;
  height: 22px;
  gap: 8px;
}
.ch-slope-col.is-current .ch-slope-row { justify-content: flex-end; }
.ch-slope-name {
  font-family: var(--font-body);
  font-weight: 300;
  font-size: 12px;
  color: var(--ink);
  letter-spacing: 0;
}
.ch-slope-svg {
  height: 100%;
  width: 100%;
  display: block;
}

/* ── Bullet chart ────────────────────────────────────────────────────── */
.ch-bullet-row {
  display: grid;
  grid-template-columns: 120px 1fr 84px;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--chart-grid);
}
.ch-bullet-row:last-child { border-bottom: none; }
.ch-bullet-label {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 13px;
  color: var(--ink);
  letter-spacing: 0;
}
.ch-bullet-track {
  position: relative;
  height: 18px;
  background: var(--chart-grey-3);
}
.ch-bullet-band {
  position: absolute;
  top: 0; bottom: 0;
  background: var(--chart-grey-2);
}
.ch-bullet-fill {
  position: absolute;
  top: 4px; bottom: 4px; left: 0;
  background: var(--chart-grey-1);
}
.ch-bullet-fill.is-target { background: var(--chart-indigo-1); }
.ch-bullet-marker {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--chart-indigo-1);
}
.ch-bullet-figure {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-align: right;
}
.ch-bullet-figure.is-target { color: var(--indigo); }

/* ── Waterfall ───────────────────────────────────────────────────────── */
.ch-water {
  display: flex;
  align-items: flex-end;
  gap: 0;
  padding: 12px 0;
  border-bottom: 1px solid var(--chart-grid);
  height: 140px;
  position: relative;
}
.ch-water-baseline {
  position: absolute;
  left: 0; right: 0; bottom: 12px;
  height: 1px;
  background: var(--chart-grid);
  pointer-events: none;
}
.ch-water-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  position: relative;
  padding: 0 4px;
  min-width: 0;
}
.ch-water-bar {
  width: 100%;
  background: var(--chart-grey-1);
  position: relative;
}
.ch-water-bar.is-add { background: var(--chart-indigo-2); }
.ch-water-bar.is-anchor { background: var(--chart-indigo-1); }
.ch-water-bar.is-base { background: var(--chart-grey-1); }
.ch-water-value {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--ink);
  margin-bottom: 6px;
  white-space: nowrap;
}
.ch-water-value.is-add { color: var(--indigo); }
.ch-water-value.is-anchor { color: var(--indigo); }
.ch-water-foot {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 9px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--soft);
  margin-top: 8px;
  text-align: center;
  white-space: nowrap;
}
.ch-water-foot.is-anchor { color: var(--indigo); font-weight: 500; }
.ch-water-connector {
  position: absolute;
  top: 0;
  right: -4px;
  width: 8px;
  height: 1px;
  border-top: 1px dashed var(--chart-grid);
  pointer-events: none;
}

/* ── Range / dot plot ────────────────────────────────────────────────── */
.ch-range-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--chart-grid);
}
.ch-range-row:last-child { border-bottom: none; }
.ch-range-label {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--soft);
}
.ch-range-track {
  position: relative;
  height: 28px;
}
.ch-range-line {
  position: absolute;
  top: 14px;
  height: 1px;
  background: var(--chart-grey-1);
}
.ch-range-line-cap {
  position: absolute;
  top: 10px;
  width: 1px;
  height: 9px;
  background: var(--chart-grey-1);
}
.ch-range-median {
  position: absolute;
  top: 8px;
  width: 1px;
  height: 13px;
  background: var(--chart-grey-1);
}
.ch-range-dot {
  position: absolute;
  top: 9px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--chart-indigo-1);
  border: 2px solid var(--paper);
  box-sizing: border-box;
  transform: translateX(-50%);
}
.ch-range-dot::after {
  content: attr(data-value);
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--indigo);
  white-space: nowrap;
}
.ch-range-scale-label {
  position: absolute;
  top: 24px;
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 9px;
  letter-spacing: 0.04em;
  color: var(--soft);
  transform: translateX(-50%);
  white-space: nowrap;
}
