/* MTIS Failure Investigator — design system
   Authority: 06_CLAUDE_CODE_HANDOFF/design_guide.md
   Archetype: utility / professional engineering dashboard. Narrow stage rail + wide work area.
   One coherent type system (Source Sans 3 + mono for audit detail). Deep-teal accent,
   semantic confidence bands. No generic blue, no Inter/Roboto, no Space Grotesk/IBM Plex. */

:root {
  --bg: #f4f2ec;            /* warm off-white paper */
  --surface: #ffffff;
  --surface-2: #faf9f5;
  --ink: #1b2222;          /* off-black */
  --ink-2: #364040;
  --muted: #5e6b6b;
  --line: #dddacf;
  --line-2: #ebe8df;

  --accent: #0f5c5c;       /* deep teal */
  --accent-ink: #0a4444;
  --accent-soft: #e3efed;
  --accent-soft-2: #d3e6e3;

  --high: #1f7a4d;  --high-bg: #e7f3ec;  --high-line:#bfe0cc;
  --mod:  #9a6a00;  --mod-bg:  #fbf0d6;  --mod-line:#ecd9a8;
  --low:  #66707a;  --low-bg:  #edeef0;  --low-line:#dadde1;
  --warn: #9c5400;  --warn-bg: #fcefda;  --warn-line:#efce9c;
  --danger:#a32525; --danger-bg:#fbe9e9;

  --r: 8px; --r-sm: 5px;
  --sp: 8px;
  --shadow: 0 1px 2px rgba(20,40,40,.06), 0 2px 8px rgba(20,40,40,.05);
  --shadow-lift: 0 2px 6px rgba(20,40,40,.10), 0 8px 24px rgba(20,40,40,.08);
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  --sans: "Source Sans 3", "Source Sans Pro", -apple-system, Segoe UI, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 15px; line-height: 1.55;
  font-feature-settings: "ss01","cv01"; letter-spacing: .005em;
}
h1,h2,h3,h4 { line-height: 1.18; color: var(--ink); margin: 0 0 .4em; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.22rem; } h3 { font-size: 1.04rem; }
p { margin: 0 0 .8em; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
small, .muted { color: var(--muted); font-size: .85rem; }
code, kbd, pre { font-family: var(--mono); }

/* --- App shell ----------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 28px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 700; color: var(--ink); letter-spacing: -.01em; }
.brand .mark { width: 26px; height: 26px; flex: none; }
.brand .sub { font-weight: 500; color: var(--muted); font-size: .82rem; }
.topnav { margin-left: auto; display: flex; gap: 6px; }
.topnav a { padding: 7px 12px; border-radius: var(--r-sm); color: var(--ink-2); font-weight: 600; font-size: .9rem; }
.topnav a:hover { background: var(--accent-soft); text-decoration: none; }

.layout { display: grid; grid-template-columns: 244px minmax(0, 1fr); align-items: start; }
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }

/* --- Stage rail (narrow, clickable) -------------------------------------- */
.rail { position: sticky; top: 57px; align-self: start; padding: 22px 14px 40px; border-right: 1px solid var(--line); min-height: calc(100vh - 57px); background: var(--surface-2); }
.rail .rail-head { font-size: .72rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 700; padding: 0 8px 10px; }
.stepper { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.stepper li { position: relative; }
.stepper a {
  display: flex; gap: 11px; align-items: flex-start; padding: 9px 9px; border-radius: var(--r-sm);
  color: var(--ink-2); position: relative;
}
.stepper a:hover { background: var(--accent-soft); text-decoration: none; }
.stepper .num {
  flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--surface);
  border: 1.5px solid var(--line); color: var(--muted); font-size: .76rem; font-weight: 700;
  display: grid; place-items: center; margin-top: 1px;
}
.stepper .lbl { font-weight: 600; font-size: .92rem; }
.stepper .dsc { display: block; font-weight: 400; color: var(--muted); font-size: .76rem; line-height: 1.3; margin-top: 1px; }
.stepper li.done .num { background: var(--high-bg); border-color: var(--high-line); color: var(--high); }
.stepper li.done .num::after { content: "\2713"; }
.stepper li.done .num span { display: none; }
.stepper li.current > a { background: var(--accent-soft-2); }
.stepper li.current .num { background: var(--accent); border-color: var(--accent); color: #fff; }
.stepper li.current .lbl { color: var(--accent-ink); }
.stepper .track { position: absolute; left: 19.5px; top: 30px; bottom: -4px; width: 1.5px; background: var(--line); }

/* --- Work area ----------------------------------------------------------- */
.work { padding: 30px 40px 80px; max-width: 1180px; }
.work.solo { max-width: 1000px; margin: 0 auto; }
.work > header.page { margin-bottom: 20px; }
.page .eyebrow { font-size: .74rem; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); font-weight: 700; }
.page h1 .muted { font-weight: 500; }
.lead { color: var(--ink-2); max-width: 70ch; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px 22px; box-shadow: var(--shadow); margin: 0 0 18px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card.tight { padding: 14px 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px){ .grid-2 { grid-template-columns: 1fr; } }
.stack > * + * { margin-top: 14px; }

/* --- Forms --------------------------------------------------------------- */
label.field { display: block; margin: 0 0 12px; }
label.field > .lab { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 4px; color: var(--ink-2); }
label.field > .hint { display:block; font-weight: 400; color: var(--muted); font-size: .8rem; margin-bottom: 5px; }
input[type=text], input[type=number], textarea, select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); font: inherit; font-size: .92rem;
}
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
input::placeholder, textarea::placeholder { color: #9aa3a3; }

.btn {
  display: inline-flex; align-items: center; gap: 7px; background: var(--accent); color: #fff;
  border: 1px solid var(--accent); padding: 9px 16px; border-radius: var(--r-sm); cursor: pointer;
  font: inherit; font-weight: 650; font-size: .9rem; transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:hover { background: var(--accent-ink); box-shadow: var(--shadow-lift); transform: translateY(-1px); text-decoration: none; }
.btn:active { transform: translateY(0); }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.secondary { background: var(--surface); color: var(--accent-ink); border-color: var(--line); }
.btn.secondary:hover { background: var(--accent-soft); }
.btn.ghost { background: transparent; color: var(--ink-2); border-color: transparent; }
.btn.ghost:hover { background: var(--line-2); box-shadow: none; }
.btn.danger { background: var(--surface); color: var(--danger); border-color: var(--danger-bg); }
.btn.danger:hover { background: var(--danger-bg); }
.btn.sm { padding: 5px 10px; font-size: .82rem; }
form.inline { display: inline; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* --- Mode cards ---------------------------------------------------------- */
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 760px){ .modes { grid-template-columns: 1fr; } }
.mode-opt { border: 1.5px solid var(--line); border-radius: var(--r); padding: 13px 14px; cursor: pointer; background: var(--surface); transition: border-color .12s, box-shadow .12s; display:block; }
.mode-opt:hover { border-color: var(--accent-soft-2); }
.mode-opt input { position: absolute; opacity: 0; }
.mode-opt .name { font-weight: 700; }
.mode-opt .tag { display: block; color: var(--muted); font-size: .82rem; margin-top: 3px; line-height: 1.4; }
.mode-opt.checked, .mode-opt:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

/* --- Tables -------------------------------------------------------------- */
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: 9px 11px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
tbody tr:hover { background: var(--surface-2); }
.table-card { padding: 4px 6px; }

/* --- Confidence bands ---------------------------------------------------- */
.band { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 700; border: 1px solid transparent; }
.band::before { content:""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.band-high { color: var(--high); background: var(--high-bg); border-color: var(--high-line); }
.band-moderate { color: var(--mod); background: var(--mod-bg); border-color: var(--mod-line); }
.band-low { color: var(--low); background: var(--low-bg); border-color: var(--low-line); }
.band-ruled_out { color: var(--muted); background: var(--surface-2); border-color: var(--line); text-decoration: line-through; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); }
.legend b { color: var(--ink-2); }

.confbar { height: 8px; border-radius: 999px; background: var(--line-2); overflow: hidden; margin: 6px 0; }
.confbar > span { display: block; height: 100%; border-radius: 999px; }
.confbar.high > span { background: var(--high); }
.confbar.moderate > span { background: var(--mod); }
.confbar.low > span { background: var(--low); }

.cand { border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; margin-bottom: 14px; background: var(--surface); box-shadow: var(--shadow); }
.cand.lead { border-color: var(--accent-soft-2); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow); }
.cand.eliminated { opacity: .55; }
.cand .scorehead { display: flex; align-items: baseline; gap: 10px; justify-content: space-between; flex-wrap: wrap; }
.cand .score { font-size: 1.5rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.cand h3 { margin: 0; }
.three { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; margin-top: 12px; }
@media (max-width: 820px){ .three { grid-template-columns: 1fr; } }
.three .col h4 { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 6px; }
.three ul { margin: 0; padding-left: 16px; font-size: .86rem; }
.three li { margin-bottom: 4px; }
.three .col.tests h4 { color: var(--accent); }

/* --- Misc ---------------------------------------------------------------- */
.notice { display: flex; gap: 11px; padding: 12px 15px; border-radius: var(--r); font-size: .9rem; border: 1px solid; margin: 0 0 16px; }
.notice .ic { flex: none; font-weight: 700; }
.notice.warn { background: var(--warn-bg); border-color: var(--warn-line); color: #6f3d00; }
.notice.info { background: var(--accent-soft); border-color: var(--accent-soft-2); color: var(--accent-ink); }
.notice.draft { background: var(--mod-bg); border-color: var(--mod-line); color: #6f4d00; font-weight: 600; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 700; background: var(--line-2); color: var(--ink-2); }
.pill.draft { background: var(--mod-bg); color: var(--mod); border:1px solid var(--mod-line); }
.pill.prelim { background: var(--warn-bg); color: var(--warn); border:1px solid var(--warn-line); }
.pill.signed { background: var(--high-bg); color: var(--high); border:1px solid var(--high-line); }
.tag-chip { display: inline-block; padding: 1px 7px; margin: 1px; border-radius: 4px; background: var(--accent-soft); color: var(--accent-ink); font-size: .76rem; font-family: var(--mono); }
.status-chip { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: .76rem; font-weight: 600; }
.status-pending { background: var(--mod-bg); color: var(--mod); }
.status-approved { background: var(--high-bg); color: var(--high); }
.status-rejected { background: var(--danger-bg); color: var(--danger); }
.status-other { background: var(--line-2); color: var(--ink-2); }
details.explain { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; }
details.explain summary { cursor: pointer; font-size: .82rem; color: var(--muted); font-weight: 600; }
.dims { font-family: var(--mono); font-size: .8rem; color: var(--muted); margin-top: 6px; }
pre.report { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 20px 22px; font-size: .82rem; line-height: 1.5; overflow-x: auto; }
.empty { color: var(--muted); font-style: italic; padding: 8px 0; }
.qrow { padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.qrow:last-child { border-bottom: none; }
hr.soft { border: none; border-top: 1px solid var(--line-2); margin: 18px 0; }
.kbd-help { font-size:.8rem; color: var(--muted); }
.skip-link { position:absolute; left:-999px; }
.skip-link:focus { left: 8px; top: 8px; background:#fff; padding:8px 12px; z-index:50; border-radius:6px; }

/* --- Failure-mode landscape (full taxonomy screen) ---------------------- */
.famblock { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); margin-bottom: 8px; box-shadow: var(--shadow); }
.famblock > summary { cursor: pointer; list-style: none; display: flex; align-items: baseline; gap: 12px; padding: 11px 14px; font-weight: 650; }
.famblock > summary::-webkit-details-marker { display: none; }
.famblock > summary::before { content: "▸"; color: var(--muted); font-size: .8rem; }
.famblock[open] > summary::before { content: "▾"; }
.famblock .famname { color: var(--ink); }
.famblock .famcount { margin-left: auto; color: var(--muted); font-size: .8rem; font-weight: 600; }
.modelist { list-style: none; margin: 0; padding: 2px 0 8px; }
.modeitem { display: flex; align-items: center; gap: 10px; padding: 6px 14px; border-top: 1px solid var(--line-2); font-size: .9rem; }
.modeitem .mname { flex: 1; min-width: 0; }
.modeitem .mstatus { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--low-line); }
.modeitem.supported .mstatus { background: var(--high); }
.modeitem.weakened .mstatus { background: var(--danger); }
.modeitem.considered .mstatus { background: var(--mod-line); }
.modeitem.ruled_out_material { opacity: .5; }
.modeitem.ruled_out_material .mname { text-decoration: line-through; text-decoration-color: var(--line); }
.confbar.mini { width: 84px; height: 6px; flex: none; }
.mbadge { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; flex: none; width: 84px; text-align: right; color: var(--muted); }
.mbadge.supported { color: var(--high); }
.mbadge.weakened { color: var(--danger); }

/* expandable per-mode card detail inside the landscape */
.modeitem > .modedetail { flex: 1; min-width: 0; }
.modedetail > summary { list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.modedetail > summary::-webkit-details-marker { display: none; }
.modedetail .mname { flex: 1; min-width: 0; }
.modedetail .score-sm { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink-2); font-size: .82rem; width: 26px; text-align: right; }
.modedetail .three { border-top: 1px dashed var(--line-2); margin-top: 6px; }
.modeitem:has(.modedetail[open]) { background: var(--surface-2); }
