/* ===========================================================================
   Source-of-Funds Tracer demo — visual language inherited from an earlier Miruvor product
   sketch, so the studio's demos read as the same hand:
   Geist sans throughout, desaturated blue accent, warm-gray ground,
   rounded cards, a 3px accent rule on the header. Net-new tokens (--ok/--warn/
   --alert for the trace states, --hl for the document link) are desaturated
   from the same family. No serif, no bright color, no gradient, no AI sparkle.
=========================================================================== */

:root {
  /* --- inherited from the earlier Miruvor demo --- */
  --bg: #f7f7f5;
  --fg: #1c1c1a;
  --muted: #6b6b66;
  --line: #e2e1dc;
  --user: #1c1c1a;
  --user-fg: #f7f7f5;
  --accent: #2a5d8a;
  --accent-soft: #eef2f6;
  --accent-deep: #234e74;
  --error: #8a2a2a;
  --sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  --display: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  --col: 860px;        /* prose column */
  --col-wide: 1160px;  /* the interactive card needs room for diagram + panes */
  --gutter: 24px;

  /* --- machine-produced surfaces (--accent family, from the earlier demo) --- */
  --machine-tint: #f0f3f6;
  --machine-rule: #c4d2dd;

  /* --- trace states (net-new, desaturated, matching the conf-band hues) --- */
  --ok: #3f6b4a;        /* verified — documented hop */
  --ok-bg: #eef3ef;
  --warn: #8a6d2f;      /* justified gap */
  --warn-bg: #f5f1e8;
  --alert: #8a2a2a;     /* frontier — unexplained source (= --error) */
  --alert-bg: #f8efef;
  --stated: #9a9a94;    /* stated, not yet evidenced */

  --hl: var(--accent-soft);   /* document highlight / cross-link selection */
}

* { box-sizing: border-box; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

body {
  margin: 0;
  font: 16px/1.55 var(--sans);
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------------- header: 3px accent rule, white ground (house pattern) ------ */

.site-head {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 22px max(var(--gutter), (100% - var(--col-wide)) / 2) 18px;
  border-top: 3px solid var(--accent);
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.head-left { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.wordmark { font-family: var(--display); font-weight: 600; letter-spacing: -0.3px; }
.site-head .wordmark { font-size: 22px; }
.head-sub { color: var(--muted); font-size: 14px; }
.head-actions { display: flex; gap: 8px; flex-shrink: 0; }

.hbtn {
  padding: 7px 14px; border-radius: 8px;
  font-family: var(--sans); font-size: 13px; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.hbtn-ghost { border: 1px solid var(--line); background: #fff; color: var(--fg); }
.hbtn-ghost:hover { background: var(--bg); border-color: #cfcec8; }
.hbtn-primary { border: 1px solid transparent; background: var(--user); color: var(--user-fg); }
.hbtn-primary:hover { background: #000; }

footer.brand {
  padding: 14px max(var(--gutter), (100% - var(--col)) / 2);
  border-top: 1px solid var(--line); background: #fff;
  color: var(--muted); font-size: 12px; letter-spacing: 0.2px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
footer.brand .wordmark { color: var(--fg); }

/* ---------------- intro / framing ---------------- */

main { padding: 0 max(var(--gutter), (100% - var(--col-wide)) / 2) 56px; margin: 0 auto; }

.intro, .tradeoffs { max-width: var(--col); margin-left: auto; margin-right: auto; }
.intro { margin-top: 28px; }
.frame { margin: 0; font-size: 17px; line-height: 1.6; color: var(--fg); }
.intro .frame + .frame { margin-top: 14px; }
.machine-note {
  margin: 16px 0 0; padding: 8px 12px;
  background: var(--machine-tint); border-left: 2px solid var(--machine-rule);
  border-radius: 0 6px 6px 0; color: var(--muted); font-size: 12.5px; line-height: 1.5;
}

/* ---------------- the interactive card ---------------- */

.demo-card {
  max-width: var(--col-wide); margin: 28px auto 0; padding: 24px 26px 22px;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
}
.case-head h2 {
  margin: 0; font-family: var(--display); font-size: 18px; font-weight: 600;
  letter-spacing: -0.1px;
}
.case-head .meta { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

/* stepper: status, not control (house pattern — circles + connector lines) */
.stepper { margin: 22px 0 6px; }
.stepper ol {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  list-style: none; margin: 0; padding: 0;
}
.stepper li {
  display: flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 13px; letter-spacing: 0.2px;
}
.stepper li::after {
  content: ""; width: 26px; height: 1px; background: var(--line); margin-left: 4px;
}
.stepper li:last-child::after { display: none; }
.stepper .num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid var(--line); font-size: 12px; font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.stepper li[aria-current="step"] { color: var(--fg); font-weight: 500; }
.stepper li[aria-current="step"] .num { background: var(--fg); color: var(--user-fg); border-color: var(--fg); }
.stepper li.done { color: var(--accent); }
.stepper li.done .num { border-color: var(--accent); color: var(--accent); }

.panel { padding: 22px 0 6px; }

/* ---------------- step 1: lawyer's input ---------------- */

.input-card { max-width: 700px; margin: 6px auto; }
.input-card h3 { font-family: var(--display); font-size: 17px; font-weight: 600; margin: 0 0 6px; }
.input-lede { color: var(--muted); margin: 0 0 20px; font-size: 14.5px; }
.input-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.input-grid label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 11px; color: var(--muted); letter-spacing: 0.4px; text-transform: uppercase;
  font-weight: 600;
}
.input-grid label.wide { grid-column: 1 / -1; }
.input-grid input, .input-grid textarea {
  font-family: var(--sans); font-size: 14.5px; color: var(--fg); font-weight: 400;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 12px; letter-spacing: normal; text-transform: none;
}
.input-grid textarea { resize: none; line-height: 1.5; }
.input-grid input:focus, .input-grid textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
#in-amount { font-weight: 600; font-size: 16px; font-variant-numeric: tabular-nums; }
.input-note {
  margin: 20px 0 0; padding: 8px 12px; font-size: 12.5px; color: var(--muted);
  background: var(--machine-tint); border-left: 2px solid var(--machine-rule); border-radius: 0 6px 6px 0;
}

/* ---------------- step 2: workspace ---------------- */

.workspace { display: grid; grid-template-columns: 300px 1fr; gap: 26px; }

.aside-h, .pane-h {
  font-size: 11px; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase;
  color: var(--muted); margin: 0 0 12px;
}

.filelist { list-style: none; margin: 0 0 14px; padding: 0; }
.filelist li {
  font-size: 12.5px; color: var(--fg);
  padding: 7px 10px; margin-bottom: 6px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  display: flex; align-items: center; gap: 8px;
}
.filelist li .fcheck { color: var(--ok); font-weight: 600; }
.filelist li.justified .fcheck { color: var(--warn); }
.filelist li .fname { font-variant-numeric: tabular-nums; }

.action-btn {
  width: 100%; min-height: 44px;
  font-family: var(--sans); font-size: 14px; font-weight: 500;
  background: var(--user); color: var(--user-fg);
  border: 1px solid var(--user); border-radius: 10px;
  padding: 11px 14px; cursor: pointer; line-height: 1.4;
  transition: background 0.12s ease;
}
.action-btn:hover { background: #000; }
.action-btn[disabled] { opacity: 0.55; cursor: progress; }
.action-btn.is-done {
  background: var(--ok-bg); color: var(--ok); border-color: var(--ok); cursor: default;
}

/* drag-and-drop zone — the upload surface */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  border: 1.5px dashed var(--machine-rule); border-radius: 10px;
  background: var(--machine-tint); color: var(--muted);
  padding: 22px 16px; text-align: center; cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); border-color: var(--accent); }
.dropzone.is-dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.is-busy { cursor: progress; border-style: solid; }
.dropzone .dz-icon { color: var(--accent); margin-bottom: 2px; }
.dropzone .dz-title { font-size: 13.5px; font-weight: 500; color: var(--fg); }
.dropzone .dz-sub { font-size: 12px; color: var(--muted); }

.files-h {
  font-size: 11px; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase;
  color: var(--muted); margin: 16px 0 8px;
}

.skiplink {
  display: block; width: 100%; text-align: center;
  background: none; border: none; cursor: pointer;
  font-family: var(--sans); font-size: 12.5px; color: var(--accent);
  margin: 10px 0 0; padding: 6px 0; min-height: 32px;
  text-decoration: underline; text-underline-offset: 2px;
}
.skiplink:hover { color: var(--accent-deep); }

.chips-h {
  font-size: 11px; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase;
  color: var(--muted); margin: 22px 0 8px;
}
.chips { display: flex; flex-direction: column; gap: 6px; }
.chip {
  font-size: 11.5px; line-height: 1.5; font-variant-numeric: tabular-nums;
  padding: 7px 10px; border-radius: 7px;
  border: 1px solid var(--line); border-left: 3px solid var(--machine-rule);
  background: var(--machine-tint); color: var(--fg);
  animation: chipIn 340ms ease both;
}
.chip.check { border-color: var(--ok); border-left-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.chip.warn { border-color: var(--warn); border-left-color: var(--warn); background: var(--warn-bg); color: var(--warn); }
@keyframes chipIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.trace-head h3 { font-family: var(--display); font-size: 16px; font-weight: 600; margin: 0 0 12px; }

.svg-wrap { border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 6px; }
.svg-wrap svg { width: 100%; height: auto; display: block; }

.frontier {
  font-size: 13px; color: var(--alert);
  background: var(--alert-bg); border: 1px solid var(--alert); border-left-width: 3px;
  border-radius: 8px; padding: 9px 13px; margin-top: 14px;
}
.frontier:empty { display: none; }
.frontier::before { content: "◌ "; font-weight: 700; }

.banner {
  font-size: 13.5px; font-weight: 500; color: var(--ok);
  background: var(--ok-bg); border: 1px solid var(--ok); border-left-width: 3px;
  border-radius: 8px; padding: 11px 14px; margin-top: 14px;
}

.narration { color: var(--muted); font-size: 14.5px; margin: 16px 2px 0; line-height: 1.55; }

/* diagram interactivity */
.edge-hit { cursor: pointer; }
.edge-group.lit path.edge-line { stroke-width: 3.4; }
.edge-group.lit text { font-weight: 600; }
.node-group { cursor: default; }
@keyframes pulseDash { to { stroke-dashoffset: -14; } }
.edge-group.is-frontier path.edge-line { animation: pulseDash 1.2s linear infinite; }

/* ---------------- step 3: the output ---------------- */

.out-actions { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.out-lede { max-width: 640px; color: var(--muted); margin: 0; font-size: 14.5px; line-height: 1.55; }
.out-btns { display: flex; gap: 10px; flex-shrink: 0; }

.out-grid { display: grid; grid-template-columns: minmax(380px, 440px) 1fr; gap: 28px; }

.memo {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 26px 28px; align-self: start; position: sticky; top: 18px;
}
.memo h3 { font-family: var(--display); font-size: 18px; font-weight: 600; margin: 0 0 2px; }
.memo .memo-sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.memo p { margin: 0 0 14px; font-size: 14.5px; line-height: 1.7; }
.memo .seg[data-edges] {
  cursor: pointer; border-bottom: 1px dashed var(--machine-rule);
  transition: background-color 160ms ease;
}
.memo .seg[data-edges]:hover { background: var(--hl); }
.memo .seg.lit { background: var(--hl); border-bottom-color: var(--accent); }
.memo .exhibits-h {
  font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: 0.4px;
  text-transform: uppercase; margin: 22px 0 8px; padding-top: 16px; border-top: 1px solid var(--line);
}
.memo ul.exhibit-list { list-style: none; margin: 0; padding: 0; }
.memo ul.exhibit-list li { font-size: 13px; color: var(--muted); padding: 3px 0; }
.memo ul.exhibit-list li b { color: var(--fg); font-weight: 600; }

.out-right { min-width: 0; }
.out-diagram { margin-bottom: 24px; }

.docs { display: flex; flex-direction: column; gap: 20px; }

/* the fabricated statements: white paper, sans chrome, tabular figures */
.doc { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.doc-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 13px 18px 10px; border-bottom: 2px solid var(--fg);
}
.doc-bank { font-weight: 600; font-size: 14px; letter-spacing: -0.1px; }
.doc-exh {
  font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums;
  border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px;
}
.doc-title { padding: 10px 18px 0; font-size: 12.5px; font-weight: 600; }
.doc-meta { padding: 2px 18px 10px; font-size: 11.5px; color: var(--muted); }
.doc table { width: 100%; border-collapse: collapse; font-size: 12px; background: #fff; }
.doc th {
  text-align: left; font-weight: 600; color: var(--muted);
  padding: 6px 10px; border-top: 1px solid var(--line); border-bottom: 1.5px solid #d6d5cf;
  font-size: 10.5px; letter-spacing: 0.3px; text-transform: uppercase;
}
.doc td {
  padding: 6px 10px; border-bottom: 1px solid var(--line);
  font-size: 11.5px; vertical-align: top; font-variant-numeric: tabular-nums;
}
.doc td:nth-child(n + 3), .doc th:nth-child(n + 3) { text-align: right; white-space: nowrap; }
.doc tr.is-hl td { background: var(--hl); cursor: pointer; }
.doc tr.is-hl td:first-child { border-left: 3px solid var(--accent); }
.doc tr.is-hl.flash td { animation: flashRow 1.1s ease 2; }
@keyframes flashRow { 0%, 100% { background: var(--hl); } 45% { background: #dbe6f1; } }
.doc-foot { padding: 8px 18px 12px; font-size: 10.5px; color: var(--muted); }

/* ---------------- controls (house pattern) ---------------- */

.controls { display: flex; justify-content: space-between; gap: 12px; margin-top: 24px; }
.controls button {
  min-height: 44px; padding: 12px 22px; border-radius: 10px;
  font-family: var(--sans); font-size: 15px; font-weight: 500; cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
}
.controls .ghost { border: 1px solid var(--line); background: #fff; color: var(--fg); }
.controls .ghost:hover { background: var(--bg); border-color: #cfcec8; }
.controls .ghost[disabled] { opacity: 0.4; cursor: default; }
.controls .ghost[disabled]:hover { background: #fff; border-color: var(--line); }
.controls .primary { border: 1px solid var(--user); background: var(--user); color: var(--user-fg); margin-left: auto; }
.controls .primary:hover { background: #000; }
.controls .primary[disabled] { opacity: 0.45; cursor: default; }

:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------------- the long-game section ---------------- */

.tradeoffs { margin-top: 52px; }
.tradeoffs h2 { font-family: var(--display); font-size: 18px; font-weight: 600; letter-spacing: -0.1px; margin: 0 0 12px; }
.tradeoffs p { margin: 0 0 14px; line-height: 1.7; color: var(--fg); }
.tradeoffs ul { margin: 0 0 14px; padding-left: 22px; }
.tradeoffs li { margin: 0 0 9px; line-height: 1.6; }

/* ---------------- login ---------------- */

body.centered { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-wrap {
  width: 360px; background: #fff; border: 1px solid var(--line); border-radius: 14px;
  border-top: 3px solid var(--accent); padding: 32px 32px 28px;
}
.login-mark { font-family: var(--display); font-size: 24px; font-weight: 600; letter-spacing: -0.3px; margin: 0 0 4px; }
.login-wrap p { color: var(--muted); font-size: 14.5px; margin: 0 0 20px; }
.login-wrap label {
  display: block; font-size: 11px; color: var(--muted); letter-spacing: 0.4px;
  text-transform: uppercase; font-weight: 600; margin: 14px 0 5px;
}
.login-wrap input {
  width: 100%; font-family: var(--sans); font-size: 15px;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--fg);
}
.login-wrap input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-wrap button {
  width: 100%; margin-top: 20px; min-height: 44px;
  font-family: var(--sans); font-size: 15px; font-weight: 500;
  background: var(--user); color: var(--user-fg); border: 1px solid var(--user);
  border-radius: 10px; padding: 11px; cursor: pointer;
}
.login-wrap button:hover { background: #000; }
.login-wrap button[disabled] { opacity: 0.6; }
.login-error { color: var(--error); font-size: 13px; margin-top: 12px; min-height: 18px; }

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

@media (max-width: 1080px) {
  .workspace { grid-template-columns: 1fr; }
  .out-grid { grid-template-columns: 1fr; }
  .memo { position: static; }
}
@media (max-width: 640px) {
  :root { --gutter: 16px; }
  .site-head { flex-direction: column; align-items: stretch; gap: 12px; padding: 18px var(--gutter) 14px; }
  .head-actions > * { flex: 1; }
  .demo-card { padding: 16px; }
  .input-grid { grid-template-columns: 1fr; }
  .stepper .lbl { display: none; }
  .stepper li::after { width: 16px; }
  .controls button { flex: 1; }
  .out-actions { flex-direction: column; align-items: stretch; }
}

/* respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------------- print: narrative + exhibit diagram ---------------- */

@media print {
  body { background: #fff; font-size: 11pt; }
  .site-head, .intro, .stepper, .controls, .tradeoffs, footer.brand,
  .out-actions, .docs-pane, #panel-1, #panel-2 { display: none !important; }
  .demo-card { border: none; padding: 0; max-width: none; }
  #panel-3 { display: block !important; }
  .out-grid { display: block; }
  .memo { position: static; border: none; border-radius: 0; padding: 0 0 24px; }
  .out-diagram .svg-wrap { border: none; padding: 0; }
  .case-head h2 { font-size: 15pt; }
}
