/* CCPP RCA Assistant — Reliability Management look (Blue #1E5AA8 · Orange #EB8222) */
:root {
  --navy: #1e5aa8;        /* brand blue: headings, structure, tables */
  --navy-dark: #164679;   /* darker blue: hovers, topbar gradient end */
  --navy-deep: #0e2c55;   /* deepest blue: topbar/login backgrounds */
  --steel: #4a6b91;       /* blue-grey: secondary text, labels */
  --accent: #eb8222;      /* brand orange: primary actions, active states */
  --accent-dark: #cf6a10; /* orange hover */
  --accent-soft: #fdeedd; /* orange tint: highlights, warnings */
  --bg: #f3f6fa;
  --card: #ffffff;
  --line: #d7dfe9;
  --text: #22303f;
  --muted: #64748b;
  --ok: #1e7d47;
  --bad: #a83232;
  --warn-bg: #fdf6ec;
  --warn-line: #f0cf9b;
  --focus-ring: rgba(30, 90, 168, .28);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45;
}
::selection { background: #f8d9b4; }

/* ---------- top bar ---------- */
.topbar {
  background: linear-gradient(90deg, var(--navy-deep) 0%, var(--navy-dark) 60%, var(--navy) 100%);
  color: #fff; display: flex; align-items: center;
  justify-content: space-between; padding: 8px 20px; min-height: 56px;
  flex-wrap: wrap; gap: 6px 16px;
  border-bottom: 3px solid var(--accent);
  position: sticky; top: 0; z-index: 20; box-shadow: 0 1px 6px rgba(14,44,85,.35);
}
.brand { white-space: nowrap; }
@media (max-width: 900px) { .brand-sub { display: none; } }
.brand { font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 7px; background: #fff; padding: 2px;
  flex: none; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.brand-mark {
  background: var(--accent); color: #fff; font-weight: 800; letter-spacing: .5px;
  padding: 2px 8px; border-radius: 4px; font-size: 14px;
}
.brand-sub { font-weight: 400; font-size: 12px; color: #b9cbe3; }
.topbar nav { display: flex; align-items: center; gap: 10px; }
.nav-btn {
  background: transparent; color: #dbe6f3; border: 1px solid transparent;
  padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 14px;
}
.nav-btn:hover { background: rgba(255,255,255,.14); color: #fff; }

.model-select {
  width: auto; max-width: 260px; margin: 0; padding: 5px 8px;
  background: var(--navy-deep); color: #dbe6f3; border: 1px solid #35598a;
  border-radius: 6px; font-size: 13px;
}
.model-select:focus { outline: 2px solid var(--accent); }

.pill {
  font-size: 12px; padding: 3px 10px; border-radius: 999px; font-weight: 600;
  background: #e7eef6; color: var(--steel); white-space: nowrap;
}
.pill-on  { background: #d9efe2; color: var(--ok); }
.pill-off { background: #f3dede; color: var(--bad); }

/* ---------- layout ---------- */
main { max-width: 1080px; margin: 0 auto; padding: 24px 20px 80px; }
.view.hidden, .hidden { display: none !important; }
.view-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
h1 { font-size: 22px; color: var(--navy); margin: 0; }
h2 { font-size: 18px; color: var(--navy); margin: 0 0 10px; }
h3 { font-size: 15px; color: var(--steel); margin: 20px 0 8px; }
.hint { color: var(--muted); font-size: 13.5px; margin: 4px 0 14px; }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- buttons & inputs ---------- */
.btn {
  background: #fff; border: 1px solid var(--line); color: var(--navy);
  padding: 8px 14px; border-radius: 7px; cursor: pointer; font-size: 14px; font-weight: 500;
  transition: border-color .12s, background .12s, box-shadow .12s;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; line-height: 1.2;
}

/* ---------- monochrome line icons (professional, currentColor) ---------- */
.ic {
  width: 1.05em; height: 1.05em; flex: none; display: inline-block; vertical-align: -0.15em;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.btn.small .ic { stroke-width: 2.1; }
.ic-spin { animation: ic-spin 0.9s linear infinite; transform-origin: 50% 50%; }
@keyframes ic-spin { to { transform: rotate(360deg); } }

/* ---------- dictation (speech-to-text) ---------- */
.dictate-wrap { position: relative; display: block; margin-top: 4px; }
.dictate-wrap > textarea { margin-top: 0; padding-right: 44px; }
.dictate-btn {
  position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--navy);
  cursor: pointer; transition: background .12s, color .12s, border-color .12s;
}
.dictate-btn .ic { width: 16px; height: 16px; }
.dictate-btn:hover { border-color: var(--navy); background: #eef3f9; }
.dictate-btn.recording {
  color: #fff; background: var(--bad); border-color: var(--bad);
  animation: dictate-pulse 1.1s ease-in-out infinite;
}
.dictate-btn.busy { color: var(--accent-dark); border-color: var(--accent); background: var(--accent-soft); cursor: wait; }
@keyframes dictate-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(168,50,50,.45); } 50% { box-shadow: 0 0 0 5px rgba(168,50,50,0); } }

/* dictation review dialog — raw vs. professional rephrasing */
.dictation-review { width: min(620px, 94vw); }
.dictation-review label { margin-bottom: 14px; }
.dictation-review .dict-suggested { color: var(--accent-dark); }
.dictation-review .dict-suggested textarea {
  border-color: var(--accent); background: var(--accent-soft); color: var(--text);
}
.dictation-review textarea { resize: vertical; }

/* AI-prefilled effect fields: pending suggestions shown in dark grey */
textarea.suggested, input.suggested, select.suggested { color: #6b7280 !important; font-style: italic; }
textarea.suggested, input.suggested { border-color: var(--accent); background: #fffdfa; }
.suggest-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 8px;
  padding: 8px 12px; margin: 4px 0 14px; font-size: 13.5px; color: var(--accent-dark);
}
.suggest-bar .suggest-actions { display: flex; gap: 8px; flex: none; }
/* Microphone level test (Admin ▸ Microphone & dictation) */
.mic-test { max-width: 640px; }
.mic-test #mic-device {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--text); font-size: 14px; min-width: 220px;
}
.mic-meter {
  height: 14px; margin: 12px 0 8px; border-radius: 8px;
  background: #e7edf4; border: 1px solid var(--line); overflow: hidden;
}
.mic-meter > span {
  display: block; height: 100%; width: 0%; border-radius: 8px;
  background: var(--muted); transition: width .06s linear, background .2s ease;
}
.mic-meter > span.live { background: var(--ok); }
/* Report branding editor (Admin ▸ Report branding) */
.brand-editor { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
.brand-fields { flex: 1 1 380px; min-width: 300px; }
.brand-fields .fld { display: block; margin-bottom: 10px; font-size: 13px; color: var(--steel); }
.brand-fields .fld input {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 14px; color: var(--text);
}
.brand-fields .fld input:focus { outline: 2px solid var(--focus-ring); border-color: var(--navy); }
.brand-preview { flex: 0 0 240px; }
.brand-logo-box {
  display: flex; align-items: center; justify-content: center;
  min-height: 96px; padding: 12px; background: #fff;
  border: 1px dashed var(--line); border-radius: 8px;
}
.brand-logo-box img { max-height: 72px; max-width: 210px; width: auto; height: auto; }
/* status messages: monochrome icon inherits the line's colour */
.status-ok   { color: var(--ok); }
.status-warn { color: var(--accent-dark); }
.status-err  { color: var(--bad); }
.btn:hover { border-color: var(--navy); box-shadow: 0 1px 3px rgba(30,90,168,.15); }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); box-shadow: 0 2px 6px rgba(235,130,34,.35); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: #e9eff6; box-shadow: none; }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); box-shadow: 0 1px 3px rgba(168,50,50,.15); }
.btn:disabled { opacity: .55; cursor: wait; }
.btn:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 1px; }

input, select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px;
  font: inherit; color: var(--text); background: #fff; margin-top: 4px;
}
input:focus, select:focus, textarea:focus {
  outline: 3px solid var(--focus-ring); border-color: var(--navy);
}
label { display: block; font-size: 13.5px; font-weight: 600; color: var(--steel); margin-bottom: 12px; }
textarea { resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }

/* asset typeahead */
.typeahead-anchor { position: relative; }
.typeahead-menu {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 30;
  background: var(--card); border: 1px solid var(--line); border-radius: 7px;
  box-shadow: 0 6px 18px rgba(14,44,85,.18); max-height: 260px; overflow-y: auto;
}
.typeahead-item {
  display: flex; gap: 10px; align-items: baseline; padding: 7px 10px;
  cursor: pointer; font-weight: 400;
}
.typeahead-item b { color: var(--navy); font-size: 13.5px; white-space: nowrap; }
.typeahead-item span { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.typeahead-item:hover, .typeahead-item.active { background: var(--accent-soft); }
input[readonly] { background: #f4f6f8; color: var(--steel); }

.filters { display: flex; gap: 10px; margin-bottom: 16px; }
.filters input[type=search] { flex: 1; margin-top: 0; }
.filters select { width: auto; margin-top: 0; }

.row-actions { display: flex; align-items: center; gap: 10px; margin: 10px 0 16px; flex-wrap: wrap; }
.inline-check { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 500; }
.inline-check input { width: auto; margin: 0; }

/* ---------- case list ---------- */
.case-list { display: grid; gap: 10px; }
.case-card {
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid transparent;
  border-radius: 10px; padding: 14px 16px; cursor: pointer; display: grid;
  grid-template-columns: 1fr auto; gap: 4px 12px;
  transition: box-shadow .15s, border-color .15s, transform .15s;
}
.case-card:hover {
  box-shadow: 0 3px 12px rgba(30,90,168,.16); border-color: var(--navy);
  border-left-color: var(--accent); transform: translateY(-1px);
}
.case-card .cc-title { font-weight: 600; color: var(--navy); }
.case-card .cc-meta { color: var(--muted); font-size: 13px; grid-column: 1; }
.case-card .cc-right { grid-row: 1 / span 2; grid-column: 2; text-align: right; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.sev { font-size: 12px; font-weight: 700; }
.sev-Critical { color: #8e1717; } .sev-High { color: var(--bad); }
.sev-Medium { color: var(--accent-dark); } .sev-Low { color: var(--ok); }

/* ---------- steps ---------- */
.case-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.case-head h1 { flex: 1; font-size: 19px; }
.save-indicator { font-size: 12px; color: var(--ok); min-width: 60px; }

.steps {
  display: flex; list-style: none; padding: 0; margin: 0 0 20px; gap: 4px;
  border-bottom: 2px solid var(--line);
}
.steps li {
  display: flex; align-items: center; gap: 7px; padding: 9px 14px; cursor: pointer;
  color: var(--muted); font-size: 14px; font-weight: 600;
  border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.steps li:hover { color: var(--navy); }
.steps li span {
  display: inline-flex; align-items: center; justify-content: center;
  width: 21px; height: 21px; border-radius: 50%; background: var(--line);
  color: var(--steel); font-size: 12px;
}
.steps li.active { color: var(--navy); border-bottom-color: var(--accent); }
.steps li.active span { background: var(--accent); color: #fff; }

.step-panel {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 20px 22px; display: none; box-shadow: 0 1px 3px rgba(14,44,85,.06);
}
.step-panel.active { display: block; }
.step-nav { display: flex; justify-content: space-between; margin-top: 18px; }

/* ---------- banners ---------- */
.banner-warn {
  background: var(--warn-bg); border: 1px solid var(--warn-line); border-left: 4px solid var(--accent);
  border-radius: 7px; padding: 10px 14px; font-size: 13.5px; margin-bottom: 14px;
}

/* ---------- cause cards ---------- */
.cause-card {
  border: 1px solid var(--line); border-left: 4px solid var(--steel);
  border-radius: 7px; padding: 12px 14px; margin-bottom: 10px; background: #fbfcfd;
}
.cause-card.st-Confirmed { border-left-color: var(--ok); background: #f4faf6; }
.cause-card.st-RuledOut { border-left-color: #9aa7b4; opacity: .75; }
.cause-card.dismissed { opacity: .45; }
.cause-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.cause-desc { font-weight: 600; color: var(--navy); flex: 1; min-width: 220px; }
.tag { font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.tag-High { background: var(--accent-soft); color: var(--accent-dark); }
.tag-Medium { background: #e4ecf7; color: var(--navy); }
.tag-Low { background: #eef3ee; color: #567; }
.tag-src-llm { background: #e4ecf5; color: var(--steel); }
.tag-src-user { background: #e9e4f5; color: #5b4a8a; }
.tag-src-history { background: #f5efe0; color: #7a6420; }
.cause-body { font-size: 13.5px; margin-top: 6px; color: #3c4a58; }
.cause-body b { color: var(--steel); }
.fmea-chain { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.fmea-chain b { color: var(--steel); }
.cause-controls { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.status-group { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.status-group button {
  border: none; background: #fff; padding: 5px 11px; cursor: pointer; font-size: 12.5px; font-weight: 600;
  color: var(--muted); border-right: 1px solid var(--line);
}
.status-group button:last-child { border-right: none; }
.status-group button:hover { background: #eef3f9; }
.status-group button.sel-Confirmed { background: var(--ok); color: #fff; }
.status-group button.sel-RuledOut { background: #7c8a97; color: #fff; }
.status-group button.sel-Undetermined { background: var(--accent); color: #fff; }
.evidence-row { margin-top: 8px; }
.evidence-row textarea { font-size: 13px; }

/* ---------- actions ---------- */
.action-card {
  display: grid; grid-template-columns: 110px 1fr 170px 140px 120px auto;
  gap: 8px; align-items: start; border: 1px solid var(--line); border-radius: 7px;
  padding: 10px 12px; margin-bottom: 8px; background: #fbfcfd; font-size: 13.5px;
}
.action-card select, .action-card input, .action-card textarea { margin-top: 0; font-size: 13px; padding: 6px 8px; }
.action-card .linked { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
@media (max-width: 860px) { .action-card { grid-template-columns: 1fr 1fr; } .action-card textarea { grid-column: 1 / -1; } }

/* ---------- login overlay ---------- */
.login-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-deep) 100%);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: #fff; border-radius: 14px; padding: 30px 32px; width: min(400px, 92vw);
  box-shadow: 0 12px 50px rgba(0,0,0,.4); border-top: 4px solid var(--accent);
  text-align: left;
}
.login-logo {
  width: 52px; height: 52px; border-radius: 10px; background: #fff; padding: 2px;
  border: 1px solid var(--line); margin-bottom: 12px; display: block;
}
.login-brand { font-size: 18px; font-weight: 700; color: var(--navy); display: flex; align-items: center; gap: 8px; }
.login-sub { color: var(--muted); font-size: 13.5px; margin: 6px 0 18px; }
.login-card .btn { width: 100%; margin-top: 6px; padding: 10px; }
.login-error { color: var(--bad); font-size: 13px; min-height: 18px; margin: 2px 0 6px; }

#user-pill { background: #dfe9f5; color: var(--navy); }
.tag-src-mcp { background: #e0efe6; color: #1e6b43; }
.report .badge.b-src { text-transform: none; }

/* ---------- RCA diagram ---------- */
.diagram-panel, .report .diagram {
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  padding: 10px; overflow-x: auto; margin: 6px 0 10px;
}
.diagram-panel svg, .report .diagram svg { min-width: 700px; width: 100%; height: auto; display: block; }

/* ---------- QA ---------- */
.qa-item { margin-bottom: 12px; }
.qa-item .q { font-weight: 600; color: var(--navy); font-size: 14px; margin-bottom: 4px; }

/* ---------- fm library table ---------- */
.fm-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.fm-table th {
  background: linear-gradient(90deg, var(--navy-dark), var(--navy)); color: #fff;
  text-align: left; padding: 8px 10px; font-size: 13px;
  border-bottom: 2px solid var(--accent);
}
.fm-table td { border-top: 1px solid var(--line); padding: 8px 10px; font-size: 13px; vertical-align: top; }
.fm-table tr:nth-child(even) td { background: #f6f9fc; }
.fm-table tr:hover td { background: var(--accent-soft); }
.fm-table input, .fm-table textarea { font-size: 13px; padding: 5px 7px; margin: 0; }

/* ---------- dialog ---------- */
.dialog { border: none; border-radius: 12px; padding: 22px 24px; width: min(520px, 92vw); box-shadow: 0 8px 40px rgba(0,0,0,.3); border-top: 4px solid var(--accent); }
.dialog::backdrop { background: rgba(14, 44, 85, .5); }
.dialog menu { display: flex; justify-content: flex-end; gap: 10px; padding: 0; margin: 16px 0 0; }

/* ---------- report ---------- */
#report-preview { margin-top: 16px; }
.report { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 28px 34px; }
/* Company branding on the report */
.report .rpt-brand {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding-bottom: 14px; margin-bottom: 6px; border-bottom: 1px solid var(--line);
}
.report .rpt-brand .rpt-logo { max-height: 56px; max-width: 240px; width: auto; height: auto; }
.report .rpt-brand .rpt-company { font-size: 16px; font-weight: 700; color: var(--navy); }
.report .rpt-footer {
  margin-top: 26px; padding-top: 12px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 12.5px; text-align: center;
}
.report h1 { font-size: 22px; color: var(--navy); border-bottom: 3px solid var(--navy); padding-bottom: 8px; }
.report h2 { font-size: 16px; color: var(--navy); margin-top: 22px; }
.report h3 { font-size: 14px; margin: 12px 0 6px; color: var(--steel); }
.report table.meta { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13.5px; }
.report table.meta th { background: #eef3f9; text-align: left; padding: 6px 9px; border: 1px solid var(--line); width: 170px; color: var(--steel); }
.report table.meta td { border: 1px solid var(--line); padding: 6px 9px; }
.report table.actions { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.report table.actions th { background: var(--navy); color: #fff; padding: 7px 9px; text-align: left; border-bottom: 2px solid var(--accent); }
.report table.actions td { border: 1px solid var(--line); padding: 7px 9px; }
.report .cause { border: 1px solid var(--line); border-left: 4px solid #9aa7b4; border-radius: 6px; padding: 10px 13px; margin: 9px 0; font-size: 13.5px; }
.report .cause.confirmed { border-left-color: var(--ok); }
.report .cause p { margin: 5px 0; }
.report .badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #e7eef6; color: var(--steel); margin-left: 6px; }
.report .badge.b-Confirmed { background: #d9efe2; color: var(--ok); }
.report .badge.b-RuledOut { background: #e7e9eb; color: #66727e; }
.report .chain { font-size: 12.5px; color: var(--muted); margin: 5px 0; }
.report .note { font-size: 12.5px; color: var(--muted); font-style: italic; }
.report .qa { font-size: 13px; margin: 6px 0; }
.report ol.whys li { margin-bottom: 5px; }

/* ---------------------------------------------- rich-text editor + fields */
.rich-editor { border: 1px solid var(--line); border-radius: 8px; background: var(--card); overflow: hidden; }
.rich-editor:focus-within { border-color: var(--navy); box-shadow: 0 0 0 3px var(--focus-ring); }
.rich-toolbar { display: flex; gap: 2px; padding: 4px 6px; background: #eef3f9; border-bottom: 1px solid var(--line); }
.rich-btn { border: 1px solid transparent; background: transparent; border-radius: 6px; min-width: 30px; height: 26px; cursor: pointer; color: var(--text); font-size: 13.5px; line-height: 1; }
.rich-btn:hover { background: #fff; border-color: var(--line); }
.rich-area { min-height: 92px; padding: 10px 12px; font-size: 14px; line-height: 1.5; outline: none; }
.rich-area:empty::before { content: attr(data-placeholder); color: var(--muted); }
.rich-area ul, .rich-inline ul { margin: 4px 0; padding-left: 22px; }
.rich-area ol, .rich-inline ol { margin: 4px 0; padding-left: 22px; }
.rich-area li, .rich-inline li { list-style: disc; }
.rich-area p, .rich-inline p { margin: 4px 0; }
.rich-inline { display: inline-block; }
.rich-inline p:first-child { margin-top: 0; }
.rich-inline p:last-child { margin-bottom: 0; }
.rich-field { min-height: 92px; }

/* Operating-context tab: reusable template library controls */
.context-library { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.context-library .fld { display: flex; flex-direction: column; gap: 4px; min-width: 240px; font-size: 13px; color: var(--steel); }
.context-library .row-actions { margin: 0; }
#step-1 .rich-area { min-height: 220px; }

/* Manual rank up/down control on cause cards */
.rank-ctl { display: inline-flex; flex-direction: column; gap: 1px; margin-right: 2px; }
.rank-ctl button { border: 1px solid var(--line); background: var(--card); color: var(--steel); width: 22px; height: 15px; line-height: 1; font-size: 9px; cursor: pointer; border-radius: 4px; padding: 0; }
.rank-ctl button:first-child { border-radius: 4px 4px 0 0; }
.rank-ctl button:last-child { border-radius: 0 0 4px 4px; margin-top: -1px; }
.rank-ctl button:hover:not(:disabled) { background: #eef3f9; border-color: var(--navy); color: var(--navy); }
.rank-ctl button:disabled { opacity: .35; cursor: default; }

/* Cause add/edit modal (wider than the default dialog) */
.cause-dialog { width: min(640px, 94vw); }
.cause-dialog label { display: block; margin: 10px 0 3px; font-size: 13px; color: var(--steel); font-weight: 600; }
.cause-dialog input, .cause-dialog select { width: 100%; }
.cause-dialog .grid2 { gap: 0 16px; }
.cause-dialog menu { display: flex; justify-content: flex-end; gap: 8px; margin: 18px 0 0; padding: 0; }

/* MCP failure-mode multiselect modal */
.mcp-select { width: min(680px, 94vw); }
.mcp-select .mcp-all { display: block; font-weight: 600; margin: 4px 0 8px; }
.mcp-pick-list { max-height: 46vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.mcp-pick { display: grid; grid-template-columns: 22px 1fr; align-items: start; gap: 4px 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.mcp-pick:last-child { border-bottom: none; }
.mcp-pick:hover { background: #f4f8fc; }
.mcp-pick input { grid-row: 1 / span 2; margin-top: 2px; }
.mcp-fm { font-weight: 600; font-size: 13.5px; }
.mcp-eff { grid-column: 2; font-size: 12.5px; color: var(--muted); }
.mcp-pick.dup { opacity: .55; cursor: default; }
.mcp-select menu { display: flex; justify-content: flex-end; gap: 8px; margin: 16px 0 0; padding: 0; }

/* Rich content inside the generated report */
.report td.rich p, .report .rich p { margin: 4px 0; }
.report td.rich p:first-child, .report .rich p:first-child { margin-top: 0; }
.report td.rich p:last-child, .report .rich p:last-child { margin-bottom: 0; }
.report .rich ul, .report td.rich ul { margin: 4px 0; padding-left: 20px; }
.report .rich li, .report td.rich li { list-style: disc; }

/* ============ Rigor levels & case status summary (Phase 4) ============ */
.case-summary {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin: 6px 0 10px;
}
.sum-chip {
  font-size: 12.5px; padding: 3px 10px; border-radius: 999px;
  background: #eef1f4; color: #40505e; border: 1px solid #dde4ea;
}
.sum-chip b { font-weight: 800; }
.sum-chip.ok { background: #d9efe2; color: var(--ok); border-color: #bfe3cf; }
.sum-chip.warn { background: var(--warn-bg); color: #9a5b00; border-color: var(--warn-line); }
.sum-chip.sum-rigor {
  background: #e8eef8; color: #1e5aa8; border-color: #c9d9ef; font-weight: 700;
}
.sum-chip.sum-rigor.warn { background: var(--warn-bg); color: #9a5b00; border-color: var(--warn-line); }

.rigor-block {
  margin-top: 18px; padding: 14px 16px; border: 1px solid #dde4ea;
  border-radius: 10px; background: #fafbfc;
}
.rigor-block h3 { margin: 0 0 4px; font-size: 15px; }
.chk-line { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.chk-line input { width: auto; }
.rigor-reco { margin: 10px 0 6px; }
.reco-line { font-size: 14px; }
.reco-line.reco-warn { color: #9a5b00; }
.reco-rules { margin: 6px 0 0 18px; font-size: 13px; color: #57606a; }
.reco-rules em { color: #1e5aa8; font-style: normal; font-weight: 700; }

/* Progressive disclosure: Quick RCA hides the Questions deep-dive step */
body[data-rigor="quick"] #steps li[data-step="4"],
body[data-rigor="quick"] #step-4 { display: none; }

/* ============ Cause tree, 5-Whys view & timeline (Phase 5a) ============ */
.cause-view-toggle { display: flex; gap: 0; margin: 14px 0 8px; }
.cause-view-toggle .btn {
  border-radius: 0; border-right-width: 0;
}
.cause-view-toggle .btn:first-child { border-radius: 8px 0 0 8px; }
.cause-view-toggle .btn:last-child { border-radius: 0 8px 8px 0; border-right-width: 1px; }
.cause-view-toggle .btn.active {
  background: #1e5aa8; color: #fff; border-color: #1e5aa8; font-weight: 700;
}

.tree-root-label { margin: 6px 0 10px; font-size: 14px; color: #40505e; }
.tree-node { margin: 2px 0; }
.tree-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 6px 8px; border: 1px solid #e3e9ef; border-radius: 8px; background: #fff;
}
.tn-dismissed > .tree-row { opacity: .5; }
.tree-children {
  margin: 2px 0 2px 16px; padding-left: 14px; border-left: 2px solid #d7e0e8;
}
.tree-caret {
  border: none; background: none; cursor: pointer; font-size: 13px;
  width: 18px; color: #57606a; padding: 0;
}
.tree-caret-spacer { width: 18px; display: inline-block; }
.tree-desc { font-weight: 600; }
.tree-btns { margin-left: auto; display: flex; gap: 6px; }
.tn-badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: #eef1f4; color: #40505e; border: 1px solid #dde4ea; white-space: nowrap;
}
.tn-confirmed { background: #d9efe2; color: var(--ok); border-color: #bfe3cf; }
.tn-ruledout { background: #eceef0; color: #6c757d; text-decoration: line-through; }
.tn-open { background: var(--warn-bg); color: #9a5b00; border-color: var(--warn-line); }
.tn-factor { background: #e8eef8; color: #1e5aa8; border-color: #c9d9ef; }
.tn-level { background: #f3e9fb; color: #6b3fa0; border-color: #e2d1f2; }
.tn-rel { font-style: italic; }
.tn-evid { background: #d9efe2; color: var(--ok); border-color: #bfe3cf; }
.tn-noevid { background: var(--warn-bg); color: #9a5b00; border-color: var(--warn-line); }
.tn-unlinked { background: #fdeedd; color: #a05a12; border-color: #f0cf9b; }

.why-chain {
  margin: 10px 0; padding: 10px 14px; border: 1px solid #e3e9ef;
  border-radius: 10px; background: #fafbfc;
}
.why-step { padding: 4px 0 4px 16px; position: relative; }
.why-step::before {
  content: "↓"; position: absolute; left: 0; color: #9fb0bf;
}
.why-step.why-event::before { content: "●"; }
.why-step.why-event { font-weight: 700; }
.why-n {
  font-size: 11px; font-weight: 800; color: #1e5aa8; margin-right: 6px;
  text-transform: uppercase; letter-spacing: .4px;
}
.why-step.tn-confirmed { background: none; color: var(--ok); }
.why-step.tn-ruledout { background: none; color: #6c757d; text-decoration: line-through; }

.tl-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 6px 8px; margin: 4px 0; border: 1px solid #e3e9ef;
  border-radius: 8px; background: #fff;
}
.tl-move { display: flex; flex-direction: column; gap: 0; }
.tl-time { font-family: ui-monospace, monospace; font-size: 12.5px; color: #57606a; min-width: 128px; }
.tl-type { background: #e8eef8; color: #1e5aa8; border-color: #c9d9ef; }
.tl-title { font-weight: 600; }
.tl-move button {
  border: 1px solid var(--line); background: var(--card); color: var(--steel);
  width: 22px; height: 15px; line-height: 1; font-size: 9px; cursor: pointer;
  border-radius: 4px; padding: 0;
}
.tl-move button:disabled { opacity: .35; cursor: default; }

/* ============ Fishbone, barriers & change analysis (Phase 5b) ============ */
#fishbone-cols {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px; align-items: start;
}
.fb-col {
  border: 1px solid #e3e9ef; border-radius: 10px; background: #fafbfc;
  padding: 8px; min-height: 90px;
}
.fb-head {
  font-weight: 800; font-size: 13px; color: #1e5aa8; margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: .4px;
}
.fb-card {
  border: 1px solid #e3e9ef; border-radius: 8px; background: #fff;
  padding: 6px 8px; margin: 4px 0;
}
.fb-card.tn-ruledout { opacity: .55; }
.fb-desc { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.fb-meta { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.fb-move { font-size: 11px; max-width: 110px; padding: 1px 2px; }
.fb-add { display: flex; gap: 4px; margin-top: 6px; }
.fb-add input { flex: 1; font-size: 12.5px; padding: 4px 6px; }

.bn-bad { background: #fbe4e4; color: #a02020; border-color: #f0bcbc; }

/* Comprehensive-only sections (progressive disclosure by rigor level) */
.comp-only { display: none; }
body[data-rigor="comprehensive"] .comp-only { display: block; }

/* ============ Action effectiveness review (Phase 6a) ============ */
.eff-row {
  grid-column: 1 / -1; display: flex; gap: 8px; align-items: center;
  flex-wrap: wrap; padding-top: 6px; border-top: 1px dashed #dde4ea; margin-top: 4px;
}
.eff-row .muted { font-weight: 600; }
.eff-row .eff-evidence { flex: 1; min-width: 220px; }

/* ============ Novice-friendly UX polish ============ */
/* Explains the vanished Questions step instead of leaving users guessing. */
.steps-note {
  display: none; margin: -6px 0 14px; padding: 6px 12px; font-size: 13px;
  color: #7a5b16; background: var(--warn-bg);
  border: 1px solid var(--warn-line); border-radius: 8px;
}
body[data-rigor="quick"] .steps-note { display: block; }
/* Quick RCA keeps the simple Cards view — no tree/fishbone toggle. */
body[data-rigor="quick"] .cause-view-toggle { display: none; }

/* Idle autosave hint next to the "Saved" flash. */
.autosave-note { color: var(--muted); font-size: 12px; font-style: italic; }

/* Optional taxonomy block in the cause dialog (progressive disclosure). */
.cd-more {
  margin: 10px 0; padding: 6px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: #fafbfc;
}
.cd-more summary { cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--navy); }
.cd-more[open] summary { margin-bottom: 8px; }
.cd-more .hint { margin: 6px 0 2px; }

/* "— or —" divider between the two answers in the evidence-gate dialog. */
.dlg-or { text-align: center; color: var(--muted); font-size: 12.5px; margin: 4px 0; }

/* Case-template description in the new-case dialog. */
.tpl-hint {
  margin: -4px 0 10px; padding: 6px 10px; border-radius: 8px;
  background: var(--accent-soft); border: 1px solid var(--warn-line);
}

/* ============ Evidence attachments ============ */
.attach-row {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin-top: 6px;
}
.ev-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 8px; background: #fafbfc;
  padding: 3px 6px; max-width: 240px;
}
.ev-chip a { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--text); }
.ev-chip img { height: 34px; width: auto; max-width: 60px; object-fit: cover; border-radius: 5px; display: block; }
.ev-ic {
  display: inline-block; min-width: 34px; text-align: center; font-size: 10px;
  font-weight: 800; text-transform: uppercase; color: #fff; background: var(--steel);
  border-radius: 5px; padding: 9px 4px;
}
.ev-name { font-size: 12px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-del {
  border: none; background: none; color: var(--muted); cursor: pointer;
  font-size: 14px; padding: 0 2px; line-height: 1;
}
.ev-del:hover { color: var(--bad); }

/* attachment references inside the on-screen report */
.report .attach-note { font-size: 12px; color: var(--muted); }
.report .attach-img {
  max-width: 260px; max-height: 180px; display: block; margin: 4px 0 6px;
  border: 1px solid var(--line); border-radius: 6px;
}

/* ============ Cross-case action register ============ */
.pill-overdue { background: #fbe4e4; color: var(--bad); }
.areg-table tr[data-goto-case] { cursor: pointer; }
.areg-table tr[data-goto-case]:hover td { background: #f2f6fb; }
.areg-table tr.areg-overdue td:first-child { color: var(--bad); font-weight: 700; }
.areg-flag { color: var(--bad); font-size: 11px; text-transform: uppercase; }

/* ============ Asset history (repeat-event context) ============ */
.asset-history { margin-top: 18px; }
.ah-row {
  display: flex; gap: 12px; align-items: flex-start; cursor: pointer;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  padding: 8px 12px; margin-bottom: 6px;
}
.ah-row:hover { border-color: var(--navy); background: #f7fafd; }
.ah-date { flex: none; width: 88px; color: var(--muted); font-size: 13px; padding-top: 1px; }
.ah-main { flex: 1; font-size: 13.5px; }
.ah-flags { flex: none; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* ============ Review & approval (Phase 6b) ============ */
.review-block { margin-bottom: 16px; }
.rev-row {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  padding: 8px 12px; margin-bottom: 6px;
}
.rev-stage { font-weight: 700; color: var(--navy); min-width: 140px; }
.rev-row .btn { margin-left: auto; }

/* second (utility) model picker — visually subordinate */
.model-select-utility { max-width: 170px; opacity: .85; }
