/* ── Cost Payback Timeline Chart ── */

/* Controls */
.cpb-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px 28px;
  margin-bottom: 20px;
}
.cpb-ctrl {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cpb-ctrl-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.cpb-ctrl label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6c757d;
}
.cpb-ctrl-val {
  font-size: 0.92rem;
  font-weight: 800;
  color: #212529;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.cpb-ctrl input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #dee2e6;
  outline: none;
  cursor: pointer;
}
.cpb-ctrl input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #0169fe;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  cursor: pointer;
}
.cpb-ctrl input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #0169fe;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  cursor: pointer;
}
.cpb-ctrl-hint {
  font-size: 0.68rem;
  color: #8a919a;
  line-height: 1.35;
  margin-top: -2px;
}

/* Mode toggle */
.cpb-mode-toggle {
  display: inline-flex;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 24px;
  border: 2px solid #0169fe;
}
.cpb-mode-btn {
  padding: 10px 24px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: #fff;
  color: #0169fe;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.cpb-mode-btn[aria-pressed="true"] {
  background: #0169fe;
  color: #fff;
}
.cpb-mode-btn:not([aria-pressed="true"]):hover {
  background: #f0f7ff;
}

/* Finance controls */
.cpb-finance-ctrls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px 28px;
  margin-bottom: 24px;
  padding: 20px 24px;
  background: #f0f7ff;
  border-radius: 10px;
  border: 1px solid #d0e3f7;
}
.cpb-finance-ctrls[hidden] { display: none; }

/* Chart */
.cpb-chart-wrap {
  position: relative;
}
.cpb-chart {
  width: 100%;
}
.cpb-chart svg {
  display: block;
  width: 100%;
  height: auto;
}
.cpb-axis text {
  font-size: 12.5px;
  fill: #6c757d;
}
.cpb-axis-x .domain { stroke: #ccc; }
.cpb-axis-x .tick line { stroke: #eee; }
.cpb-axis-y .domain { display: none; }
.cpb-axis-y .tick line { stroke: #eee; }

/* Chart areas and lines */
.cpb-area-ins  { fill: #0169fe; opacity: 0.18; }
.cpb-area-en   { fill: #28a745; opacity: 0.14; }
.cpb-area-gap  { opacity: 0.08; }
.cpb-line-savings {
  fill: none;
  stroke: #0169fe;
  stroke-width: 2.5;
}
.cpb-line-cost {
  fill: none;
  stroke: #212529;
  stroke-width: 2.5;
}
.cpb-line-breakeven {
  stroke: #198754;
  stroke-width: 2.5;
  stroke-dasharray: 8 5;
}
.cpb-line-payoff {
  stroke: #6c757d;
  stroke-width: 1;
  stroke-dasharray: 5 4;
}
.cpb-dot-breakeven {
  fill: #198754;
  stroke: #fff;
  stroke-width: 2.5;
}
.cpb-ann {
  font-size: 13px;
  fill: #495057;
}
.cpb-ann-bold { font-weight: 700; }
.cpb-ann-green { fill: #198754; }
.cpb-ann-gray { fill: #8a919a; }
.cpb-ann-breakeven { fill: #198754; font-weight: 800; font-size: 15px; }
.cpb-ann-savings-label { fill: #0169fe; font-weight: 700; font-size: 14px; }
.cpb-ann-cost-label { fill: #212529; font-weight: 700; font-size: 14px; }

/* Tooltip */
.cpb-tip {
  position: absolute;
  pointer-events: none;
  padding: 12px 16px;
  background: #1a1e2e;
  color: #fff;
  border-radius: 8px;
  font-size: 0.8rem;
  line-height: 1.6;
  white-space: nowrap;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.12s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.cpb-tip.is-visible { opacity: 1; }
.cpb-tip-row { display: flex; justify-content: space-between; gap: 20px; }
.cpb-tip-label { color: #adb5bd; }
.cpb-tip-val { font-weight: 700; text-align: right; }
.cpb-tip-val-green { color: #6ee7a0; }
.cpb-tip-divider { border-top: 1px solid rgba(255,255,255,0.12); margin: 4px 0; }

/* Legend */
.cpb-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #eee;
}
.cpb-legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  color: #495057;
}
.cpb-legend-swatch {
  width: 16px;
  height: 4px;
  border-radius: 2px;
  flex-shrink: 0;
}
.cpb-legend-swatch-area {
  width: 16px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* Stats */
.cpb-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 24px;
}
.cpb-stat {
  padding: 16px 18px;
  background: #f8f9fa;
  border-radius: 10px;
  border: 1px solid #eef0f2;
}
.cpb-stat-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #8a919a;
  margin-bottom: 4px;
}
.cpb-stat-val {
  font-size: 1.3rem;
  font-weight: 800;
  color: #212529;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.cpb-stat-val.is-positive { color: #198754; }
.cpb-stat-val.is-negative { color: #dc3545; }
.cpb-stat-sub {
  font-size: 0.7rem;
  color: #8a919a;
  margin-top: 3px;
}

/* Responsive */
@media (max-width: 991px) {
  .cpb-controls { grid-template-columns: 1fr 1fr; }
  .cpb-finance-ctrls { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 575px) {
  .cpb-controls { grid-template-columns: 1fr; }
  .cpb-finance-ctrls { grid-template-columns: 1fr; }
  .cpb-stats { grid-template-columns: 1fr 1fr; }
  .cpb-mode-btn { padding: 10px 16px; font-size: 0.78rem; }
}
