/* ===== Stepper family + wizard modal =====

   Two progression indicators sharing one vocabulary (numbered circle, is-done / is-active states):
     .stepper      inline, read-only — where you are in a modal flow you're being walked through
     .stepper-nav  full-width, clickable — where a record is in a lifecycle you can navigate
   Keep their states named the same; they're meant to read as one system.
   ─────────────────────────────────────────────────────────────────────────────

   ===== Wizard — multi-step modal flow archetype =====

   Derives from shared.css's .modal: .modal.modal-wizard swaps the fixed-height body for a
   flex column (head / stepper / scrolling body / foot) so a long step can scroll without the
   stepper or action buttons leaving the viewport. Use this for any flow that collects input
   across several ordered screens; a single-screen form stays a plain .modal.

   Which piece to reach for:
     .modal-wizard          the shell — pair with .wizard-head / .stepper / .wizard-body / .wizard-foot
     .stepper               the numbered progress strip; one .stepper-step per screen
     .step-title/.step-hint every step's heading + one-line explanation
     .entry-list/.entry-card a repeatable, removable list of sub-records (kits, builds, modules)
     .btn-dashed            the "+ Add another" affordance that grows an .entry-list
     .check-row/.check-group a checkbox checklist, optionally nested one level
     .pick-chip             an inline multi-select pill (which kits attach to a build)

   Everything else comes from existing archetypes — .card/.card--selected for a pickable
   option tile, .chip for status/number tags, .tone-banner for validation errors,
   .data-table for tabular steps, .diff-list for a review summary. Don't re-invent those here. */


/* ─── Shell ──────────────────────────────────────────────────────────────────── */

.modal-wizard {
  width: 840px;
  display: flex;
  flex-direction: column;
  max-height: min(88vh, 820px);
}

.wizard-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.4rem 0.85rem;
  border-bottom: 1px solid var(--border);
}

.wizard-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

/* Which record this flow is attached to — the wizard never stands alone, it always acts on something */
.wizard-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}
.wizard-sub strong { color: var(--info-color); font-weight: 600; }

.wizard-body {
  padding: 1.3rem 1.4rem;
  overflow-y: auto;
  flex: 1;
}

.wizard-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.4rem;
  border-top: 1px solid var(--border);
}

/* Left-hand footer slot — step counter normally, validation message when a step is blocking */
.wizard-foot-note { font-size: 0.75rem; color: var(--text-faint); }
.wizard-foot-note.is-blocking { color: var(--danger); font-weight: 600; }

.wizard-foot-actions { display: flex; gap: 0.6rem; }


/* ─── Stepper ────────────────────────────────────────────────────────────────── */

.stepper {
  display: flex;
  padding: 0.8rem 1.4rem;
  border-bottom: 1px solid var(--border);
  background: var(--table-surface);
  overflow-x: auto;
}

.stepper-step {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: none;
  padding-right: 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-faint);
}

/* Connector between steps — on the step itself, not a separate element, so the strip stays one flat row of children */
.stepper-step:not(:last-child)::after {
  content: '';
  width: 1.3rem;
  height: 1px;
  background: var(--border);
  margin-left: 0.3rem;
}

.stepper-num {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 1.3rem;
  height: 1.3rem;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
}

.stepper-label { white-space: nowrap; }

.stepper-step.is-done { color: var(--text-sub); }
.stepper-step.is-done .stepper-num {
  background: var(--success);
  border-color: var(--success);
  color: var(--on-primary);
}

.stepper-step.is-active { color: var(--text); }
.stepper-step.is-active .stepper-num {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}


/* ─── Stepper-nav — the navigable sibling of .stepper: one clickable column per lifecycle
     stage, carrying a status line so you can see what's outstanding without visiting each one ── */

.stepper-nav {
  display: flex;
  border-top: 1px solid var(--border-light);
  border-bottom: var(--panel-border-width) solid var(--border);
  background: var(--surface);
  overflow-x: auto;
}

.stepper-nav-stage {
  flex: 1;
  min-width: 9.5rem;
  border: none;
  background: none;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  padding: 0.7rem 1rem;
  border-bottom: var(--panel-border-width) solid transparent;
  margin-bottom: calc(-1 * var(--panel-border-width));
  transition: background 0.12s;
}
.stepper-nav-stage:hover { background: var(--row-hover); }
.stepper-nav-stage + .stepper-nav-stage { border-left: 1px solid var(--border-light); }

.stepper-nav-top { display: flex; align-items: center; gap: 0.45rem; }

.stepper-nav-num {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.stepper-nav-name { font-size: 0.8rem; font-weight: 650; color: var(--text-faint); }

/* Indented to clear the numbered circle above it, so hints line up with their stage names */
.stepper-nav-hint { font-size: 0.68rem; color: var(--text-faint); margin-top: 0.28rem; padding-left: 1.7rem; }

.stepper-nav-stage.is-done .stepper-nav-num { background: var(--success); border-color: var(--success); color: var(--on-primary); }
.stepper-nav-stage.is-done .stepper-nav-name { color: var(--text-sub); }

.stepper-nav-stage.is-active { border-bottom-color: var(--primary); background: var(--table-surface); }
.stepper-nav-stage.is-active .stepper-nav-num { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.stepper-nav-stage.is-active .stepper-nav-name { color: var(--text); }

/* Not reachable yet — the record hasn't got there and the viewer can't browse ahead */
.stepper-nav-stage:disabled { opacity: 0.5; cursor: default; }
.stepper-nav-stage:disabled:hover { background: none; }


/* ─── Step heading ───────────────────────────────────────────────────────────── */

.step-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.step-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
  max-width: 62ch;
  margin-bottom: 1rem;
}


/* ─── Entry list — a repeatable, removable sub-record ────────────────────────── */

.entry-list { display: flex; flex-direction: column; gap: 0.6rem; }

.entry-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--table-surface);
  padding: 0.8rem 0.9rem;
}
/* Flagged by the step's own validation — pairs with a .tone-banner naming what's wrong */
.entry-card.has-error { border-color: var(--danger); }

.entry-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

.entry-card-tag {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* .entry-card's own .form-grid is tighter than a modal body's — these are stacked, not the whole screen */
.entry-card .form-grid { gap: 0 0.9rem; }
.entry-card .form-field { margin-bottom: 0.55rem; }

/* Grow-the-list button — dashed to read as "add", distinct from the primal solid button roles */
.btn-dashed {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.55rem;
  padding: 0.45rem 0.85rem;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-md);
  background: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-dashed:hover { border-color: var(--primary); color: var(--primary); }
.btn-dashed:disabled { opacity: 0.5; cursor: default; }

/* Inline ext.int revision entry — the Manual option beside a step's preset .card--selected tiles */
.rev-row { display: flex; align-items: center; gap: 0.4rem; }
.rev-row input {
  width: 3.4rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
}
.rev-row input:focus { outline: none; border-color: var(--primary); }
.rev-row span { color: var(--text-faint); }


/* ─── Pick chips — inline multi-select (which kits attach to this build) ─────── */

.pick-chip-row { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.pick-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.26rem 0.7rem 0.26rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-sub);
  font-size: 0.75rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.pick-chip:hover { border-color: var(--text-faint); }
.pick-chip.is-checked { border-color: var(--primary); background: var(--info-bg); color: var(--text); }
/* Trailing revision/meta inside a chip — quieter than the chip's own label */
.pick-chip .pick-chip-meta { color: var(--text-faint); font-variant-numeric: tabular-nums; }


/* ─── Check rows — a checklist, optionally nested one level ──────────────────── */

.check-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--table-surface);
  margin-bottom: 0.5rem;
  cursor: pointer;
}
.check-row:hover { border-color: var(--text-faint); }
.check-row-label { font-size: 0.82rem; font-weight: 600; color: var(--text-sub); }

/* A parent check row plus its own nested children (a build and its modules) */
.check-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 0.5rem;
}
.check-group .check-row {
  border: none;
  border-radius: 0;
  margin-bottom: 0;
  background: var(--table-surface);
}
.check-group .check-row + .check-row { border-top: 1px solid var(--border-light); }
.check-group .check-row--nested {
  padding-left: 2rem;
  background: var(--surface);
}
.check-group .check-row--nested .check-row-label { font-weight: 400; }

/* The scope a group belongs to (a build), heading its rows — no checkbox and nothing to click, so it
   never looks like the thing being toggled, and its children own the documents instead */
.check-group .check-row--scope {
  cursor: default;
  background: var(--surface-deep);
}


/* ─── Grouped review/assignment block — one per record the flow will create ──── */

.wizard-group { margin-bottom: 1.2rem; }

.wizard-group-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.wizard-group-name { font-size: 0.85rem; font-weight: 600; color: var(--text-sub); }

/* Documents table scope rows — the Kit/Build/Module a document belongs to, one full-width row above
   its documents. --depth is set per row by _scopeRows(), so indent comes from the tree walk rather
   than a class per level and the ladder can grow without new CSS. */
.wizard-scope-row td.wizard-scope {
  padding-left: calc(0.55rem + var(--depth, 0) * 1.35rem);
  font-size: 0.68rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
  background: var(--surface-deep);
}
/* the revision bump rides along on the Kit row, so it reads as that scope's detail and not a document */
.wizard-scope-meta { text-transform: none; letter-spacing: 0; margin-left: 0.4rem; }
/* one level deeper than the scope that owns it */
.data-table td.wizard-doc { padding-left: calc(0.55rem + var(--depth, 0) * 1.35rem); }


/* ─── Mobile ─────────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .modal-wizard { width: 100%; max-height: 92vh; }
  .wizard-head, .stepper, .wizard-body, .wizard-foot { padding-left: 1rem; padding-right: 1rem; }
  .entry-card .form-grid, .modal-wizard .form-grid { grid-template-columns: 1fr; }
  /* Numbers alone carry the progress on a narrow strip — labels would force a horizontal scroll */
  .stepper-label { display: none; }
  .stepper-step { padding-right: 0.5rem; }
}
