/* ============================================================================
   PackTwin · Coil Packaging & Transit Trial — module styles (owner: fe-shell)

   Namespace: every rule starts with .cz- so nothing here can collide with the
   host stylesheet. Tokens come from frontend/styles.css (--paper, --plate,
   --rule, --ink, --brand, --pass/--warn/--fail, fonts). The one deliberate
   addition is the provenance hue set: one hue per SPEC §0 data type, used for
   chips, table keys and legend swatches, so "where did this number come from"
   is answered by colour everywhere, consistently.

   Other frontend agents append their own clearly-delimited blocks at the END
   of this file only.
   ============================================================================ */

.cz-root {
  /* Visualisation panel theme (light default; dark via data-theme) */
  --cz-viz-bg:        #fafafa;
  --cz-viz-ink:       var(--ink);
  --cz-viz-mute:      var(--ink-mute);
  --cz-viz-rule:      var(--rule);
  --cz-viz-plate:     #ffffff;

  /* Provenance hues — hue angle per data type (kept ≥ 20° apart) */
  --cz-h-measured_lab_test:      148;
  --cz-h-measured_cad:           122;
  --cz-h-measured_field:         170;
  --cz-h-derived_from_measured:  192;
  --cz-h-simulated:              206;
  --cz-h-standard_profile:       236;
  --cz-h-reference_simulation:   266;
  --cz-h-literature:             296;
  --cz-h-parametric:             328;
  --cz-h-calibrated_parameter:   16;
  --cz-h-engineering_assumption: 42;
  --cz-h-user:                   60;

  --cz-form-w: minmax(380px, 5fr);
  --cz-viz-w:  minmax(0, 7fr);

  color: var(--ink);
  font-family: var(--font-ui);
  min-width: 0;
}

/* ─────────────────────────────────────────────────────────── header ── */

.cz-eyebrow {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
}

.cz-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--s-5);
  padding-bottom: var(--s-4);
  border-bottom: 1px solid var(--ink);
}
.cz-head__text { min-width: 0; }
.cz-head__eyebrow { display: block; margin-bottom: 6px; }
.cz-head__title { font-size: 30px; line-height: 1.1; letter-spacing: -0.02em; margin: 0; }
.cz-head__blurb { margin: 8px 0 0; max-width: 62ch; color: var(--ink-2); font-size: 14px; }
.cz-head__tools { display: flex; align-items: center; gap: var(--s-3); flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.cz-head__case {
  font-family: var(--font-mono); font-size: 12px; color: var(--ink-mute);
  padding: 5px 10px; border: 1px solid var(--rule); border-radius: var(--r-pill); background: var(--plate);
}
.cz-head__nav { display: flex; gap: 4px; }

/* Stage sequence strip: ten segments; state colours mirror the rail dots. */
.cz-steps { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; margin: var(--s-3) 0 var(--s-6); }
.cz-steps__seg { height: 3px; background: var(--rule); border-radius: 2px; transition: background var(--t-base); }
.cz-steps__seg[data-state="complete"] { background: var(--pass); }
.cz-steps__seg[data-state="active"]   { background: var(--brand-2); }
.cz-steps__seg.is-current { background: var(--brand); box-shadow: 0 0 0 2px var(--brand-tint); }

/* Theme toggle for the visualisation panels */
.cz-theme {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 10px 5px 6px; border-radius: var(--r-pill);
  border: 1px solid var(--rule); background: var(--plate); color: var(--ink-2);
  font: 500 12px/1 var(--font-ui);
}
.cz-theme:hover { border-color: var(--ink); color: var(--ink); }
.cz-theme__sun {
  width: 16px; height: 16px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffd766 0 38%, #e9a400 40% 100%);
  border: 1px solid #b57e00; transition: background var(--t-base), border-color var(--t-base);
}
.cz-theme[aria-pressed="true"] .cz-theme__sun {
  background: radial-gradient(circle at 60% 40%, #f3f5fa 0 30%, #7c8aa5 32% 100%);
  border-color: #3c4658;
}

/* ─────────────────────────────────────────────────────────── stage layout ── */

.cz-stage {
  display: grid;
  grid-template-columns: var(--cz-form-w) var(--cz-viz-w);
  gap: var(--s-5);
  align-items: start;
}
.cz-stage--single { grid-template-columns: minmax(0, 1fr); }
.cz-stage-mount { min-width: 0; }
.cz-form { display: flex; flex-direction: column; gap: var(--s-4); min-width: 0; }
.cz-viz {
  position: sticky; top: 72px;
  display: flex; flex-direction: column; gap: var(--s-3);
  min-width: 0;
  background: var(--cz-viz-bg); color: var(--cz-viz-ink);
  border: 1px solid var(--cz-viz-rule); border-radius: var(--r-md);
  padding: var(--s-4);
  transition: background var(--t-base), color var(--t-base), border-color var(--t-base);
}
.cz-viz__canvas {
  position: relative; width: 100%; aspect-ratio: 4 / 3; min-height: 280px;
  border-radius: var(--r-sm); overflow: hidden; background: var(--cz-viz-plate);
  border: 1px solid var(--cz-viz-rule);
}
.cz-viz__canvas canvas { display: block; width: 100%; height: 100%; }
.cz-viz__toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cz-viz__note { font-size: 12px; color: var(--cz-viz-mute); }

/* Dark visualisation theme (SPEC §5.5: #0f1115) */
.cz-root[data-theme="dark"] {
  --cz-viz-bg:    #0f1115;
  --cz-viz-plate: #161a21;
  --cz-viz-ink:   #e8e9ec;
  --cz-viz-mute:  #9aa1ad;
  --cz-viz-rule:  #2a2f3a;
}
.cz-root[data-theme="dark"] .cz-viz .cz-legend,
.cz-root[data-theme="dark"] .cz-viz .cz-kpi,
.cz-root[data-theme="dark"] .cz-viz .cz-tabs,
.cz-root[data-theme="dark"] .cz-viz .cz-plate { background: var(--cz-viz-plate); border-color: var(--cz-viz-rule); color: var(--cz-viz-ink); }
.cz-root[data-theme="dark"] .cz-viz .cz-kpi__label,
.cz-root[data-theme="dark"] .cz-viz .cz-eyebrow,
.cz-root[data-theme="dark"] .cz-viz .cz-kpi__unit,
.cz-root[data-theme="dark"] .cz-viz .cz-legend__tick { color: var(--cz-viz-mute); }
.cz-root[data-theme="dark"] .cz-viz .cz-tab { color: var(--cz-viz-mute); }
.cz-root[data-theme="dark"] .cz-viz .cz-tab[aria-selected="true"] { color: var(--cz-viz-ink); border-color: var(--brand-2); }
.cz-root[data-theme="dark"] .cz-viz .cz-btn--ghost,
.cz-root[data-theme="dark"] .cz-viz .cz-btn--secondary { color: var(--cz-viz-ink); border-color: var(--cz-viz-rule); }
.cz-root[data-theme="dark"] .cz-viz .cz-btn--ghost:hover,
.cz-root[data-theme="dark"] .cz-viz .cz-btn--secondary:hover { background: #1f2430; }
.cz-root[data-theme="dark"] .cz-viz .cz-seg { background: #1f2430; border-color: var(--cz-viz-rule); }
.cz-root[data-theme="dark"] .cz-viz .cz-seg__btn { color: var(--cz-viz-mute); }
.cz-root[data-theme="dark"] .cz-viz .cz-seg__btn[aria-checked="true"] { background: #2a3140; color: var(--cz-viz-ink); }
.cz-root[data-theme="dark"] .cz-viz .cz-select,
.cz-root[data-theme="dark"] .cz-viz .cz-input { background: #1f2430; color: var(--cz-viz-ink); border-color: var(--cz-viz-rule); }
.cz-root[data-theme="dark"] .cz-viz .cz-table th { color: var(--cz-viz-mute); border-color: var(--cz-viz-rule); }
.cz-root[data-theme="dark"] .cz-viz .cz-table td { border-color: var(--cz-viz-rule); }

/* ─────────────────────────────────────────────────────────── plates ── */

.cz-plate {
  background: var(--plate);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  padding: var(--s-5);
  min-width: 0;
}
.cz-plate--feature { border-color: var(--ink); }
.cz-plate--muted { background: var(--plate-2); }
.cz-plate--pass { border-color: var(--pass); }
.cz-plate--warn { border-color: var(--warn); }
.cz-plate--fail { border-color: var(--fail); }
.cz-plate__head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s-4); margin-bottom: var(--s-4); }
.cz-plate__head .cz-eyebrow { display: block; margin-bottom: 4px; }
.cz-plate__title { font-size: 16px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.cz-plate__sub { margin: 4px 0 0; font-size: 13px; color: var(--ink-mute); }
.cz-plate__actions { display: flex; gap: 6px; flex-shrink: 0; }
.cz-plate__body { display: flex; flex-direction: column; gap: var(--s-4); }
.cz-plate__body > p { margin: 0; }

.cz-section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--s-4); margin: var(--s-2) 0 var(--s-3); }
.cz-section-head .cz-eyebrow { display: block; margin-bottom: 4px; }
.cz-section-head__title { font-size: 18px; margin: 0; letter-spacing: -0.01em; }
.cz-section-head__sub { margin: 4px 0 0; font-size: 13px; color: var(--ink-mute); max-width: 70ch; }
.cz-section-head__actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ─────────────────────────────────────────────────────────── buttons ── */

.cz-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 500 14px/1 var(--font-ui); letter-spacing: 0.01em;
  padding: 11px 18px; border-radius: var(--r-sm); border: 1px solid transparent;
  cursor: pointer; white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.cz-btn--sm { padding: 7px 12px; font-size: 12.5px; }
.cz-btn--lg { padding: 14px 24px; font-size: 15px; font-weight: 600; }
.cz-btn--primary { background: var(--brand); color: #fff; box-shadow: 0 1px 0 var(--brand-3) inset; }
.cz-btn--primary:hover { background: var(--brand-2); }
.cz-btn--primary:active { background: var(--brand-3); }
.cz-btn--secondary { background: transparent; color: var(--brand); border-color: var(--brand); }
.cz-btn--secondary:hover { background: var(--brand-tint); }
.cz-btn--ghost { background: transparent; color: var(--ink-2); border-color: var(--rule); }
.cz-btn--ghost:hover { border-color: var(--ink); color: var(--ink); }
.cz-btn--danger { background: transparent; color: var(--fail); border-color: var(--fail); }
.cz-btn--danger:hover { background: var(--fail-tint); }
.cz-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.cz-btn:focus-visible, .cz-input:focus-visible, .cz-toggle:focus-visible, .cz-seg__btn:focus-visible, .cz-tab:focus-visible, .cz-theme:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}
.cz-btn__icon { font-size: 1.05em; line-height: 1; }

/* Stage footer: back / continue */
.cz-stage-foot {
  display: flex; justify-content: space-between; align-items: center; gap: var(--s-3);
  padding-top: var(--s-4); border-top: 1px solid var(--rule); margin-top: var(--s-2);
}
.cz-stage-foot__note { font-size: 12.5px; color: var(--ink-mute); }

/* ─────────────────────────────────────────────────────────── forms ── */

.cz-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; width: var(--cz-field-w, auto); }
.cz-field--inline { flex-direction: row; align-items: center; justify-content: space-between; gap: var(--s-3); }
.cz-field--inline .cz-field__label { flex: 1; }
.cz-field__label { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.cz-field__name { color: var(--ink); }
.cz-field__control { position: relative; display: flex; align-items: stretch; }
.cz-field__control.has-unit .cz-input { padding-right: 56px; }
.cz-unit {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono); font-size: 12px; color: var(--ink-mute); pointer-events: none;
}
.cz-field__hint { font-size: 12px; color: var(--ink-mute); line-height: 1.45; }
.cz-field__error { font-size: 12px; color: var(--fail); }
.cz-field.has-error .cz-input { border-color: var(--fail); }
.cz-field-grid { display: grid; grid-template-columns: repeat(var(--cz-cols, 2), minmax(0, 1fr)); gap: var(--s-3) var(--s-4); }
.cz-field-grid .cz-field--span { grid-column: 1 / -1; }

.cz-input {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--rule-strong); border-radius: var(--r-sm);
  font: 400 14px/1.4 var(--font-ui); color: var(--ink); background: var(--paper);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.cz-input--number { font-family: var(--font-mono); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.cz-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); background: var(--plate); }
.cz-input:disabled { opacity: 0.55; cursor: not-allowed; }
.cz-input.is-readonly { background: var(--plate-2); border-style: dashed; }
.cz-input.is-invalid { border-color: var(--fail); box-shadow: 0 0 0 3px var(--fail-tint); }
.cz-input::-webkit-outer-spin-button, .cz-input::-webkit-inner-spin-button { opacity: 0.6; }
.cz-select {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-mute) 50%), linear-gradient(135deg, var(--ink-mute) 50%, transparent 50%);
  background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}

/* Toggle switch */
.cz-toggle { display: inline-flex; align-items: center; gap: 10px; background: none; border: 0; padding: 4px 0; cursor: pointer; color: var(--ink-2); font: 500 13px/1 var(--font-ui); }
.cz-toggle__track { position: relative; width: 36px; height: 20px; border-radius: 10px; background: var(--rule-strong); transition: background var(--t-fast); flex-shrink: 0; }
.cz-toggle__knob { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(26,29,34,0.25); transition: transform var(--t-fast) var(--ease-out); }
.cz-toggle[aria-checked="true"] .cz-toggle__track { background: var(--brand); }
.cz-toggle[aria-checked="true"] .cz-toggle__knob { transform: translateX(16px); }
.cz-toggle:disabled { opacity: 0.5; cursor: not-allowed; }

/* Segmented control */
.cz-seg { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--plate-2); max-width: 100%; flex-wrap: wrap; }
.cz-seg__btn {
  border: 0; background: transparent; color: var(--ink-2);
  font: 500 13px/1 var(--font-ui); padding: 7px 12px; border-radius: 4px; cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.cz-seg--sm .cz-seg__btn { padding: 5px 9px; font-size: 12px; }
.cz-seg__btn:hover { color: var(--ink); }
.cz-seg__btn[aria-checked="true"] { background: var(--plate); color: var(--brand); box-shadow: 0 1px 2px rgba(26,29,34,0.08); }
.cz-seg__btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Dropzone (Product stage CAD upload) */
.cz-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: var(--s-6) var(--s-4); text-align: center;
  border: 1.5px dashed var(--rule-strong); border-radius: var(--r-md); background: var(--paper);
  color: var(--ink-2); font-size: 13.5px; cursor: pointer; transition: border-color var(--t-fast), background var(--t-fast);
}
.cz-drop:hover, .cz-drop.is-over { border-color: var(--brand); background: var(--brand-tint-2); }
.cz-drop__formats { font-family: var(--font-mono); font-size: 11px; color: var(--ink-mute); letter-spacing: 0.04em; }

/* ─────────────────────────────────────────────────────────── KPI cards ── */

.cz-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: var(--s-2); }
.cz-kpi {
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
  padding: 12px 14px; background: var(--plate); border: 1px solid var(--rule); border-radius: var(--r-sm);
  border-left-width: 3px;
}
.cz-kpi[data-tone="pass"] { border-left-color: var(--pass); }
.cz-kpi[data-tone="warn"] { border-left-color: var(--warn); }
.cz-kpi[data-tone="fail"] { border-left-color: var(--fail); }
.cz-kpi__label { font-size: 11.5px; color: var(--ink-mute); line-height: 1.3; }
.cz-kpi__value { display: flex; align-items: baseline; gap: 5px; flex-wrap: wrap; }
.cz-kpi__num { font-family: var(--font-mono); font-size: 20px; font-weight: 500; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.cz-kpi[data-tone="fail"] .cz-kpi__num { color: var(--fail); }
.cz-kpi[data-tone="warn"] .cz-kpi__num { color: var(--warn); }
.cz-kpi[data-tone="pass"] .cz-kpi__num { color: var(--pass); }
.cz-kpi__unit { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-mute); }
.cz-kpi__foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.cz-kpi__delta { font-family: var(--font-mono); font-size: 11.5px; }
.cz-kpi__delta[data-sign="pos"] { color: var(--pass); }
.cz-kpi__delta[data-sign="neg"] { color: var(--fail); }
.cz-kpi__note { font-size: 11px; color: var(--ink-mute); }

/* ─────────────────────────────────────────────────────────── provenance chips ── */

.cz-prov {
  --h: 0;
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.02em; line-height: 1;
  padding: 4px 8px 4px 6px; border-radius: var(--r-pill);
  color: hsl(var(--h) 42% 28%);
  background: hsl(var(--h) 55% 95%);
  border: 1px solid hsl(var(--h) 38% 78%);
  white-space: nowrap; vertical-align: middle; cursor: help;
}
.cz-prov--compact { padding: 2px 6px 2px 5px; font-size: 10px; }
.cz-prov__dot { width: 6px; height: 6px; border-radius: 50%; background: hsl(var(--h) 60% 42%); flex-shrink: 0; }
.cz-prov__src { color: hsl(var(--h) 25% 45%); }
.cz-prov__src::before { content: "·"; margin-right: 5px; }
.cz-prov[data-type="measured_lab_test"]      { --h: var(--cz-h-measured_lab_test); }
.cz-prov[data-type="measured_cad"]           { --h: var(--cz-h-measured_cad); }
.cz-prov[data-type="measured_field"]         { --h: var(--cz-h-measured_field); }
.cz-prov[data-type="derived_from_measured"]  { --h: var(--cz-h-derived_from_measured); }
.cz-prov[data-type="simulated"]              { --h: var(--cz-h-simulated); }
.cz-prov[data-type="standard_profile"]       { --h: var(--cz-h-standard_profile); }
.cz-prov[data-type="reference_simulation"]   { --h: var(--cz-h-reference_simulation); }
.cz-prov[data-type="literature"]             { --h: var(--cz-h-literature); }
.cz-prov[data-type="parametric"]             { --h: var(--cz-h-parametric); }
.cz-prov[data-type="calibrated_parameter"]   { --h: var(--cz-h-calibrated_parameter); }
.cz-prov[data-type="engineering_assumption"] { --h: var(--cz-h-engineering_assumption); }
.cz-prov[data-type="user"]                   { --h: var(--cz-h-user); color: hsl(var(--h) 10% 30%); background: hsl(var(--h) 15% 95%); border-color: hsl(var(--h) 12% 78%); }
.cz-prov[data-type="user"] .cz-prov__dot     { background: hsl(var(--h) 10% 45%); }
.cz-prov[data-type="unknown"]                { color: var(--fail); background: var(--fail-tint); border-color: var(--fail); border-style: dashed; }
.cz-prov[data-type="unknown"] .cz-prov__dot  { background: var(--fail); }

/* Evidence ladder banner */
.cz-ladder {
  display: flex; align-items: stretch; gap: 10px; flex-wrap: wrap;
  padding: 12px 14px; border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--plate-2);
}
.cz-ladder__rung { display: flex; flex-direction: column; gap: 5px; min-width: 0; flex: 1 1 160px; }
.cz-ladder__label { font-size: 13px; font-weight: 600; color: var(--ink); }
.cz-ladder__meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cz-ladder__note { font-size: 11.5px; color: var(--ink-mute); }
.cz-ladder__arrow { align-self: center; color: var(--ink-mute-2); font-size: 18px; }

/* ─────────────────────────────────────────────────────────── verdict ── */

.cz-verdict-badge {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 500; letter-spacing: 0.12em;
  padding: 5px 11px 5px 9px; border-radius: var(--r-pill); border: 1px solid transparent; white-space: nowrap;
}
.cz-verdict-badge--lg { font-size: 14px; padding: 9px 16px 9px 13px; }
.cz-verdict-badge__dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.cz-verdict-badge--lg .cz-verdict-badge__dot { width: 10px; height: 10px; }
.cz-verdict-badge[data-verdict="PASS"]     { color: var(--pass); background: var(--pass-tint); border-color: var(--pass); }
.cz-verdict-badge[data-verdict="MARGINAL"] { color: var(--warn); background: var(--warn-tint); border-color: var(--warn); }
.cz-verdict-badge[data-verdict="FAIL"]     { color: var(--fail); background: var(--fail-tint); border-color: var(--fail); }
.cz-verdict-badge[data-verdict="PENDING"]  { color: var(--ink-mute); background: var(--plate-2); border-color: var(--rule-strong); }

.cz-verdict {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-5); align-items: center;
  padding: var(--s-5) var(--s-6); border-radius: var(--r-md);
  background: var(--plate); border: 1px solid var(--rule); border-left: 6px solid var(--ink-mute-2);
}
.cz-verdict[data-verdict="PASS"]     { border-left-color: var(--pass); }
.cz-verdict[data-verdict="MARGINAL"] { border-left-color: var(--warn); }
.cz-verdict[data-verdict="FAIL"]     { border-left-color: var(--fail); background: linear-gradient(90deg, var(--fail-tint) 0, var(--plate) 45%); }
.cz-verdict__main { display: flex; align-items: center; gap: var(--s-4); min-width: 0; }
.cz-verdict__headline { font-size: 22px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.2; }
.cz-verdict__reason { margin: 4px 0 0; font-size: 13.5px; color: var(--ink-2); max-width: 70ch; }
.cz-verdict__stats { display: flex; gap: var(--s-5); }
.cz-verdict__stat { display: flex; flex-direction: column; gap: 2px; min-width: 110px; }
.cz-verdict__k { font-size: 11.5px; color: var(--ink-mute); }
.cz-verdict__v { font-family: var(--font-mono); font-size: 20px; font-weight: 500; font-variant-numeric: tabular-nums; }
.cz-verdict__c { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-mute); }

/* ─────────────────────────────────────────────────────────── tabs ── */

.cz-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--rule); overflow-x: auto; scrollbar-width: none; }
.cz-tabs::-webkit-scrollbar { display: none; }
.cz-tab {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  padding: 9px 12px; font: 500 13px/1 var(--font-ui); color: var(--ink-mute); cursor: pointer; white-space: nowrap;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.cz-tab:hover { color: var(--ink); }
.cz-tab[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); }
.cz-tab:disabled { opacity: 0.4; cursor: not-allowed; }
.cz-tab__badge { font-family: var(--font-mono); font-size: 10px; padding: 1px 6px; border-radius: var(--r-pill); background: var(--plate-2); color: var(--ink-mute); }

/* ─────────────────────────────────────────────────────────── tables ── */

.cz-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--plate); }
.cz-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cz-table th {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-mute); padding: 9px 12px; border-bottom: 1px solid var(--rule-strong); background: var(--plate-2); white-space: nowrap;
}
.cz-table__unit { text-transform: none; letter-spacing: 0; margin-left: 4px; color: var(--ink-mute-2); }
.cz-table__unit::before { content: "("; } .cz-table__unit::after { content: ")"; }
.cz-table td { padding: 9px 12px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.cz-table tbody tr:last-child td { border-bottom: 0; }
.cz-table__num { font-family: var(--font-mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.cz-table__empty { color: var(--ink-mute); text-align: center; padding: var(--s-5) !important; }
.cz-table--compact th, .cz-table--compact td { padding: 6px 10px; }
.cz-table tr.is-clickable { cursor: pointer; }
.cz-table tr.is-clickable:hover td { background: var(--brand-tint-2); }
.cz-table tr.is-active td { background: var(--brand-tint); }
.cz-table td[data-status="pass"], .cz-status--pass { color: var(--pass); font-weight: 600; }
.cz-table td[data-status="warn"], .cz-status--warn { color: var(--warn); font-weight: 600; }
.cz-table td[data-status="fail"], .cz-status--fail { color: var(--fail); font-weight: 600; }

/* ─────────────────────────────────────────────────────────── legend ── */

.cz-legend {
  display: flex; flex-direction: column; gap: 5px;
  padding: 10px 12px; border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--plate); min-width: 0;
}
.cz-legend__title { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 600; }
.cz-legend__unit { font-family: var(--font-mono); font-weight: 400; color: var(--ink-mute); font-size: 11px; }
.cz-legend__bar { height: 10px; border-radius: 3px; background: linear-gradient(90deg, #1f4de0 0%, #1fb35c 25%, #f2d21f 50%, #f28a1f 75%, #d81f1f 100%); }
.cz-legend__bar canvas { display: block; width: 100%; height: 100%; border-radius: 3px; }
.cz-legend__ticks { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-mute); font-variant-numeric: tabular-nums; }
.cz-legend__keys { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.cz-legend__key { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.cz-legend__swatch { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }

/* ─────────────────────────────────────────────────────────── timeline ── */

.cz-timeline { position: relative; padding: var(--s-4) 0 var(--s-3); overflow-x: auto; }
.cz-timeline__track { position: relative; display: flex; align-items: stretch; min-width: 640px; height: 64px; }
.cz-timeline__axis { position: absolute; left: 0; right: 0; top: 30px; height: 2px; background: var(--rule-strong); }
.cz-timeline__leg {
  position: absolute; top: 20px; height: 22px; border-radius: 3px;
  background: var(--brand-tint); border: 1px solid var(--brand); color: var(--brand-3);
  display: flex; align-items: center; padding: 0 8px; font-family: var(--font-mono); font-size: 10.5px; white-space: nowrap; overflow: hidden;
  cursor: pointer; transition: box-shadow var(--t-fast);
}
.cz-timeline__leg[data-mode="ship"] { background: hsl(192 60% 92%); border-color: hsl(192 50% 40%); color: hsl(192 60% 24%); }
.cz-timeline__leg[data-mode="rail"] { background: hsl(266 50% 94%); border-color: hsl(266 40% 45%); color: hsl(266 50% 28%); }
.cz-timeline__leg[data-mode="air"]  { background: hsl(236 50% 94%); border-color: hsl(236 40% 48%); color: hsl(236 50% 30%); }
.cz-timeline__leg[data-mode="van"]  { background: hsl(206 55% 92%); border-color: hsl(206 55% 42%); color: hsl(206 60% 26%); }
.cz-timeline__leg[data-risk="warn"] { border-color: var(--warn); background: var(--warn-tint); color: var(--warn); }
.cz-timeline__leg[data-risk="fail"] { border-color: var(--fail); background: var(--fail-tint); color: var(--fail); }
.cz-timeline__leg.is-selected, .cz-timeline__event.is-selected { box-shadow: 0 0 0 3px var(--brand-tint), 0 0 0 4px var(--brand); }
.cz-timeline__dwell { position: absolute; top: 24px; height: 14px; border-radius: 2px; background: repeating-linear-gradient(90deg, var(--rule) 0 4px, transparent 4px 8px); }
.cz-timeline__station { position: absolute; top: 0; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.cz-timeline__station-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--plate); border: 2px solid var(--ink); }
.cz-timeline__station-label { font-size: 10.5px; color: var(--ink-2); white-space: nowrap; }
.cz-timeline__event {
  position: absolute; top: 44px; transform: translateX(-50%);
  width: 12px; height: 12px; border-radius: 2px; rotate: 45deg;
  background: var(--warn); border: 1px solid var(--plate); cursor: pointer;
}
.cz-timeline__event[data-risk="fail"] { background: var(--fail); }
.cz-timeline__event[data-risk="pass"] { background: var(--pass); }
.cz-timeline__scale { display: flex; justify-content: space-between; margin-top: 6px; font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-mute); min-width: 640px; }
.cz-timeline__detail { margin-top: var(--s-3); padding: 12px 14px; border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--plate-2); }
.cz-timeline__detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px 16px; }
.cz-timeline__detail-k { font-size: 11px; color: var(--ink-mute); }
.cz-timeline__detail-v { font-family: var(--font-mono); font-size: 13px; font-variant-numeric: tabular-nums; }

/* ─────────────────────────────────────────────────────────── misc blocks ── */

.cz-empty { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: var(--s-5); border: 1px dashed var(--rule-strong); border-radius: var(--r-sm); background: var(--paper); }
.cz-empty__title { font-weight: 600; font-size: 14px; }
.cz-empty__hint { margin: 0; font-size: 13px; color: var(--ink-mute); max-width: 60ch; }

.cz-placeholder { max-width: 720px; }
.cz-placeholder__blurb { color: var(--ink-2); }
.cz-placeholder__status { font-family: var(--font-mono); font-size: 12px; color: var(--ink-mute); }
.cz-placeholder__note { font-size: 13px; color: var(--ink-2); }
.cz-placeholder__actions { display: flex; gap: 8px; }

.cz-spinner { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-mute); }
.cz-spinner__ring { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--rule-strong); border-top-color: var(--brand); animation: cz-spin 0.9s linear infinite; }
@keyframes cz-spin { to { transform: rotate(360deg); } }

.cz-note { font-size: 12.5px; color: var(--ink-mute); line-height: 1.5; }
.cz-note--model { padding: 10px 12px; border-left: 3px solid var(--rule-strong); background: var(--plate-2); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.cz-inline-list { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.cz-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.cz-muted { color: var(--ink-mute); }

/* ─────────────────────────────────────────────────────────── toasts ── */

.cz-toasts { position: fixed; right: 20px; bottom: 20px; z-index: 900; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.cz-toast {
  display: flex; align-items: stretch; gap: 10px; pointer-events: auto;
  background: var(--ink); color: var(--paper); border-radius: var(--r-sm);
  padding: 10px 10px 10px 0; box-shadow: var(--shadow-pop); overflow: hidden;
  animation: cz-toast-in var(--t-base) var(--ease-out);
}
.cz-toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity 200ms, transform 200ms; }
.cz-toast__bar { width: 4px; border-radius: 0 2px 2px 0; background: var(--brand-2); flex-shrink: 0; }
.cz-toast[data-kind="success"] .cz-toast__bar { background: #4ec27a; }
.cz-toast[data-kind="warn"] .cz-toast__bar { background: #e2a93a; }
.cz-toast[data-kind="error"] .cz-toast__bar { background: #e2675b; }
.cz-toast__body { flex: 1; min-width: 0; font-size: 13px; line-height: 1.4; }
.cz-toast__title { font-weight: 600; }
.cz-toast__msg { color: #d6d3cc; overflow-wrap: anywhere; }
.cz-toast__close { background: none; border: 0; color: #b3ada1; font-size: 18px; line-height: 1; padding: 0 6px; cursor: pointer; align-self: flex-start; }
.cz-toast__close:hover { color: var(--paper); }
@keyframes cz-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ─────────────────────────────────────────────────────────── modal ── */

.cz-modal-backdrop {
  position: fixed; inset: 0; z-index: 800;
  display: flex; align-items: center; justify-content: center; padding: var(--s-4);
  background: rgba(26, 29, 34, 0.45); backdrop-filter: blur(2px);
  animation: cz-fade-in var(--t-fast) ease-out;
}
.cz-modal-backdrop.is-leaving { opacity: 0; transition: opacity 160ms; }
.cz-modal {
  width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  background: var(--plate); border: 1px solid var(--ink); border-radius: var(--r-lg);
  padding: var(--s-6); box-shadow: var(--shadow-pop);
}
.cz-modal--wide { width: min(920px, 100%); }
.cz-modal__head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s-4); margin-bottom: var(--s-4); }
.cz-modal__head .cz-eyebrow { display: block; margin-bottom: 4px; }
.cz-modal__title { font-size: 20px; margin: 0; }
.cz-modal__close { background: none; border: 1px solid var(--rule); border-radius: 50%; width: 30px; height: 30px; font-size: 18px; line-height: 1; color: var(--ink-mute); cursor: pointer; }
.cz-modal__close:hover { border-color: var(--ink); color: var(--ink); }
.cz-modal__body { display: flex; flex-direction: column; gap: var(--s-4); }
.cz-modal__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: var(--s-5); }
@keyframes cz-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Processing overlay variant for the simulation run (mirrors #processing) */
.cz-processing { position: fixed; inset: 0; z-index: 850; display: flex; align-items: center; justify-content: center; background: rgba(247, 244, 238, 0.92); backdrop-filter: blur(3px); }
.cz-processing__card { width: min(520px, calc(100% - 32px)); background: var(--plate); border: 1px solid var(--ink); border-radius: var(--r-lg); padding: var(--s-6); display: flex; flex-direction: column; gap: var(--s-4); }
.cz-processing__title { font-size: 22px; margin: 0; }
.cz-processing__line { font-size: 14px; color: var(--ink-2); min-height: 1.5em; }
.cz-processing__bar { height: 4px; background: var(--plate-2); border-radius: 2px; overflow: hidden; }
.cz-processing__fill { height: 100%; width: 10%; background: var(--brand); border-radius: 2px; transition: width 600ms var(--ease-out); }
.cz-processing__foot { font-family: var(--font-mono); font-size: 11px; color: var(--ink-mute); }

/* ─────────────────────────────────────────────────────────── rail ── */

/* The coil rail reuses .stages/.stage from the host; only the grouping
   hairlines between config / transit / results blocks are added here. */
.stages--coil .stage[data-stage="transit"],
.stages--coil .stage[data-stage="results"] { margin-top: 6px; }
.stages--coil .stage[data-stage="transit"]::before,
.stages--coil .stage[data-stage="results"]::before {
  content: ""; position: absolute; left: 12px; right: 12px; top: -4px; height: 1px; background: var(--rule);
}

/* ─────────────────────────────────────────────────────────── responsive ── */

@media (max-width: 1100px) {
  .cz-stage { grid-template-columns: minmax(0, 1fr); }
  .cz-viz { position: static; }
  .cz-verdict { grid-template-columns: minmax(0, 1fr); }
  .cz-verdict__stats { flex-wrap: wrap; gap: var(--s-4); }
  .cz-head { flex-direction: column; align-items: flex-start; }
  .cz-head__tools { justify-content: flex-start; }
}
@media (max-width: 760px) {
  .cz-head__title { font-size: 24px; }
  .cz-field-grid { grid-template-columns: minmax(0, 1fr); }
  .cz-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cz-plate { padding: var(--s-4); }
  .cz-modal { padding: var(--s-5); }
  .cz-ladder__arrow { display: none; }
  .cz-viz__canvas { min-height: 220px; }
}

@media (prefers-reduced-motion: reduce) {
  .cz-toast, .cz-modal-backdrop, .cz-spinner__ring { animation: none; }
  .cz-toggle__knob, .cz-steps__seg, .cz-viz, .cz-processing__fill { transition: none; }
}

@media print {
  .cz-head__tools, .cz-steps, .cz-toasts, .cz-stage-foot { display: none !important; }
  .cz-stage { grid-template-columns: minmax(0, 1fr); }
  .cz-viz { position: static; border: 0; }
}

/* ============================================================================
   End of fe-shell block. Other frontend agents append below this line only,
   each inside its own clearly-delimited comment block.
   ============================================================================ */

/* ============================================================================
   fe-integrate block — cross-module presentation fixes.
   Scoped so they only apply while the coil page is the active stage page.
   ============================================================================ */

/* The host stylesheet carries a "JS-fail safety net" rule
   (`main.canvas > section.stage-page:first-of-type { display: block; }`) that
   keeps the Intake section rendered on every route, so the coil page is
   pushed ~1000px below the fold and looks blank on arrival. While the coil
   page is the active one, collapse that non-active first section. Nothing
   outside the coil route is affected; the safety net still works whenever
   no stage page is active (i.e. when the host script really did fail). */
body:has(.stage-page[data-page="coil"].active)
  main.canvas > section.stage-page:first-of-type:not(.active) {
  display: none;
}

/* ============================================================================
   fe-transit block — Transit trial + Simulation stages and the shared journey
   timeline (frontend/coil/stages-transit.js).  Namespace: .czt-*, plus a
   handful of modifiers on the .cz-timeline vocabulary already defined above.
   Appended after the fe-shell block; nothing above this line is edited.
   ============================================================================ */

/* ── demo / provenance notices ─────────────────────────────────────────── */

.czt-banner {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  border: 1px dashed var(--warn); border-radius: var(--r-sm);
  background: var(--warn-tint);
  font-size: 12.5px; line-height: 1.45; color: var(--ink-2);
}
.czt-banner__tag {
  flex-shrink: 0;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em;
  padding: 3px 7px; border-radius: var(--r-pill);
  background: var(--warn); color: var(--paper);
}
.czt-banner__text { min-width: 0; }

.czt-prov-line {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--ink-mute); line-height: 1.5;
}
.czt-prov-line__k { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; }
.czt-prov-line__src,
.czt-code {
  font-family: var(--font-mono); font-size: 10.5px;
  padding: 1px 5px; border-radius: 3px;
  background: var(--plate-2); border: 1px solid var(--rule);
  overflow-wrap: anywhere;
}
.czt-prov-line__text { flex: 1 1 220px; min-width: 0; }
.czt-series { display: flex; flex-direction: column; gap: 6px; }

.czt-provlist { display: flex; flex-direction: column; gap: 10px; }
.czt-provlist__item {
  display: flex; flex-direction: column; gap: 4px;
  padding-bottom: 10px; border-bottom: 1px solid var(--rule);
}
.czt-provlist__item:last-child { padding-bottom: 0; border-bottom: 0; }
.czt-provlist__head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.czt-provlist__name { font-family: var(--font-mono); font-size: 12px; font-weight: 600; }
.czt-provlist__meta { font-size: 11px; color: var(--ink-mute); font-variant-numeric: tabular-nums; }
.czt-provlist__src { align-self: flex-start; max-width: 100%; }
.czt-provlist__note { margin: 0; font-size: 11.5px; line-height: 1.5; color: var(--ink-2); }

/* ── stage layout ──────────────────────────────────────────────────────── */

/* The transit stage is form-heavy: give the builder more of the grid than the
   shell's default 5fr / 7fr split, without touching the shell rule. */
.czt-stage { --cz-form-w: minmax(0, 1fr); --cz-viz-w: minmax(340px, 1fr); }

/* ── leg builder ───────────────────────────────────────────────────────── */

.czt-legs { display: flex; flex-direction: column; gap: var(--s-4); }
.czt-legs__foot { display: flex; justify-content: flex-start; }
.czt-leg { border-left: 3px solid var(--brand); }
.czt-leg__modes { display: flex; flex-direction: column; gap: 6px; }
.czt-leg__tools { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }

.czt-profile-wrap { display: flex; flex-direction: column; gap: 8px; }
.czt-profile {
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--rule); border-left: 3px solid hsl(var(--cz-h-measured_field) 45% 45%);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  background: var(--plate-2);
}
.czt-profile__head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.czt-profile__label { font-size: 13px; font-weight: 600; }
.czt-profile__stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px 14px; }
.czt-stat { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.czt-stat__k { font-size: 10.5px; color: var(--ink-mute); }
.czt-stat__v { font-size: 12.5px; overflow-wrap: anywhere; }
.czt-profile__cite { margin: 0; font-size: 11.5px; line-height: 1.5; color: var(--ink-2); }
.czt-profile__src { margin: 0; font-size: 11px; color: var(--ink-mute); overflow-wrap: anywhere; }
.czt-profile__src code { font-family: var(--font-mono); font-size: 10.5px; }

/* ── per-leg event list ────────────────────────────────────────────────── */

.czt-events { border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--plate); }
.czt-events__summary {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding: 9px 12px; cursor: pointer; font-size: 13px; font-weight: 500;
  list-style: none;
}
.czt-events__summary::-webkit-details-marker { display: none; }
.czt-events__summary::before { content: "▸"; color: var(--ink-mute); font-size: 11px; }
.czt-events[open] > .czt-events__summary::before { content: "▾"; }
.czt-events__hint { font-size: 11px; color: var(--ink-mute); font-weight: 400; }
.czt-events__body { display: flex; flex-direction: column; gap: 10px; padding: 0 12px 12px; }
.czt-events__actions { display: flex; gap: 6px; flex-wrap: wrap; }
.czt-row-act { display: inline-flex; gap: 2px; justify-content: flex-end; }
.czt-event-form { display: flex; flex-direction: column; gap: var(--s-4); }
.czt-event-form__prov { display: flex; flex-direction: column; gap: 6px; }

/* ── live preview ──────────────────────────────────────────────────────── */

.czt-preview { display: flex; flex-direction: column; gap: var(--s-3); min-width: 0; }
.czt-ladder-wrap { display: flex; flex-direction: column; gap: 6px; }
.czt-chart {
  position: relative; width: 100%; flex: none;
  border: 1px solid var(--cz-viz-rule); border-radius: var(--r-sm);
  background: var(--cz-viz-plate); overflow: hidden;
}
.czt-chart__canvas { display: block; }
.czt-chart-plate .cz-plate__body { gap: 10px; }

/* ── journey timeline additions ────────────────────────────────────────── */

.czt-timeline-host { min-width: 0; }
.czt-timeline .cz-timeline__track { height: 104px; margin-bottom: 4px; min-width: 460px; }
.czt-timeline .cz-timeline__scale { min-width: 460px; }
/* A sliver of a leg still has to be clickable and carry its mode colour. */
.czt-timeline .cz-timeline__leg { min-width: 14px; padding: 0 4px; }
/* Edge stations anchor inwards so the first and last labels are never clipped. */
.czt-timeline .cz-timeline__station[data-edge="start"] { transform: none; align-items: flex-start; }
.czt-timeline .cz-timeline__station[data-edge="end"]   { transform: translateX(-100%); align-items: flex-end; }
.czt-timeline .cz-timeline__station-label {
  max-width: 128px; overflow: hidden; text-overflow: ellipsis;
  background: var(--plate); padding: 0 3px; border-radius: 2px;   /* stays legible over a neighbouring dot */
}
/* Stations sit above the axis so their labels never run into the leg bars. */
.czt-timeline { padding-top: var(--s-6); }
.czt-timeline .cz-timeline__station { top: -20px; flex-direction: column-reverse; }
.czt-tl-cursor {
  position: absolute; top: 12px; bottom: 0; width: 2px;
  background: var(--brand); pointer-events: none; z-index: 3;
}
.czt-tl-cursor::before {
  content: ""; position: absolute; top: -5px; left: -4px;
  width: 10px; height: 10px; border-radius: 50%; background: var(--brand);
}
.czt-tl-damage {
  position: absolute; top: 92px; transform: translateX(-50%);
  width: 8px; height: 8px; border-radius: 50%;
  border: 1px solid var(--plate); background: var(--warn); z-index: 2;
}
.czt-tl-damage[data-severity="major"]   { background: var(--fail); }
.czt-tl-damage[data-severity="failure"] { background: var(--fail); box-shadow: 0 0 0 3px var(--fail-tint); }
.czt-tl-detail-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; font-size: 13.5px; }
.czt-tl-cell { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.czt-tl-damage-note { margin-top: 10px; }
.czt-tag {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 2px 7px; border-radius: var(--r-pill);
  border: 1px solid var(--rule-strong); color: var(--ink-mute); background: var(--plate);
}
.czt-tag[data-kind="event"] { border-color: var(--warn); color: var(--warn); }
.czt-tag[data-kind="dwell"] { border-style: dashed; }
.czt-tag[data-risk="pass"] { border-color: var(--pass); color: var(--pass); }
.czt-tag[data-risk="warn"] { border-color: var(--warn); color: var(--warn); }
.czt-tag[data-risk="fail"] { border-color: var(--fail); color: var(--fail); }

/* ── simulation-mode selector (Transit trial · ISTA 1A) ───────────────── */

.czt-mode .cz-plate__body { gap: 10px; }
.czt-mode .cz-seg { flex-wrap: wrap; }
.czt-mode .cz-seg__btn { white-space: normal; text-align: left; }
.czt-mode__desc { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--ink-2); max-width: 72ch; }
.czt-mode__prov { display: inline-flex; }
.czt-mode__prov:empty { display: none; }

/* ── simulation stage ──────────────────────────────────────────────────── */

.czt-run { display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap; }
.czt-sum-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--s-4); }
.czt-sum .cz-plate__body { gap: 6px; }
.czt-sum__row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: baseline; gap: 6px 10px;
  padding: 5px 0; border-bottom: 1px solid var(--rule);
  font-size: 12.5px;
}
.czt-sum__row:last-child { border-bottom: 0; }
.czt-sum__k { color: var(--ink-mute); white-space: nowrap; }
.czt-sum__v {
  font-family: var(--font-mono); font-size: 12.5px; font-variant-numeric: tabular-nums;
  text-align: right; min-width: 0; overflow-wrap: anywhere;
}

/* The run overlay reuses the host `.processing` chrome verbatim; it only needs
   to sit above the coil toasts and modals. */
.czt-processing { z-index: 950; }

/* ── dark visualisation theme ──────────────────────────────────────────── */

/* The shell's dark block re-colours .cz-plate / .cz-kpi / .cz-table inside
   .cz-viz; the headings, notes and the timeline chrome this stage adds need
   the same treatment, so they are covered here under our own .czt-viz hook. */
.cz-root[data-theme="dark"] .czt-viz .cz-section-head__title,
.cz-root[data-theme="dark"] .czt-viz .cz-plate__title,
.cz-root[data-theme="dark"] .czt-viz .czt-profile__label,
.cz-root[data-theme="dark"] .czt-viz .czt-tl-detail-head,
.cz-root[data-theme="dark"] .czt-viz .czt-tl-detail-head strong,
.cz-root[data-theme="dark"] .czt-viz .cz-timeline__detail-v,
.cz-root[data-theme="dark"] .czt-viz .czt-provlist__name { color: var(--cz-viz-ink); }
.cz-root[data-theme="dark"] .czt-viz .cz-section-head__sub,
.cz-root[data-theme="dark"] .czt-viz .cz-plate__sub,
.cz-root[data-theme="dark"] .czt-viz .cz-note,
.cz-root[data-theme="dark"] .czt-viz .cz-timeline__detail-k,
.cz-root[data-theme="dark"] .czt-viz .cz-timeline__station-label,
.cz-root[data-theme="dark"] .czt-viz .czt-provlist__note,
.cz-root[data-theme="dark"] .czt-viz .czt-profile__cite,
.cz-root[data-theme="dark"] .czt-viz .czt-profile__src { color: var(--cz-viz-mute); }
.cz-root[data-theme="dark"] .czt-viz .cz-timeline__detail {
  background: var(--cz-viz-bg); border-color: var(--cz-viz-rule);
}
.cz-root[data-theme="dark"] .czt-viz .cz-timeline__station-dot {
  background: var(--cz-viz-plate); border-color: var(--cz-viz-mute);
}
.cz-root[data-theme="dark"] .czt-viz .cz-timeline__station-label,
.cz-root[data-theme="dark"] .czt-viz .cz-timeline__event { border-color: var(--cz-viz-plate); }
.cz-root[data-theme="dark"] .czt-viz .cz-timeline__station-label { background: var(--cz-viz-plate); }
.cz-root[data-theme="dark"] .czt-viz .cz-timeline__axis { background: var(--cz-viz-rule); }
.cz-root[data-theme="dark"] .czt-viz .czt-provlist__item { border-bottom-color: var(--cz-viz-rule); }

.cz-root[data-theme="dark"] .cz-viz .czt-profile,
.cz-root[data-theme="dark"] .cz-viz .czt-events,
.cz-root[data-theme="dark"] .cz-viz .czt-chart { background: var(--cz-viz-plate); border-color: var(--cz-viz-rule); }
.cz-root[data-theme="dark"] .cz-viz .czt-prov-line,
.cz-root[data-theme="dark"] .cz-viz .czt-stat__k,
.cz-root[data-theme="dark"] .cz-viz .czt-sum__k { color: var(--cz-viz-mute); }
.cz-root[data-theme="dark"] .cz-viz .czt-code,
.cz-root[data-theme="dark"] .cz-viz .czt-prov-line__src { background: #1f2430; border-color: var(--cz-viz-rule); }

/* ── responsive ────────────────────────────────────────────────────────── */

@media (max-width: 1100px) {
  .czt-sum-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .czt-profile__stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .czt-leg__tools { width: 100%; }
  .czt-sum__row { grid-template-columns: minmax(0, 1fr) auto; }
  .czt-sum__row .cz-prov { grid-column: 2; }
}

/* ============================================================================
   End of fe-transit block.
   ============================================================================ */

/* ============================================================================
   BEGIN fe-config block (owner: fe-config, stages-config.js)
   Configuration stages: product · primary · secondary · outer · stacking.
   Namespace .czc-*; nothing above this line is modified.
   ============================================================================ */

/* ─────────────────────────────────────────── stage scaffold & preview tag ── */

.czc-stage { align-items: start; }
.czc-stage > .cz-stage-foot { grid-column: 1 / -1; margin-top: 0; }
.czc-form { gap: var(--s-4); }
.czc-viz { gap: var(--s-3); }
.czc-viz__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.czc-canvas { aspect-ratio: 4 / 3; min-height: 300px; }

/* viewer.js paints its legend and damage strip on their own absolutely
   positioned canvases.  The shell's `.cz-viz__canvas canvas { width:100%;
   height:100% }` rule matches those too and stretched the compression legend
   over the whole viewport (its `bottom:10px` then pushed the title off the top
   edge).  Re-assert the viewer's own geometry, scoped to the config viewports
   so no other stage is affected. */
.czc-canvas > canvas.czv-gl { width: 100%; height: 100%; }
.czc-canvas > canvas.czv-legend { width: 230px; height: 52px; }
.czc-canvas > canvas.czv-legend.czv-legend--fea { width: 142px; height: min(72%, 340px); }
.czc-canvas > canvas.czv-dmg { width: auto; height: auto; max-width: 70%; }
.czc-note { min-height: 16px; }

.czc-tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: hsl(var(--cz-h-engineering_assumption) 70% 26%);
  background: hsl(var(--cz-h-engineering_assumption) 85% 92%);
  border: 1px solid hsl(var(--cz-h-engineering_assumption) 60% 72%);
  white-space: nowrap;
}
.czc-tag::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.czc-preview {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: 12px 14px; border-radius: var(--r-sm);
  background: hsl(var(--cz-h-engineering_assumption) 85% 96%);
  border: 1px solid hsl(var(--cz-h-engineering_assumption) 60% 80%);
}
.czc-preview[hidden] { display: none; }
.czc-preview strong { display: block; font-size: 13.5px; color: var(--ink); }
.czc-preview p { margin: 4px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--ink-2); }

/* ─────────────────────────────────────────────────────── viewer toolbar ── */

.czc-toolbar { gap: var(--s-3) var(--s-4); }
.czc-toolbar__group { display: flex; align-items: center; gap: 8px; min-width: 0; }
.czc-toolbar__label { font-size: 11.5px; color: var(--cz-viz-mute); white-space: nowrap; }
.czc-range { width: 108px; accent-color: var(--brand); cursor: pointer; }

.czc-kpi-block { display: flex; flex-direction: column; gap: 8px; }
.czc-kpi-title {
  margin: 0; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--cz-viz-mute);
}
.czc-kpis { grid-template-columns: repeat(auto-fit, minmax(136px, 1fr)); }

/* ────────────────────────────────────────────── product stage read-outs ── */

.czc-drop { min-height: 120px; }
.czc-drop strong { font-size: 14px; color: var(--ink); }
.czc-intake__actions { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; margin-top: var(--s-3); }
.czc-intake__status { margin-top: 8px; min-height: 18px; }

.czc-ro { display: flex; flex-direction: column; gap: 0; }
.czc-ro__row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center; gap: var(--s-3);
  padding: 7px 0; border-bottom: 1px dashed var(--rule);
}
.czc-ro__row:last-child { border-bottom: 0; }
.czc-ro__k { font-size: 13px; color: var(--ink-2); min-width: 0; }
.czc-ro__v { font-size: 13px; color: var(--ink); white-space: nowrap; }

/* ────────────────────────────────────── partition-cell diagram card ── */

.czc-cell {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px; border: 1px solid var(--rule); border-radius: var(--r-sm);
  background: var(--plate); color: var(--ink);
  margin-bottom: var(--s-3);
}
.czc-cell .czc-dia { max-width: 420px; }
.czc-cell__meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 10.5px; color: var(--ink-mute); }

/* ─────────────────────────────────────── (legacy) config picker cards ── */

.czc-configs { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: var(--s-3); }
.czc-config {
  display: flex; flex-direction: column; gap: 8px; text-align: left;
  padding: 12px; border: 1px solid var(--rule); border-radius: var(--r-sm);
  background: var(--plate); color: var(--ink); cursor: pointer; font: inherit;
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
.czc-config:hover { border-color: var(--rule-strong); background: var(--plate-2); }
.czc-config.is-active { border-color: var(--brand); background: var(--brand-tint-2); box-shadow: inset 0 0 0 1px var(--brand); }
.czc-config:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.czc-config__head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.czc-config__letter {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 6px; flex: none;
  background: var(--ink); color: var(--paper);
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
}
.czc-config.is-active .czc-config__letter { background: var(--brand); }
.czc-config__title { font-size: 12.5px; font-weight: 600; line-height: 1.3; min-width: 0; }
.czc-config__badge {
  padding: 1px 6px; border-radius: 999px; flex: none;
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase;
  color: hsl(12 70% 32%); background: hsl(12 85% 94%); border: 1px solid hsl(12 65% 78%);
}
.czc-config__desc { display: block; font-size: 11.5px; line-height: 1.45; color: var(--ink-mute); }
.czc-config__meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 10.5px; color: var(--ink-mute); }
.czc-config__custom {
  display: flex; align-items: center; justify-content: center;
  height: 62px; border-radius: var(--r-sm); border: 1px dashed var(--rule-strong);
  background: var(--paper); font-size: 26px; color: var(--ink-mute);
}

/* Inline SVG diagrams: colours follow the module tokens, not the raw palette. */
.czc-dia { display: block; width: 100%; height: auto; }
.czc-dia__box { fill: var(--paper); stroke: var(--rule-strong); stroke-width: 1.2; }
.czc-dia__cap { fill: var(--ink-mute); font-family: var(--font-mono); font-size: 7px; letter-spacing: 0.06em; text-transform: uppercase; }
.czc-dia__carton { fill: hsl(var(--cz-h-literature) 45% 93%); stroke: hsl(var(--cz-h-literature) 40% 62%); stroke-width: 0.9; }
.czc-dia__coil { fill: hsl(148 40% 84%); stroke: hsl(148 45% 34%); stroke-width: 0.9; }
.czc-dia__spiral { fill: none; stroke: hsl(148 45% 34%); stroke-width: 1.1; stroke-linecap: round; }
.czc-dia__wall { stroke: var(--rule-strong); stroke-width: 1.6; stroke-linecap: square; }
.czc-dia__slab { fill: hsl(148 40% 84%); stroke: hsl(148 45% 34%); stroke-width: 0.6; }
.czc-dia__load, .czc-dia__flow { stroke: var(--fail); stroke-width: 1.4; fill: none; stroke-linecap: round; }
.czc-dia__flow { stroke-dasharray: 2.5 2.2; opacity: 0.85; }
.czc-dia__loadhead { fill: var(--fail); }

.czc-mode {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  margin-top: var(--s-3); padding: 10px 12px; border-radius: var(--r-sm);
  background: var(--plate-2); border-left: 3px solid var(--pass);
}
.czc-mode[data-worst="yes"] { border-left-color: var(--fail); }
.czc-mode__k { font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink); }
.czc-mode__v { font-size: 12.5px; line-height: 1.5; color: var(--ink-2); min-width: 0; }

/* ──────────────────────────────────────────── stacking legend & footer ── */

.czc-legendkeys { display: flex; flex-direction: column; gap: 8px; }
.czc-legendkey { display: flex; align-items: flex-start; gap: 10px; font-size: 12.5px; line-height: 1.5; color: var(--ink-2); }
.czc-swatch { flex: none; width: 16px; height: 16px; border-radius: 4px; margin-top: 1px; border: 1px solid var(--rule-strong); }
.czc-swatch--path { background: linear-gradient(180deg, transparent 38%, var(--fail) 38%, var(--fail) 62%, transparent 62%); }
.czc-swatch--cog { border-radius: 50%; background: #f2d21f; }
.czc-swatch--contact { background: repeating-linear-gradient(45deg, var(--rule-strong) 0 2px, transparent 2px 4px); }
.czc-swatch--util { background: linear-gradient(90deg, #1f4de0, #1fb35c, #f2d21f, #f28a1f, #d81f1f); }

.czc-foot__right { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; justify-content: flex-end; }

/* ──────────────────────────────────────────────── dark visualisation ── */

.cz-root[data-theme="dark"] .czc-viz .czc-kpi-title,
.cz-root[data-theme="dark"] .czc-viz .czc-toolbar__label { color: var(--cz-viz-mute); }
.cz-root[data-theme="dark"] .czc-viz .czc-tag {
  color: hsl(var(--cz-h-engineering_assumption) 80% 74%);
  background: hsl(var(--cz-h-engineering_assumption) 40% 16%);
  border-color: hsl(var(--cz-h-engineering_assumption) 40% 32%);
}

/* ─────────────────────────────────────────────────────────── responsive ── */

@media (max-width: 1100px) {
  .czc-viz { position: static; }
  .czc-canvas { min-height: 260px; }
}
@media (max-width: 760px) {
  .czc-configs { grid-template-columns: minmax(0, 1fr); }
  .czc-ro__row { grid-template-columns: minmax(0, 1fr) auto; }
  .czc-ro__row .cz-prov { grid-column: 2; }
  .czc-foot__right { width: 100%; justify-content: space-between; }
}

/* ============================================================================
   END fe-config block
   ============================================================================ */

/* ============================================================================
   BEGIN fe-results block (owner: fe-results — frontend/coil/stages-results.js)

   Results / Validation / Final-report stages (SPEC §5.4, §7.3, §7.5, §7.6).
   Everything here is namespaced `.czr-*` (plus two `.cz-demo-flag` / `.cz-kv`
   primitives the module needs) so nothing collides with the shell block above.
   ============================================================================ */

.czr { display: flex; flex-direction: column; gap: var(--s-5); min-width: 0; }

/* Small primitives shared by the three stages */
.cz-demo-flag {
  display: inline-flex; align-items: center;
  font: 600 10px/1 var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase;
  padding: 4px 7px; border-radius: var(--r-pill);
  color: var(--warn); background: var(--warn-tint); border: 1px solid var(--warn);
}
.cz-kv { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 12.5px; }
.cz-kv__k { color: var(--ink-mute); }
.cz-kv__v { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--ink); }

.czr-status {
  display: inline-flex; align-items: center; gap: 5px;
  font: 600 10.5px/1 var(--font-mono); letter-spacing: 0.08em;
  padding: 4px 7px; border-radius: var(--r-pill);
  color: var(--pass); background: var(--pass-tint); border: 1px solid currentColor;
  white-space: nowrap;
}
.czr-status[data-status="warn"] { color: var(--warn); background: var(--warn-tint); }
.czr-status[data-status="fail"] { color: var(--fail); background: var(--fail-tint); }

/* ── 3D inspector ────────────────────────────────────────────────────────── */

.czr-inspector { display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, 300px); gap: var(--s-4); align-items: start; }
.czr-inspector__view { display: flex; flex-direction: column; gap: var(--s-3); min-width: 0; }
.czr-inspector__side { display: flex; flex-direction: column; gap: var(--s-3); min-width: 0; }
.czr-viewer {
  height: clamp(320px, 52vh, 560px);
  background: var(--cz-viz-bg); border: 1px solid var(--cz-viz-rule); border-radius: var(--r-sm);
}
.czr-viewer-note { min-height: 1em; font-family: var(--font-mono); font-size: 11.5px; }
.czr-loadbar { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.czr-loadview { margin: 0; padding: 6px 10px; border-left: 3px solid var(--accent, #2f6fed); background: color-mix(in srgb, var(--accent, #2f6fed) 8%, transparent); border-radius: var(--r-sm); }
.czr-loadview[data-custom="true"] { border-left-color: var(--ink-mute); background: transparent; }
.czr-det__stamp { margin: 0; }
.czr-var-desc { margin: 0; }
.czr-legend__ticks { gap: 4px; }
.czr-legend__foot { display: flex; justify-content: space-between; gap: 8px; font-size: 10.5px; color: var(--ink-mute); }
.czr-legend__ck { white-space: nowrap; }
.czr-legend__name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.czr-markers { display: flex; flex-direction: column; gap: 6px; font-size: 12px; }

.czr-ctls { display: flex; flex-direction: column; gap: var(--s-2); padding-top: var(--s-2); border-top: 1px solid var(--rule); }
.czr-ctl { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); min-width: 0; }
.czr-ctl__label { font-size: 12.5px; color: var(--ink-2); display: flex; align-items: baseline; gap: 4px; min-width: 0; }
.czr-ctl__label small { color: var(--ink-mute); font-size: 11px; }
.czr-ctl .cz-select, .czr-ctl .cz-input { max-width: 160px; }
.czr-ctl .cz-seg { flex-shrink: 0; }
.czr-range { width: 150px; padding: 0; background: transparent; border: 0; accent-color: var(--brand); }

/* ── per-level KPI strip ─────────────────────────────────────────────────── */

.czr-kpi-levels { display: flex; flex-direction: column; gap: var(--s-4); }
.czr-kpi-level { display: flex; flex-direction: column; gap: var(--s-2); }
.czr-kpi-level__head { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.czr-kpi-level__title { margin: 0; font-size: 14px; letter-spacing: -0.01em; }
.czr-kpi-level__where { font-size: 11.5px; color: var(--ink-mute); }

/* ── journey scrubber ────────────────────────────────────────────────────── */

.czr-timeline-host { min-width: 0; }
.czr-scrubber { display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap; padding: var(--s-3) 0; }
.czr-scrubber__controls { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.czr-scrubber__track { flex: 1 1 320px; display: flex; flex-direction: column; gap: 4px; min-width: 240px; }
.czr-scrub { width: 100%; padding: 0; background: transparent; border: 0; accent-color: var(--brand); }
.czr-scrub__stamp { font-size: 11px; color: var(--ink-mute); }
.czr-tl-cursor { position: absolute; top: 14px; bottom: 6px; width: 2px; background: var(--brand); transform: translateX(-1px); pointer-events: none; z-index: 3; }
.czr-tl-cursor__flag {
  position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  font: 500 10px/1 var(--font-mono); white-space: nowrap;
  padding: 2px 5px; border-radius: 3px; background: var(--brand); color: #fff;
}

/* ── charts ──────────────────────────────────────────────────────────────── */

.czr-chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: var(--s-4); }
.czr-chart { margin: 0; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.czr-chart__cap { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.czr-chart__title { font-size: 13px; font-weight: 600; }
.czr-chart__sub { font-size: 11px; color: var(--ink-mute); }
.czr-chart__canvas {
  display: block; width: 100%; height: 240px;
  border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--plate);
}
.czr-chart__canvas:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.czr-seg-picker { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; margin-bottom: var(--s-2); }

/* ── expandable panels ───────────────────────────────────────────────────── */

.czr-panel { border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--paper); }
.czr-panel + .czr-panel { margin-top: var(--s-3); }
.czr-panel__summary {
  display: flex; align-items: baseline; gap: var(--s-3); flex-wrap: wrap;
  padding: 11px 14px; cursor: pointer; list-style: none; user-select: none;
}
.czr-panel__summary::-webkit-details-marker { display: none; }
.czr-panel__summary::before {
  content: "▸"; color: var(--ink-mute); font-size: 11px; transition: transform var(--t-fast);
}
.czr-panel[open] > .czr-panel__summary::before { transform: rotate(90deg); }
.czr-panel__title { font-size: 13.5px; font-weight: 600; }
.czr-panel__sub { font-size: 11.5px; color: var(--ink-mute); }
.czr-panel__body { padding: 0 14px 14px; }

/* ── deterioration panel ─────────────────────────────────────────────────── */

.czr-det__head { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.czr-det__readout {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 6px var(--s-4);
  padding: 10px 12px; border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--plate-2);
}
.czr-det__readout:empty { display: none; }

/* ── damage log ──────────────────────────────────────────────────────────── */

.czr-damage { display: flex; flex-direction: column; gap: var(--s-3); }
.czr-damage__summary { display: flex; gap: var(--s-5); flex-wrap: wrap; }
.czr-damage__summary:empty { display: none; }
.czr-damage__kind { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.czr-nodamage {
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px 16px; border-radius: var(--r-sm);
  border: 1px solid var(--pass); border-left-width: 3px; background: var(--pass-tint);
  font-size: 13px; color: var(--ink);
}
.czr-nodamage strong { font-size: 14px; }

/* ── validation ──────────────────────────────────────────────────────────── */

.czr-notes { display: flex; flex-direction: column; gap: 8px; }
.czr-note-row { display: grid; grid-template-columns: minmax(160px, 260px) minmax(0, 1fr); gap: var(--s-3); font-size: 12.5px; }
.czr-note-row__k { font-weight: 600; color: var(--ink-2); }
.czr-note-row__v { color: var(--ink-mute); line-height: 1.5; }
.czr-factors { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--s-3); }
.czr-factor { margin: 0; padding: 12px 14px; border: 1px solid var(--rule); border-left: 3px solid var(--brand-2); border-radius: var(--r-sm); background: var(--plate); }
.czr-factor__head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.czr-factor__name { font-size: 13px; font-weight: 600; }
.czr-factor__value { font-size: 14px; color: var(--brand); }
.czr-factor__why { margin: 0; font-size: 12.5px; color: var(--ink-mute); line-height: 1.55; }
.czr-summary { margin: 0 0 var(--s-3); font-size: 13.5px; line-height: 1.6; color: var(--ink-2); max-width: 78ch; }
.czr-limits { margin: 0; padding-left: 1.1em; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--ink-mute); line-height: 1.55; max-width: 84ch; }

/* ── report (in-flow, SPEC §7.6 — never a document frame) ────────────────── */

.czr-report__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; }
.czr-report__title { margin: 4px 0 6px; font-size: 22px; letter-spacing: -0.02em; }
.czr-report__actions { display: flex; gap: 8px; flex-shrink: 0; }
.czr-prose { display: flex; flex-direction: column; gap: 10px; max-width: 80ch; }
.czr-prose p { margin: 0; font-size: 13.5px; line-height: 1.65; color: var(--ink-2); }
.czr-provbox { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--plate-2); }
.czr-provbox__row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12.5px; }
.czr-provbox__k { color: var(--ink-2); }
.czr-provbox__note { color: var(--ink-mute); }
.czr-report__figs { display: flex; flex-direction: column; gap: var(--s-3); }
.czr-report__figs-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
.czr-report__pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--s-4); }
.czr-report__fig { margin: 0; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.czr-report__viewer {
  height: clamp(260px, 36vh, 400px);
  background: var(--cz-viz-bg); border: 1px solid var(--cz-viz-rule); border-radius: var(--r-sm);
}

/* ── dark visualisation theme ────────────────────────────────────────────── */

.cz-root[data-theme="dark"] .czr-chart__canvas,
.cz-root[data-theme="dark"] .czr-panel { background: var(--cz-viz-plate); border-color: var(--cz-viz-rule); }

/* ── responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 1100px) {
  .czr-inspector { grid-template-columns: minmax(0, 1fr); }
  .czr-viewer { height: clamp(280px, 44vh, 420px); }
  .czr-chart-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .czr-note-row { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .czr-scrubber__controls { width: 100%; }
  .czr-report__pair { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .czr-panel__summary::before { transition: none; }
}

/* ============================================================================
   END fe-results block
   ============================================================================ */

/* ============================================================================
   BEGIN fe-results append-2 · SPEC §8.2 (never render an empty chart frame)
   Owner: fe-results.  Appended block, additive only.
   ============================================================================ */

/* A chart with no data hides itself (charts.js sets `data-chart-empty` and
   takes the canvas out of the flow). These rules take the *card* with it, so
   no caption, border or placeholder box is left behind. */
.czr-chart__canvas[data-chart-empty="true"] { display: none !important; }
.czr-chart.is-empty,
.czr-chart:has(> canvas[data-chart-empty="true"]) { display: none !important; }

/* A chart group whose charts have all gone is dropped whole (§8.2). */
.czr-panel--charts.is-empty { display: none !important; }

/* The chart-group column: the panels keep their own spacing rules, so this
   only has to space the segment picker and the one explanatory line. */
.czr-chart-groups > .czr-seg-picker { margin-bottom: var(--s-3); }
.czr-charts-none[hidden],
.czr-det__none[hidden] { display: none !important; }
.czr-charts-none { margin: 0; }

/* ============================================================================
   END fe-results append-2
   ============================================================================ */

/* ── Embedded panels (SPEC §9): coil stages rendered beneath the host's own
   Transit / Results / Report content. The host owns the page chrome. ───────── */
.cz-root.cz-embed { margin-top: var(--s-7); padding-top: var(--s-5); border-top: 1px solid var(--rule); }
.cz-embed .cz-embed__stage + .cz-embed__stage { margin-top: var(--s-6); }
.cz-embed .cz-mode-plate { margin-bottom: var(--s-5); }
.cz-embed .cz-mode-plate .seg-control { margin-top: var(--s-3); }

/* ============================================================================
   BEGIN fe-results append-3 · focused panels (SPEC §9 embedded stages)
   Owner: fe-results.  Appended block, additive only.

   Results: four tab groups (Overview · 3D inspector · Deterioration & charts ·
   Positions & details), one shown at a time.  Report page: Validation /
   Transit trial report switcher.  Transit: collapsible blocks so the mode
   selector and the legs come first.  Nothing is removed, only organised.
   ============================================================================ */

/* ── tab bar (results tabs and the report switcher share it) ─────────────── */
.czr-tabbar {
  position: sticky; top: 0; z-index: 6;
  margin: 0 0 var(--s-2);
  padding: var(--s-2) 0 var(--s-2);
  background: var(--paper);
  box-shadow: 0 1px 0 var(--rule);
}
.czr-tabbar .cz-tabs { border-bottom: 0; gap: 4px; }
.czr-tabbar .cz-tab { font-size: 13px; padding: 8px 12px; }
.czr-tabbar__help {
  margin: 6px 0 0;
  font-size: 12.5px; line-height: 1.5;
  color: var(--ink-mute);
}
.cz-embed__tabbar { margin-bottom: var(--s-4); }
.cz-embed .cz-mode-plate + .cz-embed__tabbar { margin-top: 0; }

/* ── tab panes ───────────────────────────────────────────────────────────── */
.czr-pane { display: flex; flex-direction: column; gap: var(--s-5); min-width: 0; }
.czr-pane[hidden],
.cz-embed .cz-embed__stage[hidden] { display: none !important; }
/* The panes carry the section spacing now; keep the stage foot at its distance. */
.czr > .czr-pane + .cz-stage-foot { margin-top: var(--s-2); }

/* Shortcuts on the Overview damage plate. */
.czr-jump { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--s-3); }
.czr-damage__summary:empty { display: none; }

/* ── transit: collapsible blocks ─────────────────────────────────────────── */
.czt-fold { border: 1px solid var(--rule); border-radius: var(--r-md); background: var(--plate); min-width: 0; }
.czt-fold__summary {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding: 12px 14px; cursor: pointer; list-style: none; user-select: none;
}
.czt-fold__summary::-webkit-details-marker { display: none; }
.czt-fold__summary::before {
  content: "▸"; color: var(--ink-mute); font-size: 11px; line-height: 1;
  transition: transform 120ms ease; display: inline-block;
}
.czt-fold[open] > .czt-fold__summary::before { transform: rotate(90deg); }
.czt-fold__summary:hover .czt-fold__title { color: var(--brand); }
.czt-fold__title { font-size: 13.5px; font-weight: 600; }
.czt-fold__hint { font-size: 11.5px; color: var(--ink-mute); overflow-wrap: anywhere; }
.czt-fold__body { display: flex; flex-direction: column; gap: var(--s-4); padding: 0 14px 14px; min-width: 0; }
/* A plate folded inside the block keeps its content but not its own frame. */
.czt-fold__body > .cz-plate { border: 0; padding: 0; background: transparent; }
/* Inside a leg card the block is a lighter divider, not a second frame. */
.czt-fold--leg { background: transparent; border-color: var(--rule); }
.czt-fold--leg > .czt-fold__summary { padding: 10px 12px; }
.czt-fold--leg > .czt-fold__body { padding: 0 12px 12px; }
.cz-root[data-theme="dark"] .cz-viz .czt-fold { background: var(--cz-viz-plate); border-color: var(--cz-viz-rule); }

@media (prefers-reduced-motion: reduce) {
  .czt-fold__summary::before { transition: none; }
}
@media (max-width: 720px) {
  .czr-tabbar { position: static; }
}

/* ============================================================================
   END fe-results append-3
   ============================================================================ */

/* ── Coil optimiser (Optimise page, host flow) ─────────────────────── */
.opt-coil { display: grid; gap: 14px; margin: 6px 0 4px; }
.opt-coil__intro { margin: 0; color: var(--ink-mute, #5b6472); max-width: 72ch; }
.opt-coil__controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.opt-coil__status { min-height: 1.4em; font-size: 13px; color: var(--ink-mute, #5b6472); }
.opt-coil__status[data-tone="pass"] { color: #15803d; }
.opt-coil__status[data-tone="fail"] { color: #b91c1c; }
.opt-coil__status[data-tone="busy"] { color: #1d4ed8; }
.cz-opt-head { margin: 4px 0 8px; }
.cz-opt-note { margin: 4px 0 0; font-size: 14px; }
.cz-opt-tablewrap { overflow-x: auto; }
.cz-opt-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cz-opt-table th, .cz-opt-table td { padding: 8px 10px; border-bottom: 1px solid rgba(0,0,0,0.08); vertical-align: top; text-align: left; }
.cz-opt-table td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cz-opt-table th { font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-mute, #5b6472); }
.cz-opt-row--pass td { background: rgba(34, 197, 94, 0.06); }
.cz-opt-row--rec td { background: rgba(37, 99, 235, 0.08); }
.cz-opt-rec { font-size: 11px; color: #1d4ed8; border: 1px solid #1d4ed8; border-radius: 999px; padding: 1px 8px; margin-left: 6px; }
.cz-opt-detail { margin-top: 4px; }
.cz-opt-levers { margin: 0; padding-left: 16px; color: var(--ink-mute, #5b6472); font-size: 12px; }
.cz-opt-muted { color: var(--ink-mute, #5b6472); font-size: 12px; }
.cz-opt-verdict { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; }
.cz-opt-verdict--pass { background: #dcfce7; color: #15803d; }
.cz-opt-verdict--marginal { background: #fef3c7; color: #b45309; }
.cz-opt-verdict--fail { background: #fee2e2; color: #b91c1c; }
.cz-opt-foot { margin: 10px 0 0; font-size: 12px; color: var(--ink-mute, #5b6472); }
:root[data-theme="dark"] .cz-opt-table th, :root[data-theme="dark"] .cz-opt-table td { border-bottom-color: rgba(255,255,255,0.1); }
