/* ==========================================================================
   FOUNDEROWN · tools.css
   Calculator workbench layer: inputs (range/stepper/segmented/select/toggle)
   · KPI telemetry · gauge & chart shells · benchmark tables · formula blocks
   · health banner · print/PDF audit sheet
   Depends on: tokens.css, base.css, layout.css, components.css.
   ========================================================================== */

/* ==========================================================================
   1. WORKBENCH SHELL
   ========================================================================== */

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--sp-5);
  align-items: start;
  margin-block: var(--sp-6);
}

@media (max-width: 980px) {
  .workbench {
    grid-template-columns: minmax(0, 1fr);
  }
}

.workbench__inputs,
.workbench__telemetry {
  min-width: 0;
}

.workbench__telemetry {
  position: sticky;
  top: calc(var(--header-h) + var(--sp-4));
}

@media (max-width: 980px) {
  .workbench__telemetry {
    position: static;
  }
}

/* ==========================================================================
   2. FIELDS
   ========================================================================== */

.fields {
  display: grid;
  gap: var(--field-cols, var(--sp-4));
}

.field {
  display: grid;
  gap: var(--sp-2);
  min-width: 0;
}

.field__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  min-width: 0;
}

.field__label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  letter-spacing: var(--tracking-snug);
}

/* The readout beside each label. Value text is written by JS after mount, so
   the box is reserved here: a late value must never widen the row and push
   the panel. Measured with the layout-shift observer. */
.field__value {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  text-align: right;
  white-space: nowrap;
  min-width: 6.5ch;
  min-height: 1.5em;
  line-height: 1.5;
  contain: layout paint;
}

.field__value--prose {
  font-family: var(--font-sans);
  min-width: 0;
}

.field__hint,
.field__help {
  font-size: var(--text-xs);
  color: var(--text-faint);
  line-height: var(--leading-snug);
}

.field__error {
  font-size: var(--text-xs);
  color: var(--accent-rose);
}

.field__error:empty {
  display: none;
}

/* ==========================================================================
   3. RANGE SLIDER
   ========================================================================== */

.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
  margin: 0;
}

.range::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: var(--r-full);
  background: linear-gradient(
    to right,
    var(--accent-emerald) 0%,
    var(--accent-emerald) var(--fill, 50%),
    var(--bg-inset) var(--fill, 50%),
    var(--bg-inset) 100%
  );
  border: 1px solid var(--border-subtle);
}

.range::-moz-range-track {
  height: 5px;
  border-radius: var(--r-full);
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
}

.range::-moz-range-progress {
  height: 5px;
  border-radius: var(--r-full);
  background: var(--accent-emerald);
}

.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: var(--r-full);
  background: var(--bg-elevated);
  border: 2px solid var(--accent-emerald);
  box-shadow: var(--sh-raise);
  transition: transform var(--dur-1) var(--ease-out);
}

.range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: var(--r-full);
  background: var(--bg-elevated);
  border: 2px solid var(--accent-emerald);
  box-shadow: var(--sh-raise);
}

.range:hover::-webkit-slider-thumb,
.range:focus-visible::-webkit-slider-thumb {
  transform: scale(1.12);
}

.range:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 4px;
  border-radius: var(--r-sm);
}

.range-scale {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-2);
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   4. STEPPER
   ========================================================================== */

.stepper {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  background: var(--bg-inset);
  overflow: hidden;
}

.stepper__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--text-md);
  cursor: pointer;
  transition: background var(--dur-1) var(--ease-out),
    color var(--dur-1) var(--ease-out);
}

.stepper__btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.stepper__btn:disabled {
  color: var(--text-faint);
  cursor: not-allowed;
}

.stepper__unit {
  display: inline-flex;
  align-items: center;
  padding-inline: var(--sp-3);
  border-inline: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  color: var(--text-muted);
  white-space: nowrap;
}

/* ==========================================================================
   5. SEGMENTED CONTROL
   ========================================================================== */

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: var(--bg-inset);
  flex-wrap: wrap;
}

.segmented__btn {
  border: 0;
  background: transparent;
  border-radius: var(--r-sm);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-1) var(--ease-out),
    color var(--dur-1) var(--ease-out);
}

.segmented__btn:hover {
  color: var(--text-primary);
}

.segmented__btn[aria-pressed="true"] {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: var(--sh-raise);
}

/* ==========================================================================
   6. SELECT & TEXT INPUT
   ========================================================================== */

.select,
.input {
  width: 100%;
  min-width: 0;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  background: var(--bg-inset);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  transition: border-color var(--dur-1) var(--ease-out),
    box-shadow var(--dur-1) var(--ease-out);
}

.select:focus-visible,
.input:focus-visible {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-indigo-soft);
}

.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: var(--sp-8);
}

/* ==========================================================================
   7. SWITCH
   ========================================================================== */

.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  cursor: pointer;
}

.switch__label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.switch__track {
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: var(--r-full);
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  flex: none;
  transition: background var(--dur-2) var(--ease-out),
    border-color var(--dur-2) var(--ease-out);
}

.switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: var(--r-full);
  background: var(--text-muted);
  transition: transform var(--dur-2) var(--ease-spring),
    background var(--dur-2) var(--ease-out);
}

.switch input:checked + .switch__track {
  background: var(--accent-emerald-soft);
  border-color: var(--accent-emerald);
}

.switch input:checked + .switch__track::after {
  transform: translateX(16px);
  background: var(--accent-emerald);
}

.switch input:focus-visible + .switch__track {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* ==========================================================================
   8. PRESET BAR
   ========================================================================== */

.preset-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
  padding-block: var(--sp-3);
  border-top: 1px solid var(--border-subtle);
}

.preset-bar__label {
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--text-faint);
}

/* ==========================================================================
   9. TELEMETRY / KPI
   ========================================================================== */

.telemetry {
  display: grid;
  gap: var(--sp-4);
  min-width: 0;
}

.telemetry__hero {
  display: grid;
  gap: var(--sp-1);
  padding: var(--sp-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  background: var(--bg-inset);
}

.telemetry__label {
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--text-faint);
}

.telemetry__sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: var(--leading-snug);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--sp-3);
  min-width: 0;
}

.kpi {
  display: grid;
  gap: var(--sp-1);
  min-width: 0;
  padding: var(--sp-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: var(--bg-inset);
}

.kpi__value {
  font-family: var(--font-mono);
  font-size: var(--text-kpi);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
  /* Numerals must not wrap mid-value (a wrapped "₹1,20,000" reads as two
     figures). Text values are exempted below. */
  white-space: nowrap;
  min-width: 0;
  min-height: 1.2em;
}

/* The document generators use the hero KPI to show a long title
   ("Mutual NDA — 3-year term, Bengaluru, Karnataka"). nowrap there pushed the
   page 264px wide at 360px. data-fmt="raw" is exactly those cases. */
.kpi__value[data-fmt="raw"] {
  font-family: var(--font-sans);
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-snug);
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: var(--leading-snug);
}

/* The delta chip is injected by JS ("+3.2", "−₹12,000"). Width is reserved
   so a late value cannot reflow the KPI grid. */
.kpi__delta {
  display: inline-flex;
  /* .kpi is a grid, so an inline-flex child would still be stretched to the
     full column width — pin it to its content instead. */
  justify-self: start;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 22px;
  min-width: 4.6ch;
  padding-inline: var(--sp-2);
  border-radius: var(--r-xs);
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  margin-bottom: 4px;
}

.kpi__delta:empty {
  visibility: hidden;
}

.kpi__delta--up {
  color: var(--accent-emerald);
  background: var(--accent-emerald-softer);
}

.kpi__delta--down {
  color: var(--accent-rose);
  background: var(--accent-rose-softer);
}

.kpi__delta--flat {
  color: var(--text-muted);
  background: var(--bg-elevated);
}

.kpi-card {
  display: grid;
  gap: var(--sp-1);
  min-width: 0;
  padding: var(--sp-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: var(--bg-inset);
}

.kpi-card__label {
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--text-faint);
}

.kpi-card__value {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  white-space: nowrap;
  min-height: 1.2em;
}

.kpi-card__meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: var(--leading-snug);
}

/* ==========================================================================
   10. CHART SHELLS
   ========================================================================== */

.chart {
  position: relative;
  width: 100%;
  /* An explicit height on an SVG plus automatic width would otherwise
     transfer into a min-width and blow out narrow grids — pin it to zero. */
  min-width: 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  background: var(--bg-inset);
  contain: layout style;
}

.chart__head {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-1) var(--sp-3);
  padding: var(--sp-3) var(--sp-4) 0;
  pointer-events: none;
}

.chart__title {
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--text-faint);
}

.chart__legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.chart__legend li {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-2xs);
  color: var(--text-muted);
}

.chart__swatch {
  width: var(--swatch, 8px);
  height: var(--swatch, 8px);
  border-radius: 2px;
  background: currentColor;
  flex: none;
}

/* --- SVG geometry -------------------------------------------------------
   Every chart SVG is injected by JS with a viewBox and no height attribute.
   Left to height:auto the rendered height depends on the panel width, so the
   box resizes when the SVG lands and shifts everything below it (CLS).
   Each chart therefore pins its own SVG height, and preserveAspectRatio
   letterboxes the drawing inside it. Verified by the layout-shift observer
   at 390 / 768 / 1280 / 1920 and by test_p4 "chart contained" checks.
   ---------------------------------------------------------------------- */

/* The height lives on the CONTAINER, not on the SVG. Before JS injects the
   SVG the container would otherwise be 2px tall (borders only) and then jump
   to its full height — a large shift that pushed every panel below it. With a
   fixed container height the box is final at first paint and the SVG simply
   fills it. */

.chart--gauge {
  --chart-pad-t: 44px;
  --chart-pad-x: 8%;
  --chart-pad-b: 8px;
  height: 288px;
}

.chart--line,
.chart--bars {
  --chart-pad-t: 36px;
  --chart-pad-x: 12px;
  --chart-pad-b: 10px;
  height: 286px;
}

.chart--donut {
  --chart-pad-t: 36px;
  --chart-pad-x: 12px;
  --chart-pad-b: 10px;
  height: 266px;
}

/* The SVG is positioned by insets rather than by percentages. Two reasons:
   SVG does not honour box-sizing, so padding on the <svg> adds to its height,
   and Chrome resolves height:100% against the parent's padding box — both let
   the drawing spill past the envelope (test_p4 asserts svg.bottom <=
   chart.bottom). Insets are exact and independent of the parent's padding. */
.chart svg {
  position: absolute;
  top: var(--chart-pad-t, 36px);
  left: var(--chart-pad-x, 12px);
  width: calc(100% - (2 * var(--chart-pad-x, 12px)));
  height: calc(100% - var(--chart-pad-t, 36px) - var(--chart-pad-b, 10px) - 1px);
  max-width: calc(100% - (2 * var(--chart-pad-x, 12px)));
  max-height: calc(100% - var(--chart-pad-t, 36px) - var(--chart-pad-b, 10px) - 1px);
  overflow: hidden;
}

@media (max-width: 620px) {
  .chart--gauge {
    --chart-pad-t: 40px;
    --chart-pad-x: 6%;
    --chart-pad-b: 6px;
    height: 248px;
  }

  .chart--line,
  .chart--bars {
    --chart-pad-t: 32px;
    --chart-pad-x: 8px;
    --chart-pad-b: 8px;
    height: 240px;
  }

  .chart--donut {
    --chart-pad-t: 32px;
    --chart-pad-x: 8px;
    --chart-pad-b: 8px;
    height: 226px;
  }
}

/* --- SVG paint (classes emitted by the chart kit) ------------------------ */

.chart-grid-line {
  stroke: var(--viz-grid);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.chart-axis-label {
  fill: var(--viz-axis);
  font-family: var(--font-mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.chart-series {
  fill: none;
  stroke: var(--viz-1);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-area {
  fill: var(--viz-1);
  opacity: 0.12;
  stroke: none;
}

.chart-dot {
  fill: var(--bg-elevated);
  stroke: var(--viz-1);
  stroke-width: 2;
}

.chart-marker {
  stroke: var(--viz-2);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
}

.chart-marker-label {
  fill: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10px;
}

.bar {
  fill: var(--viz-1);
  rx: 3;
  transition: fill var(--dur-1) var(--ease-out);
}

.bar:hover {
  fill: var(--viz-2);
}

.donut-seg {
  stroke: var(--bg-inset);
  stroke-width: 2;
}

.gauge-track {
  fill: none;
  stroke: var(--viz-track);
  stroke-width: 14;
  stroke-linecap: round;
}

.gauge-arc {
  fill: none;
  stroke: var(--viz-1);
  stroke-width: 14;
  stroke-linecap: round;
  transition: stroke-dashoffset var(--dur-3) var(--ease-out),
    stroke var(--dur-2) var(--ease-out);
}

.gauge-value {
  fill: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  text-anchor: middle;
}

.gauge-unit {
  fill: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 11px;
  text-anchor: middle;
}

.gauge-label {
  fill: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 11px;
  text-anchor: middle;
}

/* ==========================================================================
   11. BENCHMARK TABLE
   ========================================================================== */

.data-table-wrap {
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  background: var(--bg-inset);
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

/* Caption reads "Industry benchmark · startup runway" — a title, so it sits
   above the table, left-aligned like the column heads. */
.data-table caption {
  caption-side: top;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--text-faint);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table tfoot td {
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-xs);
  color: var(--text-faint);
  line-height: var(--leading-snug);
  border-top: 1px solid var(--border-subtle);
}

.data-table th {
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.data-table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: top;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

/* Only the *numeric* trailing column is right-aligned. The benchmark table's
   last column is prose ("Cut burn now; bridge or begin fundraising"), so the
   default is left/flowing and cells opt in with .is-num. */
.data-table td.is-num,
.data-table th.is-num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.data-table tr[data-highlight] td,
.data-table tr.is-you td {
  background: var(--accent-emerald-softer);
  color: var(--text-primary);
}

/* Benchmark status pill. The renderer emits
   <span class="bench bench--bad|warn|healthy|elite">Critical</span>
   — a text label, not a bar. Tone carries the meaning; there is no fill. */
.bench {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 3px var(--sp-3);
  border-radius: var(--r-full);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  white-space: nowrap;
  border: 1px solid transparent;
}

.bench::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: var(--r-full);
  background: currentColor;
  flex: none;
}

.bench--bad {
  color: var(--accent-rose);
  background: var(--accent-rose-softer);
  border-color: var(--accent-rose-line);
}

.bench--warn {
  color: var(--accent-amber);
  background: var(--accent-amber-softer);
  border-color: var(--accent-amber-line);
}

.bench--healthy {
  color: var(--accent-emerald);
  background: var(--accent-emerald-softer);
  border-color: var(--accent-emerald-line);
}

.bench--elite {
  color: var(--accent-violet);
  background: var(--accent-violet-soft);
  border-color: var(--accent-violet);
}

/* ==========================================================================
   12. FORMULA BLOCKS
   ========================================================================== */

.formula {
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  background: var(--bg-inset);
  overflow: hidden;
}

.formula__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-subtle);
}

.formula__title {
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--text-faint);
}

.formula__body {
  padding: var(--sp-4);
  overflow-x: auto;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

.formula__body math {
  font-size: var(--text-md);
  color: var(--text-primary);
}

.formula__math {
  display: block;
  margin: 0;
  overflow-x: auto;
  font-size: var(--text-md);
  color: var(--text-primary);
}

.formula-canonical {
  margin: 0;
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-void);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: var(--leading-relaxed);
  color: var(--text-muted);
  white-space: pre-wrap;
  overflow-x: auto;
}

.formula__vars {
  display: grid;
  gap: var(--sp-1) var(--sp-4);
  margin: 0;
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-xs);
}

.formula__vars dt {
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.formula__vars dd {
  margin: 0 0 var(--sp-1);
  color: var(--text-muted);
}

@media (min-width: 620px) {
  .formula__vars {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .formula__vars dd {
    margin: 0;
  }
}

/* ==========================================================================
   13. HEALTH BANNER
   ========================================================================== */

.health {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: var(--bg-inset);
  /* The banner swaps tone and text after compute(); reserve the box. */
  min-height: 74px;
}

.health__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: var(--weight-bold);
}

.health__copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.health__title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.health--good {
  border-color: var(--accent-emerald-line);
  background: var(--accent-emerald-softer);
}

.health--good .health__icon {
  background: var(--accent-emerald);
  color: var(--bg-void);
}

.health--warn {
  border-color: var(--accent-amber-line);
  background: var(--accent-amber-softer);
}

.health--warn .health__icon {
  background: var(--accent-amber);
  color: var(--bg-void);
}

.health--bad {
  border-color: var(--accent-rose-line);
  background: var(--accent-rose-softer);
}

.health--bad .health__icon {
  background: var(--accent-rose);
  color: var(--bg-void);
}

.health--info {
  border-color: var(--accent-indigo-line);
  background: var(--accent-indigo-softer);
}

.health--info .health__icon {
  background: var(--accent-indigo);
  color: var(--bg-void);
}

/* ==========================================================================
   14. PRINT / PDF AUDIT SHEET
   ========================================================================== */

.print-header,
.print-note,
.doc-preview,
.doc-actions {
  display: none;
}

@media print {
  .workbench {
    display: block;
  }

  .workbench__telemetry {
    position: static;
  }

  .preset-bar,
  .doc-actions,
  .stepper,
  .segmented,
  .share-strip,
  .panel__foot {
    display: none !important;
  }

  .print-header {
    display: grid;
    gap: var(--sp-1);
    padding-bottom: var(--sp-3);
    margin-bottom: var(--sp-4);
    border-bottom: 1px solid var(--border-default);
  }

  .print-header__brand {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    color: var(--text-primary);
  }

  .print-header__meta,
  .print-note {
    font-size: var(--text-2xs);
    color: var(--text-muted);
  }

  .print-note {
    display: block;
    margin-top: var(--sp-4);
    padding-top: var(--sp-2);
    border-top: 1px solid var(--border-subtle);
  }

  .chart,
  .formula,
  .data-table-wrap,
  .kpi {
    break-inside: avoid;
  }

  .chart svg {
    height: 200px;
  }
}

/* ==========================================================================
   15. REDUCED MOTION
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .range::-webkit-slider-thumb,
  .switch__track,
  .switch__track::after,
  .gauge-arc,
  .bar,
  .segmented__btn,
  .stepper__btn {
    transition: none !important;
  }
}
