/* Mortgage rate anatomy — isolated prototype styles. Every rule is scoped
   under .ra so nothing leaks into the main dashboard. */

.ra {
  --ra-bg: #0a0a0a;
  --ra-bg-2: #141416;
  --ra-panel: rgba(28, 28, 30, 0.72);
  --ra-border: rgba(255, 255, 255, 0.1);
  --ra-border-strong: rgba(255, 255, 255, 0.18);
  --ra-text: #ebebf5;
  --ra-muted: rgba(235, 235, 245, 0.62);
  --ra-faint: rgba(235, 235, 245, 0.32);
  --ra-accent: #0a84ff;
  --ra-accent-soft: rgba(10, 132, 255, 0.22);
  --ra-tsy: #4f8ff7;
  --ra-swap: #52c7c0;
  --ra-basis: #f2b64b;
  --ra-pss: #ff7a6b;
  --ra-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --ra-mono: "JetBrains Mono", "SF Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --ra-ease: cubic-bezier(0.2, 0.8, 0.2, 1);

  margin: 0;
  height: 100dvh;
  overflow: auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: radial-gradient(1200px 800px at 15% -10%, #1c1c1e 0%, var(--ra-bg) 60%);
  color: var(--ra-text);
  font-family: var(--ra-ui);
  font-size: 13px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

.ra *,
.ra *::before,
.ra *::after {
  box-sizing: border-box;
}

.ra ::selection {
  background: var(--ra-accent-soft);
  color: #fff;
}

.ra :focus-visible {
  outline: 2px solid var(--ra-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.ra a {
  color: inherit;
  text-decoration: none;
}

.ra-vh {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- header ---------- */
.ra-top {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "brand status" "title status";
  column-gap: 24px;
  align-items: end;
  padding: 14px 20px 10px;
  border-bottom: 1px solid var(--ra-border);
}
.ra-brand {
  grid-area: brand;
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 12px;
  color: var(--ra-muted);
}
.ra-brand a {
  font-weight: 600;
  color: #fff;
  font-size: 14px;
}
.ra-title {
  grid-area: title;
  margin: 2px 0 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.ra-status {
  grid-area: status;
  margin: 0;
  justify-self: end;
  text-align: right;
  max-width: 62ch;
  color: var(--ra-muted);
  font-size: 12px;
}
.ra-status b {
  color: var(--ra-text);
  font-weight: 500;
}

/* ---------- layout ---------- */
.ra-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 372px;
  min-height: 0;
}
.ra-stagewrap {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  grid-auto-rows: auto;
  min-height: 0;
  min-width: 0;
  padding: 10px 16px 12px 20px;
  gap: 8px;
}
.ra-panel {
  min-height: 0;
  overflow: auto;
  border-left: 1px solid var(--ra-border);
  background: var(--ra-panel);
  padding: 16px 18px 24px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}
.ra-panel::-webkit-scrollbar {
  width: 8px;
}
.ra-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 8px;
}

/* ---------- toolbar ---------- */
.ra-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}
.ra-seg {
  display: inline-flex;
  margin: 0;
  padding: 2px;
  border: 1px solid var(--ra-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}
.ra-seg label {
  position: relative;
  display: inline-flex;
}
.ra-seg input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}
.ra-seg span,
.ra-toggle span,
.ra-actions button {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 6px;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--ra-muted);
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s var(--ra-ease), color 0.15s var(--ra-ease);
}
.ra-seg input:checked + span {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.ra-seg input:focus-visible + span {
  outline: 2px solid var(--ra-accent);
  outline-offset: 1px;
}
.ra-seg span:hover {
  color: var(--ra-text);
}
.ra-toggle {
  position: relative;
  display: inline-flex;
  border: 1px solid var(--ra-border);
  border-radius: 8px;
  padding: 2px;
}
.ra-toggle input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}
.ra-toggle span::before {
  content: "";
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 3px;
  border: 1px solid var(--ra-border-strong);
  background: transparent;
  transition: background-color 0.15s var(--ra-ease), border-color 0.15s var(--ra-ease);
}
.ra-toggle input:checked + span {
  color: #fff;
}
.ra-toggle input:checked + span::before {
  background: var(--ra-swap);
  border-color: var(--ra-swap);
}
.ra-toggle input:focus-visible + span {
  outline: 2px solid var(--ra-accent);
  outline-offset: 1px;
}
.ra-actions {
  display: inline-flex;
  gap: 6px;
  margin-left: auto;
}
.ra-actions button {
  border: 1px solid var(--ra-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ra-text);
}
.ra-actions button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
}
.ra-actions button:disabled {
  color: var(--ra-faint);
  cursor: not-allowed;
}
.ra-actions button[aria-pressed="true"] {
  background: var(--ra-accent);
  border-color: var(--ra-accent);
  color: #fff;
}

/* ---------- stage ---------- */
.ra-stage {
  position: relative;
  min-height: 360px;
  border: 1px solid var(--ra-border);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0) 60%);
  overflow: hidden;
}
.ra-stage svg {
  display: block;
  width: 100%;
  height: 100%;
  font-family: var(--ra-ui);
}
.ra-stage-msg {
  margin: 0;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px dashed var(--ra-border-strong);
  color: var(--ra-muted);
  font-size: 12px;
}

.ra-seg-block {
  cursor: pointer;
  outline: none;
  transition: transform 0.45s var(--ra-ease), opacity 0.3s var(--ra-ease);
}
.ra-seg-block rect {
  transition: stroke 0.15s var(--ra-ease), opacity 0.3s var(--ra-ease);
}
.ra-seg-block:hover rect.ra-fill {
  stroke: #fff;
  stroke-width: 1.5;
}
.ra-seg-block:focus-visible rect.ra-fill {
  stroke: #fff;
  stroke-width: 2;
}
.ra-seg-block[aria-pressed="true"] rect.ra-fill {
  stroke: #fff;
  stroke-width: 2;
}
.ra-dim {
  opacity: 0.28;
}
.ra-rail text {
  font-size: 12px;
  fill: var(--ra-text);
}
.ra-rail .ra-rail-name {
  font-weight: 600;
}
.ra-rail .ra-rail-val {
  font-family: var(--ra-mono);
  font-size: 11.5px;
  fill: var(--ra-muted);
}
.ra-rail .ra-rail-delta {
  font-family: var(--ra-mono);
  font-size: 11.5px;
  fill: var(--ra-text);
}
.ra-rail line {
  stroke: var(--ra-faint);
  stroke-width: 1;
}
.ra-rail .ra-rail-row {
  cursor: pointer;
  transition: opacity 0.3s var(--ra-ease);
}
.ra-head-date {
  font-size: 11px;
  fill: var(--ra-muted);
}
.ra-head-k {
  font-size: 11px;
  font-weight: 700;
}
.ra-head-total {
  font-family: var(--ra-mono);
  font-size: 20px;
  font-weight: 600;
  fill: #fff;
}
.ra-head-note {
  font-size: 10.5px;
  fill: var(--ra-pss);
}
.ra-baseline {
  stroke: var(--ra-border-strong);
  stroke-width: 1;
}
.ra-missing rect {
  fill: none;
  stroke: var(--ra-faint);
  stroke-dasharray: 4 3;
}
.ra-missing text {
  font-size: 10.5px;
  fill: var(--ra-muted);
}
.ra-axis text {
  font-family: var(--ra-mono);
  font-size: 10.5px;
  fill: var(--ra-muted);
}
.ra-axis line {
  stroke: var(--ra-border);
}
.ra-wf-label {
  font-size: 11.5px;
  fill: var(--ra-text);
}
.ra-wf-val {
  font-family: var(--ra-mono);
  font-size: 11.5px;
  fill: var(--ra-text);
}
.ra-wf-conn {
  stroke: var(--ra-faint);
  stroke-dasharray: 2 3;
}
.ra-wf-title {
  font-size: 12px;
  fill: var(--ra-muted);
}
.ra-wf-title tspan.ra-strong {
  fill: #fff;
  font-weight: 600;
}

/* ---------- dates ---------- */
.ra-dates {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 18px;
}
.ra-date {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}
.ra-date-k {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #0a0a0a;
}
.ra-date-a {
  background: #c8ccd6;
}
.ra-date-b {
  background: #fff;
}
.ra-date input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: var(--ra-accent);
  cursor: pointer;
}
.ra-date output {
  font-family: var(--ra-mono);
  font-size: 12px;
  color: var(--ra-text);
  min-width: 10ch;
  text-align: right;
}

/* ---------- timeline ---------- */
.ra-timeline {
  height: 128px;
  border: 1px solid var(--ra-border);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
}
.ra-timeline svg {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}
.ra-tl-year text {
  font-family: var(--ra-mono);
  font-size: 10px;
  fill: var(--ra-faint);
}
.ra-tl-year line {
  stroke: var(--ra-border);
}
.ra-tl-band {
  transition: opacity 0.3s var(--ra-ease);
}
.ra-tl-marker text {
  font-size: 10px;
  font-weight: 700;
  fill: #fff;
}
.ra-tl-gap rect {
  fill: url(#raHatchGap);
}
.ra-tl-gap text {
  font-size: 10px;
  fill: var(--ra-muted);
}

/* ---------- panel ---------- */
.ra-panel h2 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.ra-panel h3 {
  margin: 18px 0 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ra-muted);
}
.ra-panel p {
  margin: 6px 0;
  color: var(--ra-text);
}
.ra-muted {
  color: var(--ra-muted);
}
.ra-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 8px;
  vertical-align: 0;
}
.ra-formula {
  font-family: var(--ra-mono);
  font-size: 12px;
  color: var(--ra-muted);
  margin: 0 0 10px;
}
.ra-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.ra-kpi {
  padding: 8px 10px;
  border: 1px solid var(--ra-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}
.ra-kpi small {
  display: block;
  font-size: 10.5px;
  color: var(--ra-muted);
}
.ra-kpi b {
  display: block;
  font-family: var(--ra-mono);
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  margin-top: 2px;
}
.ra-kpi b.ra-neg {
  color: var(--ra-pss);
}
.ra-kpi b.ra-pos {
  color: #5fd1a5;
}
.ra-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.ra-table th,
.ra-table td {
  padding: 5px 0;
  border-bottom: 1px solid var(--ra-border);
  text-align: right;
  font-family: var(--ra-mono);
  white-space: nowrap;
}
.ra-table th {
  font-family: var(--ra-ui);
  font-weight: 500;
  color: var(--ra-muted);
  font-size: 11px;
}
.ra-table th:first-child,
.ra-table td:first-child {
  text-align: left;
  font-family: var(--ra-ui);
}
.ra-table tr.ra-row {
  cursor: pointer;
}
.ra-table tr.ra-row:hover td {
  color: #fff;
}
.ra-table tr.ra-row[aria-selected="true"] td {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}
.ra-table tfoot td {
  border-bottom: none;
  color: var(--ra-muted);
}
.ra-recon {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  font-family: var(--ra-mono);
  font-size: 11.5px;
  border: 1px solid var(--ra-border);
}
.ra-recon.ra-ok {
  border-color: rgba(95, 209, 165, 0.4);
  color: #5fd1a5;
}
.ra-recon.ra-warn {
  border-color: rgba(255, 122, 107, 0.4);
  color: var(--ra-pss);
}
.ra-hist {
  height: 170px;
  margin-top: 6px;
  border: 1px solid var(--ra-border);
  border-radius: 8px;
  overflow: hidden;
}
.ra-inputs {
  margin: 0;
  padding: 0;
  list-style: none;
}
.ra-inputs li {
  padding: 6px 0;
  border-bottom: 1px solid var(--ra-border);
}
.ra-inputs li:last-child {
  border-bottom: none;
}
.ra-inputs .ra-in-name {
  font-weight: 500;
}
.ra-inputs code {
  font-family: var(--ra-mono);
  font-size: 11px;
  color: var(--ra-muted);
}
.ra-inputs .ra-in-meta {
  display: block;
  color: var(--ra-muted);
  font-size: 11.5px;
}
.ra-inputs .ra-in-obs {
  display: block;
  font-family: var(--ra-mono);
  font-size: 11px;
  color: var(--ra-muted);
}
.ra-caveat {
  margin-top: 16px;
  padding-top: 10px;
  border-top: 1px solid var(--ra-border);
  color: var(--ra-muted);
  font-size: 11.5px;
}
.ra-keys {
  margin-top: 8px;
  color: var(--ra-faint);
  font-size: 11px;
}
.ra-keys kbd {
  font-family: var(--ra-mono);
  font-size: 10px;
  padding: 1px 5px;
  border: 1px solid var(--ra-border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--ra-muted);
}
.ra-panel button.ra-link {
  font: inherit;
  color: var(--ra-accent);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

/* ---------- footer ---------- */
.ra-foot {
  padding: 8px 20px;
  border-top: 1px solid var(--ra-border);
  color: var(--ra-faint);
  font-size: 11px;
}

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .ra {
    display: block;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }
  .ra-top {
    grid-template-columns: 1fr;
    grid-template-areas: "brand" "title" "status";
    row-gap: 4px;
    padding: 12px 14px 10px;
  }
  .ra-status {
    justify-self: start;
    text-align: left;
    max-width: none;
  }
  .ra-title {
    font-size: 19px;
  }
  .ra-main {
    grid-template-columns: minmax(0, 1fr);
  }
  .ra-stagewrap {
    padding: 10px 12px 12px;
  }
  .ra-stage {
    height: min(62dvh, 520px);
    min-height: 380px;
  }
  .ra-dates {
    grid-template-columns: 1fr;
  }
  .ra-timeline {
    height: 96px;
  }
  .ra-panel {
    border-left: none;
    border-top: 1px solid var(--ra-border);
    overflow: visible;
  }
  .ra-actions {
    margin-left: 0;
  }
  .ra-head-total {
    font-size: 16px;
  }
  .ra-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .ra-seg-block,
  .ra-seg-block rect,
  .ra-tl-band,
  .ra-rail .ra-rail-row {
    transition: none;
  }
}
