/* ============================================================
   Demo — RFI Audit Explainer
   BPS-04 RFI diagnostic console inside the Asite CDE chrome.
   A real, read-only agent explains why a single RFI is stuck —
   who touched it, what changed, where it stalled — and lays out
   a permissioned, export-ready audit trail. Every claim is cited.
   Selectors prefixed `rae-`. Builds on main.css.
   ============================================================ */

.rae-app {
  position: relative;
  min-height: 520px;
  --rae: #0D9488;
  --rae-d: #0F766E;
  --rae-l: #E4F5F2;
}

/* ---- CDE shell ---- */
.rae-cde {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: #fff;
  box-shadow: var(--sh-1);
  overflow: hidden;
  font-size: 12.5px;
}

/* ---- dark top bar ---- */
.rae-top {
  display: flex; align-items: center; gap: 14px;
  height: 46px; padding: 0 14px; color: #fff;
  background: linear-gradient(90deg, #2a6db5, #15375f);
}
.rae-brand { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.rae-logo {
  width: 26px; height: 26px; border-radius: 6px; background: #fff;
  display: flex; align-items: center; justify-content: center;
}
.rae-brandtx { letter-spacing: .04em; font-size: 14px; }
.rae-topsearch {
  display: flex; align-items: center; gap: 8px;
  width: 220px; height: 28px; padding: 0 11px; border-radius: 6px;
  background: rgba(255,255,255,.92); color: var(--text-3); font-size: 12.5px;
}
.rae-proj { display: flex; align-items: center; gap: 6px; opacity: .96; }
.rae-proj strong { font-weight: 700; }
.rae-tools { margin-left: auto; display: flex; align-items: center; gap: 11px; }
.rae-ic { opacity: .9; display: inline-flex; }
.rae-ava {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 24px; height: 24px; border-radius: 50%; font-size: 9.5px; font-weight: 800;
  color: #fff; background: var(--rae-d);
}

/* ---- nav tabs ---- */
.rae-tabs {
  display: flex; align-items: center; gap: 2px; padding: 0 12px;
  border-bottom: 1px solid var(--line); background: #fff; overflow-x: auto;
}
.rae-tab {
  padding: 11px 12px; font-size: 12.5px; font-weight: 600; white-space: nowrap;
  color: var(--text-2); border-bottom: 2px solid transparent;
}
.rae-tab.active { color: var(--rae-d); border-bottom-color: var(--rae); font-weight: 700; }

/* ---- body ---- */
.rae-body { padding: 16px; background: #fafbfc; }

/* ---- head ---- */
.rae-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.rae-head-id { display: flex; align-items: center; gap: 11px; }
.rae-head-orb {
  width: 38px; height: 38px; flex: none; display: flex; align-items: center; justify-content: center;
  border-radius: 10px; color: #fff; background: linear-gradient(120deg, var(--rae), var(--rae-d));
  box-shadow: 0 6px 14px -6px rgba(0,0,0,.32);
}
.rae-head-name { font-size: 16px; font-weight: 800; color: var(--text); letter-spacing: -.01em; }
.rae-head-sub { font-size: 12px; color: var(--text-3); font-weight: 600; }
.rae-head .rae-btn { margin-left: auto; }

/* ---- buttons ---- */
/* tokens redeclared here too: the modal footer Close button lives in
   .modal-foot, outside .rae-app/.rae-doc, so var(--rae*) must resolve locally */
.rae-btn {
  --rae: #0D9488; --rae-d: #0F766E; --rae-l: #E4F5F2;
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px;
  border-radius: 7px; font-size: 12.5px; font-weight: 600; cursor: pointer; border: 1px solid transparent;
  transition: filter .14s ease, background .14s ease, transform .12s ease;
}
.rae-btn.ghost { background: #fff; border-color: var(--line-strong); color: var(--text-2); }
.rae-btn.ghost:hover { border-color: var(--rae); color: var(--rae-d); }
.rae-btn.primary {
  background: linear-gradient(120deg, var(--rae), var(--rae-d)); color: #fff;
  box-shadow: 0 6px 14px -6px rgba(0,0,0,.32);
}
.rae-btn.primary:hover { filter: brightness(1.07); }
.rae-btn.primary:active { transform: translateY(1px); }
.rae-btn:disabled { opacity: .5; cursor: default; filter: none; box-shadow: none; }

/* ---- idle state ---- */
.rae-idle {
  border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; box-shadow: var(--sh-1);
  padding: 34px 28px 30px; text-align: center;
}
.rae-idle-t { font-size: 18px; font-weight: 800; color: var(--text); margin: 0 0 8px; letter-spacing: -.01em; }
.rae-idle-p { font-size: 13px; line-height: 1.6; color: var(--text-2); margin: 0 auto 22px; max-width: 60ch; }

/* RFI picker */
.rae-picks {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  margin: 0 auto 22px; max-width: 720px; text-align: left;
}
.rae-pick {
  display: flex; flex-direction: column; gap: 7px; padding: 13px 14px; cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: 11px; background: #fff;
  transition: border-color .14s ease, box-shadow .14s ease, transform .12s ease;
}
.rae-pick:hover { border-color: var(--rae); transform: translateY(-1px); box-shadow: var(--sh-1); }
.rae-pick.selected { border-color: var(--rae); box-shadow: 0 0 0 2px var(--rae-l); background: #fbfefe; }
.rae-pick-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rae-pick-id { font-size: 12.5px; font-weight: 800; letter-spacing: .03em; font-variant-numeric: tabular-nums; color: var(--rae-d); }
.rae-pick-title { font-size: 13px; font-weight: 700; color: var(--text); line-height: 1.35; }
.rae-pick-meta { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-3); font-weight: 600; flex-wrap: wrap; }
.rae-pick-meta .ico { opacity: .8; }
.rae-pick-disc { padding-left: 6px; margin-left: 2px; border-left: 1px solid var(--line-strong); }

.rae-gen {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 18px; border: none;
  border-radius: 9px; background: linear-gradient(120deg, var(--rae), var(--rae-d)); color: #fff;
  font-size: 13.5px; font-weight: 700; cursor: pointer;
  box-shadow: 0 8px 18px -10px rgba(0,0,0,.45); transition: filter .14s ease, transform .12s ease;
}
.rae-gen:hover { filter: brightness(1.07); }
.rae-gen:active { transform: translateY(1px); }
.rae-idle-hint {
  display: flex; align-items: flex-start; justify-content: center; gap: 7px; margin: 14px auto 0;
  font-size: 11.5px; line-height: 1.5; color: var(--text-3); max-width: 56ch;
}
.rae-idle-hint .ico { color: var(--rae); flex: none; margin-top: 1px; }

/* ---- loading ---- */
.rae-loading {
  border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; box-shadow: var(--sh-1);
  padding: 22px 20px;
}
.rae-loading-t { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 16px; }
.rae-cklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 13px; }
.rae-ck { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-3); }
.rae-ck.active { color: var(--text); font-weight: 600; }
.rae-ck.done { color: var(--text-2); }
.rae-ck-mark { display: inline-flex; }
.rae-ck-mark.ok { color: var(--ok); }
.rae-dot { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--line-strong); display: inline-block; }
.rae-spin {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(0,0,0,.14); border-top-color: var(--rae);
  display: inline-block; animation: rae-spin .65s linear infinite;
}
.rae-spin.sm { width: 13px; height: 13px; }
@keyframes rae-spin { to { transform: rotate(360deg); } }

/* ---- report ---- */
.rae-report { display: flex; flex-direction: column; gap: 14px; animation: rae-fade .4s ease; }
@keyframes rae-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- state chip (RAG) ---- */
.rae-chip {
  font-size: 10.5px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.rae-chip.lg { font-size: 11.5px; padding: 4px 12px; }
.rae-chip-err { background: var(--err-bg, #FBEAEE); color: var(--err); }
.rae-chip-warn { background: var(--warn-bg); color: var(--warn); }
.rae-chip-ok { background: var(--ok-bg); color: var(--ok); }

/* ---- verdict card ---- */
.rae-verdict {
  border: 1px solid var(--line); border-left-width: 4px; border-radius: var(--r-sm);
  background: #fff; box-shadow: var(--sh-1); padding: 16px 18px;
}
.rae-verdict-err { border-left-color: var(--err); }
.rae-verdict-warn { border-left-color: var(--warn); }
.rae-verdict-ok { border-left-color: var(--ok); }
.rae-verdict-rfi { font-size: 12.5px; font-weight: 800; color: var(--text-2); letter-spacing: .01em; }
.rae-verdict-badges { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 9px 0 11px; }
.rae-verdict-age { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; color: var(--err); }
.rae-verdict-warn .rae-verdict-age { color: var(--warn); }
.rae-verdict-ok .rae-verdict-age { color: var(--ok); }
.rae-verdict-age .ico { opacity: .85; }
.rae-verdict-disc { font-size: 11.5px; font-weight: 600; color: var(--text-3); padding-left: 10px; border-left: 1px solid var(--line-strong); }
.rae-verdict-head { margin: 0; font-size: 15px; line-height: 1.5; font-weight: 700; color: var(--text); letter-spacing: -.01em; }

/* ---- generic section ---- */
.rae-sec { border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; box-shadow: var(--sh-1); overflow: hidden; }
.rae-sec-head { display: flex; align-items: center; gap: 9px; padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--bg-sunken); }
.rae-sec-ic { display: inline-flex; width: 26px; height: 26px; align-items: center; justify-content: center; border-radius: 7px; color: var(--rae-d); background: var(--rae-l); }
.rae-sec-ic-why { color: var(--err); background: var(--err-bg, #FBEAEE); }
.rae-sec-title { margin: 0; font-size: 13.5px; font-weight: 700; color: var(--text); }
.rae-sec-count { font-size: 11px; font-weight: 700; color: var(--text-3); padding: 1px 8px; border-radius: 999px; background: #eef2f7; }
.rae-sec-note { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; color: var(--text-3); }
.rae-sec-note .ico { opacity: .8; }

/* ---- why it's stuck ---- */
.rae-whylist { list-style: none; margin: 0; padding: 0; }
.rae-why { display: flex; gap: 11px; padding: 13px 14px; border-bottom: 1px solid var(--line-soft); }
.rae-why:last-child { border-bottom: none; }
.rae-why-ic { flex: none; margin-top: 1px; color: var(--err); display: inline-flex; }
.rae-why-main { flex: 1; min-width: 0; }
.rae-why-point { font-size: 13px; font-weight: 700; color: var(--text); }
.rae-why-detail { margin: 4px 0 0; font-size: 12.5px; line-height: 1.55; color: var(--text-2); }
.rae-why-cite { margin-top: 7px; }

/* ---- citation chip ---- */
.rae-cite {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700;
  font-variant-numeric: tabular-nums; color: var(--rae-d); background: var(--rae-l);
  padding: 2px 8px 2px 6px; border-radius: 6px;
}
.rae-cite .ico { opacity: .8; }
.rae-cite-link {
  border: 0; cursor: pointer; font-family: inherit; line-height: 1.4;
  transition: background .12s ease, color .12s ease, box-shadow .12s ease;
}
.rae-cite-link:hover { background: var(--rae-d); color: #fff; }
.rae-cite-link:hover .ico { opacity: 1; }
.rae-cite-link:focus-visible { outline: 2px solid var(--rae); outline-offset: 2px; }

/* ---- audit timeline ---- */
.rae-tllist { list-style: none; margin: 0; padding: 14px 16px 14px 14px; position: relative; }
.rae-tl { position: relative; display: flex; gap: 12px; padding: 0 0 16px 6px; }
.rae-tl:last-child { padding-bottom: 0; }
/* vertical rail */
.rae-tl::before {
  content: ''; position: absolute; left: 16px; top: 20px; bottom: -4px; width: 2px; background: var(--line-strong);
}
.rae-tl:last-child::before { display: none; }
.rae-tl-mark {
  position: relative; z-index: 1; flex: none; width: 22px; height: 22px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; color: #fff;
  box-shadow: 0 0 0 3px #fff;
}
.rae-tl-raised { background: var(--rae); }
.rae-tl-reassign { background: #7C3AED; }
.rae-tl-respond { background: #2563EB; }
.rae-tl-reopen { background: var(--warn); }
.rae-tl-overdue { background: var(--err); }
.rae-tl-chase { background: #0EA5E9; }
.rae-tl-note { background: var(--text-3); }
.rae-tl-blocked { background: #B45309; }
.rae-tl-open { background: var(--text-2); }
.rae-tl-main { flex: 1; min-width: 0; padding-top: 1px; }
.rae-tl-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rae-tl-actor { font-size: 13px; font-weight: 700; color: var(--text); }
.rae-tl-role {
  font-size: 10px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase;
  color: var(--rae-d); background: var(--rae-l); padding: 1px 7px; border-radius: 999px;
}
.rae-tl-when { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rae-tl-action { margin: 3px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--text-2); }

/* ---- who touched it ---- */
.rae-conlist { list-style: none; margin: 0; padding: 0; }
.rae-con { display: flex; align-items: center; gap: 11px; padding: 11px 14px; border-bottom: 1px solid var(--line-soft); }
.rae-con:last-child { border-bottom: none; }
.rae-con.flagged { background: #FEFAF0; }
.rae-con-ava {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: #fff; background: linear-gradient(120deg, var(--rae), var(--rae-d));
}
.rae-con-main { flex: 1; min-width: 0; }
.rae-con-name { font-size: 13px; font-weight: 700; color: var(--text); }
.rae-con-role { font-size: 11.5px; color: var(--text-3); font-weight: 600; }
.rae-con-flag {
  display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 800;
  color: var(--warn); background: var(--warn-bg); padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.rae-con-flag .ico { opacity: .9; }
.rae-con-touch {
  flex: none; font-size: 11px; font-weight: 700; color: var(--text-2);
  background: #eef2f7; padding: 3px 10px; border-radius: 999px; font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* ---- export bar ---- */
.rae-export {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; box-shadow: var(--sh-1);
  padding: 13px 16px;
}
.rae-export-tx { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 220px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.rae-export-ic { display: inline-flex; color: var(--rae-d); flex: none; }
.rae-export-actions { display: flex; align-items: center; gap: 9px; margin-left: auto; }

/* ---- sample source-record document (shown in modal) ---- */
/* modal renders on <body>, outside .rae-app — redeclare brand tokens */
.rae-doc {
  --rae: #0D9488; --rae-d: #0F766E; --rae-l: #E4F5F2;
  position: relative; overflow: hidden; border-radius: 10px; background: #fff;
}
.rae-doc-inner { position: relative; z-index: 1; }
.rae-doc-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.rae-doc-kind {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--rae-d);
}
.rae-doc-kind .ico { opacity: .85; }
.rae-doc-status { font-size: 11px; font-weight: 800; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.rae-doc-ok { background: var(--ok-bg); color: var(--ok); }
.rae-doc-open { background: var(--rae-l); color: var(--rae-d); }
.rae-doc-warn { background: var(--warn-bg); color: var(--warn); }
.rae-doc-overdue { background: var(--err-bg, #FBEAEE); color: var(--err); }
.rae-doc-id {
  font-size: 12px; font-weight: 800; letter-spacing: .04em;
  font-variant-numeric: tabular-nums; color: var(--text-2);
}
.rae-doc-title { margin: 2px 0 14px; font-size: 18px; font-weight: 800; color: var(--text); }
.rae-doc-meta {
  display: grid; grid-template-columns: 1fr 1fr; gap: 9px 22px;
  padding: 12px 14px; margin-bottom: 14px;
  background: #F5FAF9; border: 1px solid var(--line); border-radius: 10px;
}
.rae-doc-field { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rae-doc-k { font-size: 10.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }
.rae-doc-v { font-size: 13px; font-weight: 600; color: var(--text); }
.rae-doc-summary { margin: 0 0 14px; font-size: 13.5px; line-height: 1.6; color: var(--text); }
.rae-doc-foot { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-3); border-top: 1px dashed var(--line); padding-top: 10px; }
.rae-doc-foot .ico { opacity: .8; }

/* diagonal SAMPLE watermark tiled across the record */
.rae-doc-wm {
  position: absolute; inset: -40% -10%; z-index: 0; pointer-events: none;
  display: flex; flex-wrap: wrap; align-content: center; justify-content: center;
  gap: 26px 40px; transform: rotate(-24deg); opacity: .08;
}
.rae-doc-wm span { font-size: 30px; font-weight: 900; letter-spacing: .14em; color: var(--rae-d); white-space: nowrap; user-select: none; }

/* ---- responsive ---- */
@media (max-width: 720px) {
  .rae-topsearch { display: none; }
  .rae-picks { grid-template-columns: 1fr; }
  .rae-export-actions { margin-left: 0; flex-wrap: wrap; }
  .rae-verdict-disc { padding-left: 0; border-left: none; }
  .rae-doc-meta { grid-template-columns: 1fr; }
}
