/* ============================================================================
   APQPSigma — application styling

   Design stance: QUALITY ENGINEER FIRST, AUDITOR SECOND.
   The engineer must be able to work naturally; the governance must be present
   without shouting. Decision markers are therefore quiet, inline and factual —
   never alarm-coloured, never blocking, never a wall of red tape.
   ========================================================================= */

:root {
  --ink:        #0f172a;
  --ink-2:      #334155;
  --ink-3:      #64748b;
  --ink-4:      #94a3b8;
  --line:       #e2e8f0;
  --line-2:     #cbd5e1;
  --bg:         #f6f7f9;
  --surface:    #ffffff;
  --surface-2:  #f8fafc;

  --accent:     #3b5bdb;
  --accent-ink: #2b45ab;
  --accent-bg:  #eef2ff;

  --apqp:       #0d9488;
  --dmaic:      #7c3aed;

  --ok:         #0f766e;
  --ok-bg:      #ecfdf5;
  --warn:       #92400e;
  --warn-bg:    #fffbeb;
  --err:        #b91c1c;
  --err-bg:     #fef2f2;

  --radius:     10px;
  --radius-sm:  6px;
  --shadow:     0 1px 2px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.06);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 0.98rem; }
h4 { font-size: 0.88rem; }
p { margin: 0 0 .6rem; }
p:last-child { margin-bottom: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--mono); font-size: .82em; }
.fine { color: var(--ink-3); font-size: .82rem; line-height: 1.5; }
.lead { color: var(--ink-2); max-width: 70ch; margin-bottom: 1rem; }
.nowrap { white-space: nowrap; }
.pad { padding: .8rem; }
ul.tight { margin: .4rem 0; padding-left: 1.1rem; }
ul.tight li { margin-bottom: .3rem; }

/* ---- layout ------------------------------------------------------------ */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px; flex: 0 0 232px;
  background: var(--ink);
  color: #e2e8f0;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: .6rem;
  padding: 1.1rem 1rem; border-bottom: 1px solid rgba(255,255,255,.08);
  color: #fff; text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; flex: 0 0 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--apqp), var(--dmaic));
  display: grid; place-items: center;
  font-weight: 700; font-size: .78rem; letter-spacing: .02em;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: .95rem; }
.brand-text em { font-style: normal; font-size: .7rem; color: var(--ink-4); }

#sidenav { flex: 1; overflow-y: auto; padding: .75rem 0; }
.nav-group { padding: .35rem .6rem; }
.nav-group + .nav-group { border-top: 1px solid rgba(255,255,255,.07); margin-top: .35rem; padding-top: .6rem; }
.nav-head {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .09em;
  color: var(--ink-4); padding: .2rem .5rem .4rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav-item {
  display: flex; align-items: center; gap: .55rem;
  padding: .44rem .55rem; border-radius: var(--radius-sm);
  color: #cbd5e1; font-size: .86rem; text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(255,255,255,.12); color: #fff; font-weight: 600; }
.nav-icon { width: 1.1rem; text-align: center; font-size: .95rem; }
.nav-muted .nav-item, .nav-disabled { color: #56617a; cursor: default; }
.nav-disabled:hover { background: none; color: #56617a; }
.sidebar-foot {
  padding: .9rem 1rem; border-top: 1px solid rgba(255,255,255,.08);
  font-size: .72rem; color: var(--ink-4); line-height: 1.5;
}
.sidebar-foot .fine { color: #56617a; font-size: .68rem; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 54px; flex: 0 0 54px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.25rem; position: sticky; top: 0; z-index: 20;
}
.crumb { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.crumb strong { font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb-sub { color: var(--ink-3); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb-meth {
  font-size: .66rem; font-weight: 700; letter-spacing: .06em;
  padding: .16rem .42rem; border-radius: 4px; color: #fff;
}
.crumb-apqp { background: var(--apqp); }
.crumb-dmaic { background: var(--dmaic); }
.topbar-actions { display: flex; gap: .4rem; }

.view { flex: 1; padding: 1.5rem 1.75rem 4rem; max-width: 1500px; width: 100%; }

/* ---- buttons ----------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; gap: .35rem;
  font: inherit; font-size: .85rem; font-weight: 550;
  padding: .46rem .85rem; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer;
  background: var(--surface-2); color: var(--ink);
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); }
.btn-secondary { background: var(--surface); border-color: var(--line-2); color: var(--ink); }
.btn-secondary:hover { border-color: var(--ink-4); }
.btn-ghost { background: transparent; border-color: var(--line-2); color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: .32rem .6rem; font-size: .8rem; }
.btn-mini { padding: .16rem .45rem; font-size: .74rem; border: 1px solid var(--line-2); background: var(--surface); border-radius: 4px; cursor: pointer; font-family: inherit; }
.btn-mini:hover { border-color: var(--ink-4); }
.icon-btn {
  border: none; background: none; cursor: pointer; color: var(--ink-4);
  font-size: 1rem; line-height: 1; padding: .15rem .3rem; border-radius: 4px;
}
.icon-btn:hover { background: var(--err-bg); color: var(--err); }
button.link {
  border: none; background: none; padding: 0; cursor: pointer;
  color: var(--accent); font: inherit; text-align: left;
}
button.link:hover { text-decoration: underline; }

/* ---- section chrome ---------------------------------------------------- */

.section-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; margin-bottom: 1rem;
}
.section-head .sub { color: var(--ink-3); font-size: .85rem; margin: .2rem 0 0; max-width: 70ch; }
.section-actions { display: flex; gap: .5rem; flex-shrink: 0; }

.ws-head { margin-bottom: 1rem; }
.ws-relation {
  color: var(--ink-3); font-size: .78rem; margin: .1rem 0 0;
  font-family: var(--mono); letter-spacing: .01em;
}

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem;
}
.panel h3 { margin-bottom: .45rem; }
.panel h4 { margin-bottom: .3rem; }
.panel-warn { background: var(--warn-bg); border-color: #fde68a; }
.panel-inline { margin-top: .75rem; margin-bottom: 0; background: var(--surface-2); }
.panel .count {
  font-size: .72rem; font-weight: 600; color: var(--ink-3);
  background: var(--surface-2); border: 1px solid var(--line);
  padding: .05rem .35rem; border-radius: 20px; margin-left: .25rem;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.row-end { display: flex; justify-content: flex-start; margin-top: .5rem; }

.empty {
  background: var(--surface); border: 1px dashed var(--line-2);
  border-radius: var(--radius); padding: 2.25rem 1.5rem; text-align: center;
}
.empty-title { font-weight: 620; margin-bottom: .3rem; }
.empty-body { color: var(--ink-3); font-size: .86rem; max-width: 52ch; margin: 0 auto .9rem; }

/* ---- badges + decision markers ----------------------------------------- */

.badge {
  display: inline-flex; align-items: center;
  font-size: .68rem; font-weight: 620; letter-spacing: .03em;
  padding: .1rem .42rem; border-radius: 4px;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink-2);
  white-space: nowrap; vertical-align: middle;
}
.badge-neutral { }
.badge-ok    { background: var(--ok-bg);   border-color: #a7f3d0; color: var(--ok); }
.badge-warn  { background: var(--warn-bg); border-color: #fde68a; color: var(--warn); }
.badge-error { background: var(--err-bg);  border-color: #fecaca; color: var(--err); }

/* Quiet, informational, never alarming. Governance must not read as red tape. */
button.badge { cursor: pointer; font-family: inherit; }
.badge-decision  { background: var(--accent-bg); border-color: #c7d2fe; color: var(--accent-ink); }
.badge-config    { background: var(--surface-2); border-color: var(--line-2); color: var(--ink-3); }
.badge-reference { background: #f5f3ff; border-color: #ddd6fe; color: #6d28d9; }
/* A recovered working rule. Present and in use — reads as information, not as a warning. */
.badge-working  { background: var(--ok-bg); border-color: #a7f3d0; color: var(--ok); }
button.badge:hover { filter: brightness(.97); }

.note {
  border-radius: var(--radius-sm); padding: .65rem .8rem;
  margin: .6rem 0; font-size: .82rem; line-height: 1.5;
}
.note-decision { background: var(--accent-bg); border: 1px solid #c7d2fe; }
.note-config   { background: var(--surface-2); border: 1px solid var(--line); }
.note-working  { background: var(--ok-bg); border: 1px solid #a7f3d0; }
.note-head {
  font-size: .64rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: .15rem;
}
.note-title { font-weight: 620; margin-bottom: .2rem; }
.note p { margin: 0; color: var(--ink-2); }

.decision-list { list-style: none; margin: .4rem 0 0; padding: 0; }
.decision-list li {
  padding: .32rem 0; border-top: 1px solid var(--line);
  display: flex; gap: .5rem; align-items: baseline; justify-content: space-between;
}
.decision-list li:first-child { border-top: none; }

/* ---- project list ------------------------------------------------------ */

.proj-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem;
}
.proj-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem; color: inherit; text-decoration: none;
  display: flex; flex-direction: column; gap: .35rem;
}
.proj-card:hover { border-color: var(--ink-4); box-shadow: var(--shadow); text-decoration: none; }
.proj-top { display: flex; align-items: center; justify-content: space-between; }
.proj-num { color: var(--ink-3); }
.proj-card h3 { font-size: 1rem; }
.proj-subject { color: var(--ink-2); font-size: .85rem; }
.proj-phase { color: var(--ink-3); font-size: .78rem; }
.proj-stats, .tally { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: .35rem; }
.tally { margin: .5rem 0; }
.stat { font-size: .76rem; color: var(--ink-3); }
.stat strong { color: var(--ink); font-size: .9rem; }

/* ---- phase strip ------------------------------------------------------- */

.phase-strip {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .75rem .9rem; margin-bottom: 1.25rem;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.phase-strip-label {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .09em;
  color: var(--ink-3); font-weight: 700; flex-shrink: 0;
}
.phases { display: flex; gap: .4rem; flex: 1; flex-wrap: wrap; }
.phase {
  flex: 1 1 120px; min-width: 110px;
  display: flex; flex-direction: column; gap: .1rem; align-items: flex-start;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: .45rem .6rem;
  cursor: pointer; font: inherit; text-align: left;
}
.phase:hover { border-color: var(--ink-4); }
.phase.active { border-color: var(--accent); background: var(--accent-bg); }
.phase.closed { background: var(--ok-bg); border-color: #a7f3d0; }
.phase.closed.active { border-color: var(--accent); }
.phase-label {
  font-weight: 700; font-size: .7rem; color: #fff; background: var(--ink-2);
  width: 1.15rem; height: 1.15rem; border-radius: 3px;
  display: grid; place-items: center;
}
.phase-label.sm { display: inline-grid; vertical-align: middle; }
.phase.active .phase-label { background: var(--accent); }
.phase-name { font-size: .78rem; font-weight: 550; line-height: 1.25; }
.phase-gate { font-size: .68rem; color: var(--ink-3); }
.phase-strip-actions { flex-shrink: 0; }

/* ---- tabs -------------------------------------------------------------- */

.ws-tabs {
  display: flex; gap: .15rem; border-bottom: 1px solid var(--line); margin-bottom: 1.15rem;
  overflow-x: auto;
}
.tab {
  font: inherit; font-size: .85rem; font-weight: 550;
  background: none; border: none; border-bottom: 2px solid transparent;
  padding: .5rem .8rem; cursor: pointer; color: var(--ink-3); white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---- the chain --------------------------------------------------------- */

.chain {
  display: flex; align-items: stretch; gap: .5rem; flex-wrap: wrap;
  margin-bottom: .5rem;
}
.chain-node {
  flex: 1 1 150px; min-width: 140px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .8rem; cursor: pointer; font: inherit; text-align: left;
  display: flex; flex-direction: column; gap: .1rem;
}
.chain-node:hover { border-color: var(--accent); }
.chain-node.has { border-color: var(--line-2); background: var(--surface); }
.chain-count { font-size: 1.5rem; font-weight: 700; line-height: 1; color: var(--ink-4); }
.chain-node.has .chain-count { color: var(--accent); }
.chain-label { font-weight: 620; font-size: .9rem; }
.chain-hint { font-size: .72rem; color: var(--ink-3); }
.chain-arrow { align-self: center; color: var(--ink-4); font-size: 1.1rem; }
.chain-tail { display: flex; gap: .75rem; align-items: flex-start; margin: 0 0 1.25rem; padding-left: .5rem; }
.chain-tail-arrow { color: var(--ink-4); font-size: 1.2rem; line-height: 1; }
.chain-tail-body { flex: 1; }

/* ---- records + grids --------------------------------------------------- */

.record {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1.25rem;
}
.record-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; margin-bottom: .8rem; flex-wrap: wrap;
}
.record-meta { display: flex; align-items: center; gap: .5rem; margin-top: .2rem; flex-wrap: wrap; }
.record-actions { display: flex; gap: .4rem; flex-shrink: 0; }
.record-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-top: .7rem; flex-wrap: wrap;
}
.rev {
  font-family: var(--mono); font-size: .72rem; font-weight: 600;
  background: var(--ink); color: #fff; padding: .1rem .35rem; border-radius: 3px;
}

.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table.grid { width: 100%; border-collapse: collapse; font-size: .84rem; background: var(--surface); }
table.grid th {
  text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-3); font-weight: 700; padding: .5rem .55rem;
  background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.grid td { padding: .3rem .55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid tr:last-child td { border-bottom: none; }
table.grid.plain td { padding: .45rem .55rem; }
table.grid input, table.grid select {
  width: 100%; font: inherit; font-size: .84rem;
  border: 1px solid transparent; background: transparent;
  padding: .25rem .3rem; border-radius: 4px; color: var(--ink);
}
table.grid input:hover, table.grid select:hover { border-color: var(--line-2); }
table.grid input:focus, table.grid select:focus {
  outline: none; border-color: var(--accent); background: var(--surface);
}
.col-sub { min-width: 150px; }
/* Rating columns must be wide enough to show the SELECTED VALUE, not just the
   dropdown arrow. At 52px the digit was clipped and every rating read as blank. */
.col-r { width: 70px; text-align: center; }
table.grid td.col-r { padding-left: .2rem; padding-right: .2rem; }
.rating { text-align: center; text-align-last: center; padding-left: .15rem; padding-right: 0; }
.col-n { width: 90px; }
.col-x { width: 36px; }
.col-act { width: 130px; }
.rpn { font-variant-numeric: tabular-nums; font-weight: 600; }

.ev-list { list-style: none; margin: 0; padding: 0; }
.ev-list li {
  position: relative; padding: .45rem .55rem .45rem 0; border-bottom: 1px solid var(--line);
}
.ev-list li:last-child { border-bottom: none; }
.ev-list .icon-btn { position: absolute; right: 0; top: .4rem; }
.ev-main { padding-right: 1.6rem; }
.ev-inline { display: flex; align-items: center; gap: .3rem; font-size: .82rem; }

/* ---- gates -------------------------------------------------------------- */

.gate-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.gate-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .9rem 1rem;
}
.gate-card.gate-closed { border-color: #a7f3d0; }
.gate-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; margin-bottom: .5rem;
}
.gate-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: .6rem; margin-top: .6rem; flex-wrap: wrap;
}

/* ---- metrics ------------------------------------------------------------ */

.metric-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .5rem; }
.metric {
  flex: 1 1 100px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: .5rem .65rem;
  display: flex; flex-direction: column;
}
.metric-label { font-size: .66rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 700; }
.metric-value { font-size: 1.05rem; font-weight: 640; font-variant-numeric: tabular-nums; }
.metric-row-key .metric { background: var(--accent-bg); border-color: #c7d2fe; }
.study-notes { margin-top: .5rem; }

/* ---- 8D ---------------------------------------------------------------- */

.disc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.disc { display: flex; flex-direction: column; gap: .2rem; }
.disc-head { font-size: .78rem; font-weight: 600; color: var(--ink-2); }
.disc-label {
  font-family: var(--mono); font-size: .68rem; font-weight: 700;
  background: var(--ink-2); color: #fff; padding: .05rem .3rem; border-radius: 3px;
}
.disc textarea, .panel-inline textarea {
  width: 100%; font: inherit; font-size: .84rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .4rem .5rem; resize: vertical; background: var(--surface);
}
.disc textarea:focus, .panel-inline textarea:focus { outline: none; border-color: var(--accent); }

/* ---- modal -------------------------------------------------------------- */

.modal-host { position: fixed; inset: 0; z-index: 100; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.45); }
.modal {
  position: relative; margin: 4vh auto; max-width: 640px; width: calc(100% - 2rem);
  max-height: 92vh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
}
.modal-sm { max-width: 420px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 1.1rem; border-bottom: 1px solid var(--line);
}
.modal-intro { padding: .8rem 1.1rem 0; }
.modal-body {
  padding: 1rem 1.1rem; overflow-y: auto;
  display: grid; grid-template-columns: 1fr 1fr; gap: .75rem;
}
.modal-prose { display: block; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: .5rem;
  padding: .8rem 1.1rem; border-top: 1px solid var(--line);
}
.field { display: flex; flex-direction: column; gap: .22rem; }
.field-wide { grid-column: 1 / -1; }
.field-label { font-size: .76rem; font-weight: 620; color: var(--ink-2); }
.field-label em { font-style: normal; font-weight: 500; color: var(--ink-4); font-size: .9em; }
.field-hint { font-size: .74rem; color: var(--ink-3); }
.field input, .field select, .field textarea {
  font: inherit; font-size: .86rem; padding: .42rem .55rem;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); width: 100%;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg);
}
.check-list {
  max-height: 240px; overflow-y: auto; border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: .35rem;
}
/* Checkboxes must not inherit the full-width rule for text inputs, or the box
   stretches across the row and shoves its own label to the far right. */
.field input[type="checkbox"], .check input[type="checkbox"] { width: auto; flex: 0 0 auto; }
.check { display: flex; gap: .5rem; align-items: flex-start; padding: .3rem .35rem; font-size: .84rem; }
.check:hover { background: var(--surface-2); }
.check input { margin-top: .22rem; }
.kicker {
  font-size: .66rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3);
}

/* ---- toast -------------------------------------------------------------- */

.toast-host {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: .4rem; align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--ink); color: #fff; font-size: .84rem;
  padding: .5rem .9rem; border-radius: 20px; box-shadow: var(--shadow);
  opacity: 1; transition: opacity .4s ease, transform .4s ease;
}
.toast-error { background: var(--err); }
.toast-out { opacity: 0; transform: translateY(6px); }

/* ---- responsive --------------------------------------------------------- */

@media (max-width: 1100px) {
  .grid-2, .disc-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  #sidenav { display: flex; overflow-x: auto; padding: .4rem; }
  .nav-group { display: flex; gap: .25rem; border: none !important; margin: 0; padding: .2rem; }
  .nav-head { display: none; }
  .sidebar-foot { display: none; }
  .view { padding: 1rem; }
  .modal-body { grid-template-columns: 1fr; }
  .phase-strip { flex-direction: column; align-items: stretch; }
}

/* ---- recovered working model: bands, verdicts, unreviewed rows ---------- */

/* RPN banding — the recovered 2025 model (High 100+, Medium 40+). */
.rpn-value { display: inline-block; min-width: 2.2rem; padding: .05rem .3rem; border-radius: 4px;
             font-variant-numeric: tabular-nums; font-weight: 650; }
.rpn-high   { background: var(--err-bg);  color: var(--err); }
.rpn-medium { background: var(--warn-bg); color: var(--warn); }
.rpn-low    { background: var(--ok-bg);   color: var(--ok); }

/* A nomination the working model suggests. Highlights; never acts on its own. */
.btn-suggest { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-bg); font-weight: 600; }

/* A Control Plan row still carrying unedited recovered starting values. */
tr.row-unedited { background: var(--warn-bg); }
tr.row-unedited input { color: var(--warn); }

/* Capability verdict, from the recovered bands. */
.verdict { border-radius: var(--radius-sm); padding: .55rem .8rem; margin: .5rem 0; font-size: .86rem; }
.verdict-excellent, .verdict-good { background: var(--ok-bg);   border: 1px solid #a7f3d0; }
.verdict-marginal                 { background: var(--warn-bg); border: 1px solid #fde68a; }
.verdict-inadequate               { background: var(--err-bg);  border: 1px solid #fecaca; }

.metric-excellent, .metric-good { background: var(--ok-bg);   border-color: #a7f3d0; }
.metric-marginal                { background: var(--warn-bg); border-color: #fde68a; }
.metric-inadequate              { background: var(--err-bg);  border-color: #fecaca; }

/* ============================================================================
   APQP PHASE PLAN — recovered swim-lane canvas
   Recovered from APQP5-improved (1).html: ribbon-selected phase, tools panel
   with required/supporting typing, five lanes with per-lane progress, and a
   readiness meter. Restyled to the platform, same interaction.
   ========================================================================= */

.pp-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 1rem; }
.pp-tools, .pp-side { min-width: 0; }
.pp-side .panel:last-child { margin-bottom: 1rem; }

.pp-tool-list { display: flex; flex-direction: column; gap: .4rem; margin-top: .6rem; }
.pp-tool {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .5rem .6rem; background: var(--surface-2); cursor: grab;
}
.pp-tool:hover { border-color: var(--ink-4); }
.pp-tool.is-assigned { background: var(--accent-bg); border-color: #c7d2fe; }
.pp-tool.is-dragging { opacity: .45; }
.pp-tool-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.pp-tool-name { font-weight: 600; font-size: .87rem; }
.pp-tool-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; margin-top: .3rem;
}
.pp-type {
  font-size: .64rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  padding: .08rem .35rem; border-radius: 3px; white-space: nowrap;
}
.pp-type-required   { background: var(--ink); color: #fff; }
.pp-type-supporting { background: var(--surface); color: var(--ink-3); border: 1px solid var(--line-2); }
.pp-status { font-size: .74rem; text-decoration: none; }
.pp-status-has     { color: var(--ok); font-weight: 600; }
.pp-status-none    { color: var(--ink-3); }
.pp-status-pending { color: var(--ink-4); font-style: italic; }
.pp-assigned { font-size: .72rem; color: var(--accent-ink); font-weight: 600; }

/* Planning readiness — recovered meter, with its counting defect fixed. */
.pp-meter {
  position: relative; height: 1.4rem; border-radius: 20px;
  background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; margin: .5rem 0 .4rem;
}
.pp-meter-fill { height: 100%; transition: width .25s ease; }
.pp-meter-ok   { background: linear-gradient(90deg, #34d399, #10b981); }
.pp-meter-warn { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.pp-meter-low  { background: linear-gradient(90deg, #f87171, #ef4444); }
.pp-meter-text {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: .72rem; font-weight: 700; color: var(--ink);
}
.pp-rule { border: none; border-top: 1px solid var(--line); margin: .6rem 0; }
.pp-coach ul { color: var(--ink-2); }

/* The five lanes. */
.pp-canvas { display: flex; gap: .6rem; overflow-x: auto; padding-bottom: .4rem; }
.pp-lane {
  flex: 1 1 200px; min-width: 190px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface-2); padding: .55rem;
  display: flex; flex-direction: column; gap: .35rem;
}
.pp-lane.is-current { border-color: var(--accent); background: var(--accent-bg); }
.pp-lane.is-closed  { border-color: #a7f3d0; }
.pp-lane-head { display: flex; align-items: center; justify-content: space-between; gap: .4rem; }
.pp-lane-title {
  font: inherit; font-size: .78rem; font-weight: 600; text-align: left;
  background: none; border: none; padding: 0; cursor: pointer; color: var(--ink);
  display: flex; align-items: center; gap: .35rem;
}
.pp-lane-title:hover { color: var(--accent); }
.pp-lane-bar { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.pp-lane-fill { height: 100%; background: var(--accent); transition: width .25s ease; }
.pp-zone {
  flex: 1; min-height: 84px; border: 1px dashed var(--line-2); border-radius: var(--radius-sm);
  padding: .35rem; display: flex; flex-direction: column; gap: .3rem;
}
.pp-zone.has-tools { border-style: solid; background: var(--surface); }
.pp-zone.is-over { border-color: var(--accent); background: var(--accent-bg); }
.pp-zone-hint { font-size: .72rem; color: var(--ink-4); margin: auto; }
.pp-chip {
  display: flex; align-items: center; justify-content: space-between; gap: .3rem;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 4px;
  padding: .22rem .3rem; font-size: .76rem; cursor: grab;
}
.pp-chip:hover { border-color: var(--ink-4); }

.nav-sep { height: 1px; background: rgba(255,255,255,.09); margin: .35rem .55rem; }

@media (max-width: 1100px) { .pp-grid { grid-template-columns: 1fr; } }

/* ---- Project Charter (assembly STEP 2) --------------------------------- */

.ch-head { border-bottom: 1px solid var(--line); padding-bottom: .7rem; margin-bottom: 1rem; }
.ch-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.ch-main, .ch-side { min-width: 0; }

.ch-id { display: grid; grid-template-columns: 1fr 1fr; gap: .1rem .9rem; margin-top: .4rem; }
.ch-id-row { display: flex; gap: .5rem; padding: .3rem 0; border-bottom: 1px solid var(--line); }
.ch-id-label { flex: 0 0 44%; font-size: .78rem; color: var(--ink-3); font-weight: 600; }
.ch-id-value { font-size: .86rem; min-width: 0; overflow-wrap: anywhere; }

.ch-purpose, .ch-status {
  width: 100%; font: inherit; font-size: .88rem; margin-top: .4rem;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  padding: .5rem .6rem; background: var(--surface); color: var(--ink); resize: vertical;
}
.ch-purpose:focus, .ch-status:focus { outline: none; border-color: var(--accent); }

.ch-list { list-style: none; margin: .4rem 0 0; padding: 0; }
.ch-item {
  display: flex; align-items: flex-start; gap: .6rem;
  padding: .45rem 0; border-bottom: 1px solid var(--line);
}
.ch-item:last-child { border-bottom: none; }
.ch-item-date { flex: 0 0 7.5rem; color: var(--ink-2); font-weight: 600; }
.ch-item-text { flex: 1; font-size: .87rem; overflow-wrap: anywhere; }

.ch-progress { list-style: none; margin: .4rem 0 .6rem; padding: 0; }
.ch-progress li {
  display: flex; align-items: center; gap: .5rem;
  padding: .28rem 0; font-size: .85rem; color: var(--ink-3);
}
.ch-progress li.is-filled { color: var(--ink); }
.ch-tick {
  width: 1.1rem; height: 1.1rem; flex: 0 0 1.1rem; border-radius: 50%;
  display: grid; place-items: center; font-size: .7rem; font-weight: 700;
  background: var(--surface-2); color: var(--ink-4); border: 1px solid var(--line-2);
}
.ch-progress li.is-filled .ch-tick { background: var(--ok-bg); color: var(--ok); border-color: #a7f3d0; }

@media (max-width: 1100px) {
  .ch-grid { grid-template-columns: 1fr; }
  .ch-id { grid-template-columns: 1fr; }
}

/* ---- PPAP evidence state (assembly STEP 3) ----------------------------- */

.ppap-tally { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0 .35rem; }
.ppap-chip {
  font-size: .76rem; padding: .18rem .5rem; border-radius: 20px;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink-2);
}
.ppap-chip strong { font-size: .86rem; }
.ppap-chip.is-complete   { background: var(--ok-bg);   border-color: #a7f3d0; color: var(--ok); }
.ppap-chip.is-incomplete { background: var(--surface); border-color: var(--line-2); }
.ppap-chip.is-na         { background: var(--surface-2); color: var(--ink-3); }
.ppap-chip.is-undecided  { background: var(--accent-bg); border-color: #c7d2fe; color: var(--accent-ink); }
.ppap-chip.is-warn       { background: var(--warn-bg); border-color: #fde68a; color: var(--warn); }

.ppap-filters {
  display: flex; align-items: center; gap: .15rem; flex-wrap: wrap;
  border-bottom: 1px solid var(--line); margin: .6rem 0 .5rem;
}
.ppap-filters .fine { margin-left: auto; padding-right: .3rem; }

.col-st { width: 118px; }
.col-ap { width: 190px; }
.col-note { width: 150px; }

.ppap-status {
  display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .02em;
  padding: .12rem .45rem; border-radius: 4px; white-space: nowrap;
}
.ppap-complete       { background: var(--ok-bg);   color: var(--ok); }
.ppap-incomplete     { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line-2); }
.ppap-not_applicable { background: var(--surface-2); color: var(--ink-4); }
.ppap-undecided      { background: var(--accent-bg); color: var(--accent-ink); }

/* A quiet left edge, so status is scannable down the table without shouting. */
.ppap-row td:first-child { border-left: 3px solid transparent; }
.ppap-row-complete   td:first-child { border-left-color: #10b981; }
.ppap-row-incomplete td:first-child { border-left-color: var(--line-2); }
.ppap-row-undecided  td:first-child { border-left-color: var(--accent); }

.ppap-phase {
  font-size: .66rem; font-weight: 700; letter-spacing: .04em;
  background: var(--ink-2); color: #fff; padding: .06rem .3rem; border-radius: 3px;
  white-space: nowrap; vertical-align: middle;
}

.ppap-ev {
  position: relative; padding: .3rem 1.5rem .3rem 0;
  border-bottom: 1px solid var(--line);
}
.ppap-ev:last-of-type { border-bottom: none; }
.ppap-ev-main { font-size: .82rem; }
.ppap-ev .icon-btn { position: absolute; right: 0; top: .25rem; }
.ppap-cand {
  margin-top: .3rem; padding: .35rem; border-radius: var(--radius-sm);
  background: var(--accent-bg); border: 1px solid #c7d2fe;
  display: flex; flex-direction: column; gap: .25rem; align-items: flex-start;
}

/* ---- Part Submission Warrant (assembly STEP 4) ------------------------- */

.psw-card {
  border: 1px solid var(--line-2); border-radius: var(--radius);
  background: var(--surface-2); padding: .85rem 1rem; margin: .6rem 0 .9rem;
}
.psw-empty { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.psw-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: .6rem;
}
.psw-actions { display: flex; gap: .4rem; flex-shrink: 0; }

.psw-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: .1rem .9rem; margin-bottom: .7rem;
}
.psw-f { display: flex; gap: .5rem; padding: .26rem 0; border-bottom: 1px solid var(--line); }
.psw-f-label { flex: 0 0 45%; font-size: .74rem; color: var(--ink-3); font-weight: 600; }
.psw-f-value { font-size: .83rem; min-width: 0; overflow-wrap: anywhere; }

.psw-decl {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: .6rem .75rem; margin-bottom: .7rem;
}
.psw-decl p { font-size: .84rem; color: var(--ink-2); }
.psw-decl-label {
  font-size: .64rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: .25rem;
}

.psw-parties { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: .6rem; }
.psw-party {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: .55rem .7rem;
}
.psw-party-name { font-size: .78rem; font-weight: 620; margin-bottom: .25rem; }
/* Deliberately NOT green: an attestation is not an approval and must not read as one. */
.psw-attested {
  font-size: .74rem; font-weight: 650; color: var(--accent-ink);
  background: var(--accent-bg); border: 1px solid #c7d2fe;
  padding: .08rem .4rem; border-radius: 4px;
}

@media (max-width: 900px) { .psw-parties { grid-template-columns: 1fr; } }

/* ---- recovered tools (assembly STEP 5) --------------------------------- */

.tab-count {
  font-size: .66rem; font-weight: 700; background: var(--surface-2);
  border: 1px solid var(--line-2); color: var(--ink-3);
  padding: 0 .28rem; border-radius: 20px; margin-left: .2rem;
}
.tab.active .tab-count { background: var(--accent-bg); border-color: #c7d2fe; color: var(--accent-ink); }

.tool-fields {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: .1rem .9rem; margin-bottom: .5rem;
}
.tool-f { display: flex; gap: .5rem; padding: .3rem 0; border-bottom: 1px solid var(--line); }
.tool-f-label { flex: 0 0 40%; font-size: .74rem; color: var(--ink-3); font-weight: 600; }
.tool-f-value { font-size: .84rem; min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; }

.fish-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: .5rem; margin-bottom: .5rem;
}
.fish-cat {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: .5rem .6rem;
}
.fish-cat-name { font-size: .78rem; font-weight: 650; margin-bottom: .2rem; }
.fish-cat ul { font-size: .82rem; color: var(--ink-2); }

.metric.metric-key { background: var(--accent-bg); border-color: #c7d2fe; }

/* Step-type column: must show the selected value, not just the dropdown arrow.
   Same lesson as the S/O/D rating columns in the FMEA grid. */
.col-step { width: 140px; }

/* A capability invoked in context from the phase plan (its workspace is not in this
   project's navigation). Workspace != exclusive methodology ownership. */
.pp-tool-action { margin-top: .35rem; display: flex; justify-content: flex-end; }
button.pp-status {
  border: none; background: none; padding: 0; cursor: pointer;
  font: inherit; font-size: .74rem; text-align: left;
}
button.pp-status:hover { text-decoration: underline; }

/* ---- PFMEA -> characteristic -> Control Plan (assembly STEP 7) ---------- */

.cp-actions { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.cp-prov { margin-top: .2rem; }
.cp-review { margin-top: .25rem; display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.check.is-disabled { opacity: .55; }
.check.is-disabled input { cursor: not-allowed; }

/* ---- DMAIC journey (assembly STEP 8) ----------------------------------- */

.dj-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.dj-main, .dj-side { min-width: 0; }

.dj-caps { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .5rem; margin-top: .6rem; }
.dj-cap {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); padding: .55rem .65rem;
  display: flex; flex-direction: column; gap: .25rem;
}
.dj-cap.has { background: var(--surface); border-color: var(--line-2); }
.dj-cap-top { display: flex; align-items: center; justify-content: space-between; gap: .4rem; }
.dj-cap-name { font-weight: 620; font-size: .86rem; }
.dj-cap-count {
  font-size: .72rem; font-weight: 700; color: var(--ok);
  background: var(--ok-bg); border: 1px solid #a7f3d0;
  padding: 0 .35rem; border-radius: 20px;
}
.dj-cap-foot { display: flex; align-items: center; justify-content: space-between; gap: .4rem; margin-top: auto; }

@media (max-width: 1100px) { .dj-grid { grid-template-columns: 1fr; } }
