:root {
  color-scheme: light;
  --paper: #faf9f5;
  --surface: #ffffff;
  --surface-subtle: #f2f5f3;
  --ink: #171717;
  --ink-soft: #3f4545;
  --muted: #747b7a;
  --line: #ddd9ce;
  --line-strong: #c7c1b3;
  --accent: #173f35;
  --accent-soft: #e6f0eb;
  --blue: #2251c7;
  --red: #a7352a;
  --red-soft: #fff0ed;
  --amber: #9c5a0f;
  --amber-soft: #fff4df;
  --green: #116849;
  --green-soft: #e7f4ed;
  --shadow: 0 18px 45px rgba(29, 32, 31, 0.07);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(23, 63, 53, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 76px 76px;
}
a { color: inherit; text-decoration: none; }
main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 42px 30px 64px;
  transition: opacity 160ms ease, transform 160ms ease, filter 160ms ease;
}
main.is-swapping {
  opacity: .58;
  transform: translateY(4px);
  filter: saturate(.96);
}
main.swap-in {
  animation: portal-swap-in 220ms ease both;
}

.topbar {
  min-height: 72px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  padding: 0 30px;
  border-bottom: 1px solid var(--line);
  background: rgba(250, 249, 245, 0.94);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 2;
}
.brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  width: fit-content;
}
.brand-mark {
  width: 32px;
  height: 32px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  position: relative;
  background: var(--paper);
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-top: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
}
.brand strong,
.brand small,
.user-chip span,
.user-chip small {
  display: block;
}
.brand strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
  font-weight: 500;
  letter-spacing: 0;
}
.brand small,
.user-chip small {
  color: var(--muted);
  margin-top: 1px;
  font-size: 12px;
}
.topnav {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
}
.topnav a {
  padding: 8px 13px;
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 650;
}
.topnav a:hover {
  background: var(--ink);
  color: #fff;
}
.topnav a.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.user-chip {
  justify-self: end;
  text-align: right;
}
.user-chip span {
  font-size: 13px;
  font-weight: 750;
}

.page-head {
  display: grid;
  grid-template-columns: minmax(0, 760px) auto;
  justify-content: space-between;
  align-items: end;
  gap: 28px;
  margin-bottom: 34px;
}
.page-head.compact {
  align-items: center;
  margin-bottom: 24px;
}
.eyebrow,
.section-kicker {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .11em;
  text-transform: uppercase;
  margin: 0 0 10px;
}
.section-kicker { margin-bottom: 4px; }
h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(38px, 5vw, 68px);
  line-height: .97;
  font-weight: 500;
  letter-spacing: 0;
  margin: 0;
  max-width: 900px;
}
.page-head.compact h1 {
  font-size: clamp(31px, 3.4vw, 47px);
  line-height: 1.04;
  max-width: 760px;
  overflow-wrap: anywhere;
}
h2 {
  font-size: 18px;
  line-height: 1.2;
  margin: 0;
  letter-spacing: 0;
}
h3 {
  font-size: 16px;
  margin: 12px 0 7px;
  letter-spacing: 0;
}
.lede {
  max-width: 640px;
  color: var(--ink-soft);
  font-size: 17px;
  line-height: 1.55;
  margin: 18px 0 0;
}
.compact-lede {
  margin-top: 10px;
}
.subtle,
.empty {
  color: var(--muted);
}
.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: end;
}
.inline-import {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: end;
}
.inline-import input {
  min-width: 240px;
  min-height: 39px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  font: inherit;
}
.agent-runtime {
  text-align: right;
}
.agent-runtime span,
.agent-runtime small {
  display: block;
}
.agent-runtime span {
  font-weight: 800;
}
.agent-runtime small {
  color: var(--muted);
  margin-top: 3px;
}

button,
.primary,
.secondary,
.ghost-action {
  border: 0;
  border-radius: 999px;
  padding: 11px 16px;
  font-weight: 750;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: 0;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease, opacity 140ms ease, transform 140ms ease;
}
button:disabled,
.is-loading {
  cursor: progress;
  opacity: .72;
}
button:active,
.primary:active,
.secondary:active,
.ghost-action:active {
  transform: translateY(1px);
}
.primary {
  background: var(--ink);
  color: #fff;
  box-shadow: 0 8px 20px rgba(23, 23, 23, 0.16);
}
.primary:hover {
  background: var(--accent);
}
.secondary {
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink);
  border: 1px solid var(--line-strong);
}
.icon-button,
.ml-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.lucide {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}
.ml-button {
  min-height: 41px;
  padding: 8px 13px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .16);
  box-shadow: 0 8px 20px rgba(23, 63, 53, .18);
  transition: background-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}
.ml-button:hover {
  background: #0f3129;
}
.ml-button:active {
  transform: translateY(1px);
}
.ml-button img {
  display: block;
  width: 118px;
  height: auto;
}
.ml-button span {
  color: rgba(255, 255, 255, .92);
  font-size: 12px;
  font-weight: 800;
}
.notice {
  max-width: 1180px;
  margin: -12px auto 20px;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  font-size: 14px;
  font-weight: 650;
}
.notice.success {
  background: #ecfdf3;
  color: #067647;
  border-color: #abefc6;
}
.notice.warn {
  background: #fffaeb;
  color: #b54708;
  border-color: #fedf89;
}
.ghost-action {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.58);
  color: var(--ink-soft);
  box-shadow: none;
}
.ghost-action:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.danger-action:hover {
  border-color: var(--red);
  color: var(--red);
}

.metrics,
.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--line);
}
.metrics article,
.status-card {
  background: rgba(255, 255, 255, 0.78);
  padding: 19px 20px;
  min-height: 116px;
}
.metrics small,
.status-card small,
.status-card span,
.mini,
.category {
  color: var(--muted);
}
.metrics small,
.status-card small {
  display: block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 14px;
}
.metrics span,
.status-card strong {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 42px;
  font-weight: 500;
  line-height: .95;
}
.metrics .metric-word {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 21px;
  font-weight: 800;
  line-height: 1.05;
  overflow-wrap: anywhere;
}
.status-card.danger { background: var(--red-soft); }
.status-card.warn { background: var(--amber-soft); }
.status-card.good { background: var(--green-soft); }

.panel {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: var(--shadow);
  transition: border-color 160ms ease, box-shadow 160ms ease, opacity 160ms ease, transform 160ms ease;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 14px;
  margin-bottom: 18px;
}
.panel-head > span {
  color: var(--muted);
  font-size: 13px;
}

.loan-list {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
}
.loan-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 22px;
  padding: 19px 2px;
  border-bottom: 1px solid var(--line);
  transition: background-color 150ms ease, opacity 150ms ease, transform 150ms ease;
}
.loan-row.is-submitting,
.finding.is-submitting,
.remediation-row.is-submitting,
.panel.is-submitting,
.page-head.is-submitting {
  opacity: .64;
  pointer-events: none;
}
.loan-row.is-submitting,
.finding.is-submitting,
.remediation-row.is-submitting {
  transform: translateX(3px);
}
.loan-row:hover .loan-main strong {
  color: var(--accent);
}
.loan-main .loan-id {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.loan-main {
  min-width: 0;
}
.loan-main strong,
.loan-main small {
  display: block;
}
.loan-main strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 29px;
  font-weight: 500;
  line-height: 1.05;
}
.loan-main small {
  color: var(--muted);
  margin-top: 5px;
  overflow-wrap: anywhere;
}
.loan-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 8px;
  align-items: center;
  max-width: 470px;
}
.mini {
  font-size: 13px;
  border-left: 1px solid var(--line);
  padding-left: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.readiness.not_ready,
.readiness-text.not_ready,
.severity.blocker {
  color: var(--red);
  background: var(--red-soft);
}
.readiness.ready_with_warnings,
.readiness-text.ready_with_warnings,
.severity.warning {
  color: var(--amber);
  background: var(--amber-soft);
}
.readiness.ready_for_du,
.readiness-text.ready_for_du,
.severity.info {
  color: var(--green);
  background: var(--green-soft);
}
.readiness-text {
  background: transparent !important;
  text-transform: capitalize;
}
.muted { color: var(--muted); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 365px;
  gap: 20px;
}
.stack {
  display: grid;
  gap: 20px;
  align-content: start;
}
.review-workspace {
  display: grid;
  gap: 18px;
}
.agent-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(242, 245, 243, .72);
}
.agent-icon {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
}
.agent-icon .lucide {
  width: 18px;
  height: 18px;
}
.agent-summary h2 {
  margin: 3px 0 6px;
}
.agent-summary p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.45;
}
.agent-path {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.agent-summary-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: end;
}
.agent-summary-actions form {
  margin: 0;
}
.icon-only {
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  justify-content: center;
}
.loan-chat-shell[hidden] {
  display: none;
}
.loan-chat-shell {
  position: fixed;
  inset: 0;
  z-index: 30;
}
.chat-drawer-open {
  overflow: hidden;
}
.chat-drawer-open body {
  position: fixed;
  inset: var(--chat-scroll-lock-top, 0) 0 auto 0;
  width: 100%;
  overflow: hidden;
}
.chat-scrim {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(16, 24, 40, .28);
  cursor: pointer;
}
.loan-chat-drawer {
  position: absolute;
  inset: 0 auto 0 0;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 10px;
  width: min(510px, calc(100vw - 24px));
  padding: 16px;
  border-right: 1px solid var(--line);
  background: #fff;
  box-shadow: 20px 0 44px rgba(16, 24, 40, .18);
  animation: drawer-in 160ms ease-out;
}
@keyframes drawer-in {
  from {
    transform: translateX(-18px);
    opacity: .72;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
.loan-chat-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 4px;
}
.loan-chat-head h2 {
  margin: 0;
  font-size: 20px;
}
.drawer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.compact-action {
  min-height: 34px;
  padding: 7px 10px;
}
.chat-context-meter {
  display: grid;
  gap: 8px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,.88), rgba(245,241,232,.72));
}
.context-meter-row,
.context-meter-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.context-meter-row > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.context-meter-row strong {
  font-size: 13px;
  white-space: nowrap;
}
.context-meter-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(15, 79, 75, .11);
}
.context-meter-track span {
  display: block;
  width: var(--chat-percent);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #9a7a35);
}
.context-meter-foot span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}
.context-meter-foot [data-chat-token-short] {
  white-space: nowrap;
}
.chat-session-history {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.66);
}
.chat-session-history summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 850;
}
.chat-session-history summary small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}
.chat-session-list {
  display: grid;
  gap: 4px;
  max-height: 170px;
  overflow: auto;
  padding: 0 8px 8px;
}
.chat-session-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 7px 8px;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
}
.chat-session-link.active,
.chat-session-link:hover {
  background: var(--surface-subtle);
}
.chat-session-link span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 800;
}
.chat-session-link small {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
.loan-chat-messages {
  display: grid;
  gap: 10px;
  overflow: auto;
  padding: 2px;
  align-content: start;
}
.chat-message {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}
.chat-message.user {
  grid-template-columns: minmax(0, 1fr);
  justify-items: end;
}
.chat-message.user .chat-avatar {
  display: none;
}
.chat-content {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  max-width: min(100%, 38rem);
}
.chat-message.user .chat-content {
  grid-column: 1;
  justify-self: end;
  align-items: flex-end;
  max-width: min(86%, 32rem);
}
.chat-message:not(.user) .chat-content {
  grid-column: 2;
  justify-self: start;
}
.chat-message.user .chat-bubble {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.chat-message.user .chat-bubble p {
  color: rgba(255, 255, 255, .92);
}
.chat-avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
}
.chat-avatar .lucide {
  width: 15px;
  height: 15px;
}
.chat-bubble {
  min-width: 0;
  width: fit-content;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(242, 245, 243, .72);
  padding: 10px 12px;
}
.chat-message.user .chat-bubble {
  justify-self: end;
}
.chat-bubble strong,
.chat-tool strong,
.chat-remediation strong {
  display: block;
  font-size: 13px;
  line-height: 1.35;
}
.chat-bubble p {
  margin: 5px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.chat-bubble small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}
.chat-message.user .chat-bubble small {
  color: rgba(255, 255, 255, .68);
}
.chat-tool-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.chat-tool,
.chat-remediation,
.chat-evidence {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .72);
  padding: 8px 10px;
}
.chat-tool {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  padding: 5px 8px;
  width: fit-content;
  max-width: 100%;
}
.chat-tool.done {
  color: var(--ink-soft);
}
.chat-tool strong {
  font-size: 11px;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tool-state {
  border-left: 1px solid var(--line);
  padding-left: 6px;
  white-space: nowrap;
}
.chat-tool.running .tool-state,
.chat-thinking {
  position: relative;
  overflow: hidden;
}
.chat-tool.running .tool-state::after,
.chat-thinking::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .7), transparent);
  animation: chat-shimmer 1.2s infinite;
}
@keyframes chat-shimmer {
  100% { transform: translateX(100%); }
}
.chat-remediation {
  margin-top: 8px;
  border-color: var(--green);
  background: var(--green-soft);
}
.chat-remediation span,
.chat-evidence span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.loan-chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}
.loan-chat-form textarea {
  width: 100%;
  resize: vertical;
  min-height: 48px;
  max-height: 150px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  line-height: 1.4;
}
.review-head {
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}
.review-tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-subtle);
}
.review-tab {
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}
.review-tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .08);
}
.review-tab-panel[hidden] {
  display: none;
}
.review-group-list {
  display: grid;
  gap: 12px;
}
.review-item-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .64);
  overflow: hidden;
}
.review-item-group > header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(242, 245, 243, .72);
}
.review-item-group.blocker > header {
  background: var(--red-soft);
}
.review-item-group.warning > header {
  background: var(--amber-soft);
}
.review-item-group.ready > header {
  background: var(--green-soft);
}
.review-item-group h3 {
  margin: 4px 0 0;
}
.finding-list {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
}
.finding-list.grouped,
.review-pass-list.grouped {
  border-top: 0;
}
.finding-list.grouped .finding,
.review-pass-list.grouped .review-pass {
  padding-left: 16px;
  padding-right: 16px;
}
.finding {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
  transition: opacity 150ms ease, transform 150ms ease, background-color 150ms ease;
}
.finding.blocker h3 { color: var(--red); }
.finding.warning h3 { color: var(--amber); }
.finding.info h3 { color: var(--green); }
.finding p {
  margin: 0 0 11px;
  color: var(--ink-soft);
  line-height: 1.48;
}
.finding footer {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.review-pass-list {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
}
.review-pass {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}
.review-pass:last-child,
.finding:last-child {
  border-bottom: 0;
}
.review-pass h3 {
  color: var(--green);
}
.review-pass p {
  margin: 0 0 12px;
  color: var(--ink-soft);
  line-height: 1.48;
}
.review-evidence {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.review-evidence div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .68);
  padding: 8px 10px;
}
.review-evidence dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.review-evidence dd {
  margin-top: 4px;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.remediation-list {
  display: grid;
  gap: 12px;
}
.remediation-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.66);
  overflow: hidden;
  transition: opacity 150ms ease, transform 150ms ease;
}
.remediation-group header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(242, 245, 243, 0.72);
}
.remediation-group h3 {
  margin: 5px 0 0;
}
.group-meta {
  display: flex;
  justify-content: end;
  flex-wrap: wrap;
  gap: 6px;
}
.remediation-rows {
  display: grid;
}
.remediation-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(140px, auto);
  gap: 10px 16px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  transition: opacity 150ms ease, transform 150ms ease, background-color 150ms ease;
}
.remediation-row:last-child {
  border-bottom: 0;
}
.remediation-row span,
.remediation-row small {
  display: block;
}
.remediation-row span {
  font-weight: 800;
  font-size: 13px;
}
.remediation-row small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.remediation-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: right;
}
.custom-remediation-copy {
  display: grid;
  gap: 8px;
}
.custom-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 4px 0 0;
}
.custom-facts div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(242, 245, 243, .62);
  padding: 8px 10px;
}
.custom-facts dt {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.custom-facts dd {
  margin-top: 3px;
  font-size: 13px;
}
.remediation-row .table-actions {
  grid-column: 1 / -1;
  justify-content: start;
}
.remediation-row .ghost-action {
  min-height: 28px;
  padding: 6px 9px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 8px;
  text-align: left;
  vertical-align: top;
}
th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.facts {
  display: grid;
  gap: 11px;
  margin: 14px 0 0;
}
.facts div {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
dt {
  color: var(--muted);
  font-size: 13px;
}
dd {
  margin: 0;
  font-weight: 700;
  min-width: 0;
  overflow-wrap: anywhere;
}
.doc-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}
.employment-list {
  display: grid;
  gap: 0;
  margin-top: 14px;
  border-top: 1px solid var(--line);
}
.employment-list article {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 10px;
  align-items: start;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.employment-list strong,
.employment-list span,
.employment-list small {
  display: block;
}
.employment-list strong {
  font-size: 13px;
}
.employment-list div > span,
.employment-list small {
  color: var(--muted);
  font-size: 12px;
}
.employment-list small {
  grid-column: 1 / -1;
}
.doc-list article {
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.doc-list strong,
.doc-list span,
.doc-list small {
  display: block;
}
.doc-list strong {
  font-size: 12px;
  letter-spacing: .08em;
}
.doc-list span {
  color: var(--ink-soft);
  margin-top: 4px;
}
.doc-list small {
  color: var(--muted);
  margin-top: 5px;
}
.timeline {
  display: grid;
  gap: 0;
  margin-top: 14px;
  border-top: 1px solid var(--line);
}
.timeline article {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.timeline strong,
.timeline span,
.timeline small {
  display: block;
}
.timeline strong {
  text-transform: capitalize;
}
.timeline span,
.timeline small {
  color: var(--muted);
  margin-top: 4px;
}
.timeline small {
  overflow-wrap: anywhere;
}
.inline-link {
  display: inline-flex;
  margin-top: 9px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 750;
}
.text-preview {
  border-top: 1px solid var(--line);
  padding: 16px 0;
}
.text-preview span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.text-preview pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
  color: var(--ink-soft);
  font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}
.preview-note {
  color: var(--muted);
  line-height: 1.5;
}
.source-preview {
  min-height: 540px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.source-preview iframe {
  width: 100%;
  height: 640px;
  border: 0;
  display: block;
  background: #fff;
}
.source-preview img {
  display: block;
  width: 100%;
  height: auto;
}
.evidence-head {
  margin-bottom: 18px;
}
.evidence-focus {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 22px;
  align-items: center;
  padding: 18px 20px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}
.evidence-focus h2 {
  margin: 4px 0 0;
  font-size: 24px;
}
.evidence-focus dl {
  display: grid;
  grid-template-columns: repeat(4, auto);
  gap: 16px;
  margin: 0;
}
.evidence-focus dt,
.evidence-focus dd {
  display: block;
}
.evidence-focus dd {
  margin-top: 3px;
}
.evidence-reviewer {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, .65fr);
  gap: 18px;
  align-items: start;
}
.evidence-document {
  position: sticky;
  top: 18px;
}
.source-preview.integrated {
  min-height: 720px;
}
.source-preview.integrated iframe {
  height: 760px;
}
.evidence-sidebar {
  display: grid;
  gap: 18px;
}
.evidence-facts {
  display: grid;
  margin: 0;
  border-top: 1px solid var(--line);
}
.evidence-facts div {
  display: grid;
  grid-template-columns: 138px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.evidence-facts dt {
  font-weight: 760;
}
.evidence-facts dd {
  color: var(--ink);
}
.compact-facts div {
  grid-template-columns: 92px minmax(0, 1fr);
}
.evidence-snippets {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}
.evidence-snippets article {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-subtle);
  color: var(--ink-soft);
  line-height: 1.45;
}
.ocr-details {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.evidence-text-details {
  margin-top: 14px;
}
.ocr-details summary {
  cursor: pointer;
  color: var(--ink-soft);
  font-weight: 780;
}
.compact-text {
  padding: 12px 0 0;
}
.compact-text pre {
  max-height: 260px;
  overflow: auto;
}
.agent-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.agent-case {
  display: grid;
  gap: 16px;
}
.agent-decision {
  border-top: 0;
}
.agent-decision div {
  grid-template-columns: 98px minmax(0, 1fr);
}
.agent-reason {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.5;
}
.agent-io {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.agent-io section {
  min-width: 0;
}
.agent-io h3 {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin: 0 0 8px;
}
.agent-io pre,
.agent-raw {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  color: var(--ink-soft);
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
}
.doc-queue {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
}
.doc-queue-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 22px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}
.doc-queue-row strong,
.doc-queue-row small {
  display: block;
}
.doc-queue-row strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 25px;
  font-weight: 500;
  line-height: 1.08;
}
.doc-queue-row small {
  color: var(--muted);
  margin-top: 5px;
  overflow-wrap: anywhere;
}
.doc-queue-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: end;
  max-width: 560px;
}
.note-panel {
  margin-top: 20px;
}
.note-panel p:last-child {
  color: var(--ink-soft);
  line-height: 1.55;
  max-width: 820px;
}

/* Console revamp */
:root {
  --paper: #f5efe4;
  --surface: #fffaf1;
  --surface-subtle: #ebe3d3;
  --ink: #14201d;
  --ink-soft: #33413d;
  --muted: #69736c;
  --line: #d7cab4;
  --line-strong: #968b78;
  --accent: #174942;
  --accent-soft: #dfe9e2;
  --blue: #315a8f;
  --blue-deep: #24446e;
  --red: #983834;
  --red-soft: #f7e8e3;
  --amber: #815a22;
  --amber-soft: #f3e8d2;
  --green: #28644e;
  --green-soft: #e2eee5;
  --shadow: 0 16px 34px rgba(32, 27, 18, 0.07);
}

body {
  background:
    radial-gradient(circle at 22% -8%, rgba(23, 73, 66, .08), transparent 30%),
    radial-gradient(circle at 100% 4%, rgba(129, 90, 34, .06), transparent 24%),
    linear-gradient(180deg, #fffaf1 0%, var(--paper) 100%);
}

.app-shell {
  min-height: 100vh;
  display: block;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto minmax(210px, 1fr);
  align-items: center;
  gap: 24px;
  padding: 0 38px;
  border-right: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 250, 241, .94);
  backdrop-filter: blur(18px);
}

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 34px 30px 52px;
}

.brand {
  gap: 12px;
  padding: 0;
}

.rail-toggle {
  display: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border: 2px solid var(--accent);
  border-radius: 14px;
  background: linear-gradient(135deg, #e8ede5, #fffaf1);
  box-shadow: inset 0 0 0 5px var(--surface);
}

.brand-mark::after {
  inset: 8px;
  border: 0;
  border-left: 3px solid var(--accent);
  border-bottom: 3px solid var(--accent);
  transform: rotate(-35deg);
}

.brand strong {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  font-weight: 850;
  text-transform: uppercase;
}

.brand small {
  color: var(--accent);
  font-size: 14px;
  font-weight: 760;
}

.topnav {
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .62);
}

.topnav a {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 36px;
  padding: 0 13px;
  border-radius: 6px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 760;
}

.topnav a:hover,
.topnav a.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.topnav .lucide {
  width: 20px;
  height: 20px;
}

.user-chip {
  justify-self: end;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 0;
  border-top: 0;
  text-align: left;
}

.user-chip .user-avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: linear-gradient(180deg, #e6f0eb, #cbded4);
  color: var(--accent);
  border: 1px solid #bfd3c7;
  font-size: 13px;
  font-weight: 850;
  line-height: 1;
  text-transform: uppercase;
}

.user-text {
  min-width: 0;
  max-width: 170px;
}

.user-text > span,
.user-text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

h1,
.page-head.compact h1,
.loan-main strong,
.metrics span,
.status-card strong,
.doc-queue-row strong {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 820;
}

h1,
.page-head.compact h1 {
  font-size: clamp(30px, 3.1vw, 44px);
  line-height: 1.08;
}

h2 {
  font-size: 17px;
  font-weight: 820;
}

h3 {
  font-size: 15px;
  font-weight: 820;
}

.lede {
  font-size: 15px;
  line-height: 1.45;
}

.page-head {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  margin-bottom: 26px;
}

.dashboard-head {
  align-items: start;
}

.loan-hero {
  grid-template-columns: 1fr;
  gap: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.loan-hero .actions {
  justify-content: start;
  flex-wrap: wrap;
}

.loan-hero + .status-grid {
  display: none;
}

.back-link {
  margin: 0 0 22px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 780;
}

.back-link a::before {
  content: "←";
  margin-right: 8px;
}

.loan-title-row {
  display: grid;
  grid-template-columns: minmax(0, max-content) auto;
  align-items: center;
  gap: 16px 22px;
  max-width: 100%;
}

.loan-title-row h1 {
  max-width: min(760px, 100%);
  overflow-wrap: normal;
  word-break: normal;
}

.loan-number {
  padding-left: 20px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  font-weight: 760;
}

.property-line {
  margin: 6px 0 0;
  font-size: 13px;
}

.loan-status-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
}

.status-count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 780;
}

.danger-text { color: var(--red); }
.warn-text { color: var(--amber); }

button,
.primary,
.secondary,
.ghost-action,
.ml-button {
  border-radius: 6px;
  font-weight: 780;
}

.primary {
  background: linear-gradient(180deg, #1f5a52, #143f39);
  color: #fff;
  box-shadow: 0 10px 22px rgba(23, 73, 66, .2);
}

.primary:hover {
  background: #123a35;
}

.secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  box-shadow: 0 1px 2px rgba(32, 27, 18, .04);
}

.secondary:hover,
.ghost-action:hover {
  border-color: #9ab2a7;
  color: var(--accent);
  background: #f4f8f3;
}

.ml-button {
  min-height: 42px;
  background: #112d32;
  color: #fff;
  box-shadow: 0 10px 22px rgba(17, 45, 50, .18);
}

.ml-button:hover {
  background: #0b2226;
}

.ml-button img {
  width: 106px;
}

.ml-button span {
  font-size: 13px;
  text-transform: none;
}

.inline-import {
  align-items: end;
}

.inline-import input {
  min-height: 46px;
  border-color: var(--line);
  border-radius: 7px;
  background: #fff;
}

.metrics,
.status-grid {
  gap: 14px;
  border: 0;
  overflow: visible;
  background: transparent;
}

.metrics article,
.status-card {
  min-height: 106px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .86);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

.metrics span,
.status-card strong {
  font-size: 34px;
}

.status-card.danger,
.status-card.warn,
.status-card.good {
  background: #fff;
}

.status-card .readiness-text {
  font-size: 23px;
  line-height: 1.05;
}

.panel {
  background: rgba(255, 255, 255, .9);
  border-color: var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

.panel:hover {
  border-color: #b8c7bd;
}

.detail-layout {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 306px);
  column-gap: 24px;
  align-items: start;
}

.detail-layout > aside.stack {
  position: sticky;
  top: 18px;
  min-width: 0;
  align-self: stretch;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 1px;
  scrollbar-width: thin;
  scrollbar-color: rgba(105, 115, 108, .36) transparent;
}

.detail-layout > aside.stack .support-panel {
  display: none;
}

.review-workspace > .agent-summary {
  display: none;
}

.agent-side-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
  position: static;
  background: var(--surface);
}

.agent-side-head {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.agent-side-head p,
.agent-side-section p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.agent-side-section {
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.agent-label {
  display: block;
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 820;
}

.agent-mini-list {
  display: grid;
  gap: 10px;
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.4;
}

.agent-mini-list li::marker {
  color: var(--accent);
}

.agent-chat-button {
  width: 100%;
}

.agent-side-panel form {
  margin: 0;
}

.agent-icon {
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
}

.review-head {
  align-items: center;
  gap: 12px;
}

.review-tabs {
  border-radius: 8px;
  background: var(--surface-subtle);
}

.review-tab {
  border-radius: 6px;
}

.review-tab.active {
  color: var(--accent);
}

.review-item-group,
.remediation-group {
  background: #fff;
  border-color: var(--line);
}

.review-item-group > header,
.remediation-group header {
  background: rgba(255, 253, 248, .78);
}

.review-item-group.blocker > header {
  background: var(--red-soft);
}

.review-item-group.warning > header {
  background: var(--amber-soft);
}

.review-item-group.ready > header {
  background: var(--green-soft);
}

.finding,
.review-pass {
  padding-top: 13px;
  padding-bottom: 13px;
}

.finding h3,
.review-pass h3 {
  color: var(--ink);
}

.finding .row-actions form:first-child .ghost-action {
  border-color: #b7d1c2;
  background: var(--green-soft);
  color: var(--green);
}

.finding .row-actions form:first-child .ghost-action:hover {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.finding .row-actions .danger-action {
  background: transparent;
}

.finding .row-actions .danger-action:hover {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}

.review-evidence div,
.custom-facts div,
.chat-bubble,
.chat-tool,
.chat-remediation,
.chat-evidence {
  background: rgba(255, 253, 248, .82);
}

.support-panel {
  padding: 0;
  overflow: hidden;
}

.support-panel > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
}

.support-panel > summary::-webkit-details-marker {
  display: none;
}

.support-panel > summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 140ms ease;
}

.support-panel[open] > summary {
  border-bottom: 1px solid var(--line);
}

.support-panel[open] > summary::after {
  transform: rotate(225deg);
}

.support-panel > summary .section-kicker {
  margin: 0 0 3px;
}

.support-panel > summary h2 {
  margin: 0;
}

.support-panel > .facts,
.support-panel > .employment-list,
.support-panel > .doc-list,
.support-panel > .timeline,
.support-panel > .empty {
  margin: 0;
  padding: 14px 16px 16px;
}

.support-panel > .facts {
  gap: 0;
}

.support-panel > .facts div:last-child,
.support-panel .employment-list article:last-child,
.support-panel .doc-list article:last-child,
.support-panel .timeline article:last-child {
  border-bottom: 0;
}

.support-panel .doc-list,
.support-panel .timeline,
.support-panel .employment-list {
  border-top: 0;
}

.support-panel .doc-list article,
.support-panel .timeline article,
.support-panel .employment-list article {
  padding-left: 0;
  padding-right: 0;
}

.doc-list article {
  min-width: 0;
}

.doc-list strong,
.doc-list span,
.doc-list small,
.doc-list a {
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.doc-list strong {
  color: var(--ink);
}

.timeline article {
  min-width: 0;
}

.remediation-row {
  grid-template-columns: minmax(0, 1fr) minmax(170px, auto);
  padding-top: 10px;
  padding-bottom: 10px;
}

.remediation-row strong {
  color: var(--ink);
}

.pill {
  border-radius: 6px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 12px;
}

.readiness.not_ready,
.readiness-text.not_ready,
.severity.blocker {
  color: var(--red);
  background: var(--red-soft);
  border: 1px solid #e6bcb4;
}

.readiness.ready_with_warnings,
.readiness-text.ready_with_warnings,
.severity.warning {
  color: var(--amber);
  background: var(--amber-soft);
  border: 1px solid #dec69a;
}

.readiness.ready_for_du,
.readiness-text.ready_for_du,
.severity.info {
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid #b7d1c2;
}

.loan-table-panel {
  padding: 0;
  overflow: hidden;
}

.loan-table-panel .panel-head {
  padding: 20px 22px;
  margin: 0;
  border-bottom: 1px solid var(--line);
}

.loan-table {
  display: grid;
}

.loan-table-header,
.loan-row {
  display: grid;
  grid-template-columns: minmax(142px, 1.25fr) minmax(116px, .78fr) minmax(102px, .68fr) minmax(128px, .9fr) minmax(110px, .72fr) 76px;
  gap: 8px;
  align-items: center;
}

.loan-table-header {
  min-height: 48px;
  padding: 12px 16px 10px;
  color: var(--ink-soft);
  background: rgba(255, 250, 241, .72);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 820;
}

.loan-row {
  grid-template-columns: minmax(142px, 1.25fr) minmax(116px, .78fr) minmax(102px, .68fr) minmax(128px, .9fr) minmax(110px, .72fr) 76px;
  min-height: 80px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.loan-row:hover {
  background: rgba(255, 250, 241, .72);
}

.loan-row:last-child {
  border-bottom: 0;
}

.loan-main strong {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.25;
}

.loan-main small,
.last-review-cell,
.open-item-cell {
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.35;
}

.loan-id-link {
  color: var(--accent);
  font-size: 13px;
  font-weight: 780;
}

.open-item-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  font-weight: 760;
}

.last-review-cell span {
  display: block;
}

.loan-meta {
  flex-wrap: nowrap;
  justify-content: end;
  gap: 6px;
  max-width: none;
}

.loan-meta form {
  margin: 0;
}

.loan-table .icon-only {
  width: 32px;
  height: 32px;
  min-height: 32px;
}

.ghost-action.icon-only,
.icon-only {
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
}

.sync-callout {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 22px;
  align-items: center;
  margin-top: 20px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .82);
}

.sync-callout > span {
  display: grid;
  place-items: center;
  width: 70px;
  height: 70px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}

.sync-callout .lucide {
  width: 34px;
  height: 34px;
}

.sync-callout p {
  margin: 8px 0 0;
  color: var(--muted);
}

.loan-chat-drawer {
  inset: 0 0 0 auto;
  border-right: 0;
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 44px rgba(16, 24, 40, .18);
  animation: drawer-in-right 160ms ease-out;
}

@keyframes drawer-in-right {
  from {
    transform: translateX(18px);
    opacity: .72;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.chat-message.user .chat-bubble {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: #b7cbc0;
}

.chat-message.user .chat-bubble p {
  color: var(--accent);
}

.evidence-modal-shell[hidden] {
  display: none;
}

.evidence-modal-shell {
  position: fixed;
  inset: 0;
  z-index: 35;
}

.evidence-modal-open {
  overflow: hidden;
}

.evidence-modal-scrim {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(16, 24, 40, .42);
  cursor: pointer;
}

.evidence-modal {
  position: absolute;
  inset: 28px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(16, 24, 40, .28);
  overflow: hidden;
}

.evidence-modal header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.evidence-modal h2 {
  margin: 3px 0 0;
}

.evidence-modal iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--surface);
}

.report-shell {
  padding: 0;
  overflow: hidden;
}

.report-shell .panel-head {
  padding: 18px 20px;
  margin: 0;
  border-bottom: 1px solid var(--line);
}

.report-shell iframe {
  display: block;
  width: 100%;
  min-height: calc(100vh - 240px);
  border: 0;
  background: var(--surface);
}

.modal-body .app-shell {
  display: block;
  min-height: 100vh;
}

.modal-body .topbar,
.modal-body .portal-progress {
  display: none;
}

.modal-body main {
  padding: 18px;
}

.modal-body .evidence-head {
  display: none;
}

.modal-body .evidence-reviewer {
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, .75fr);
}

.modal-body .evidence-document {
  position: static;
}

.modal-body .source-preview.integrated,
.modal-body .source-preview.integrated iframe {
  min-height: 0;
  height: calc(100vh - 100px);
}

.portal-progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 20;
  width: 100%;
  height: 3px;
  pointer-events: none;
  opacity: 0;
  overflow: hidden;
}
.portal-progress::before {
  content: "";
  display: block;
  width: 42%;
  height: 100%;
  background: var(--accent);
  box-shadow: 0 0 18px rgba(23, 63, 53, .36);
  transform: translateX(-110%);
}
.portal-progress.active {
  opacity: 1;
}
.portal-progress.active::before {
  animation: portal-progress 1.05s ease-in-out infinite;
}
.portal-busy .topbar {
  border-bottom-color: var(--line-strong);
}

@keyframes portal-progress {
  0% { transform: translateX(-110%); }
  52% { transform: translateX(92%); }
  100% { transform: translateX(245%); }
}

@keyframes portal-swap-in {
  from {
    opacity: .62;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  main { padding: 28px 16px 42px; }
  .topbar {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    min-height: auto;
    position: static;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .topnav {
    grid-column: 1 / -1;
    justify-self: stretch;
    display: flex;
    justify-content: stretch;
  }
  .topnav a {
    flex: 1;
    justify-content: center;
    min-height: 42px;
    padding: 0 8px;
  }
  .user-chip {
    justify-self: end;
    gap: 8px;
    text-align: left;
    padding-top: 0;
  }
  .user-avatar {
    width: 34px;
    height: 34px;
  }
  .user-text {
    display: none;
  }
  .page-head,
  .page-head.compact {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .metrics,
  .status-grid,
  .detail-layout {
    grid-template-columns: 1fr;
  }
  .loan-row {
    grid-template-columns: 1fr;
  }
  .doc-queue-row {
    grid-template-columns: 1fr;
  }
  .agent-grid,
  .agent-io {
    grid-template-columns: 1fr;
  }
  .agent-summary {
    grid-template-columns: 1fr;
  }
  .detail-layout > aside.stack {
    position: static;
    max-height: none;
    overflow: visible;
  }
  .agent-summary-actions {
    align-items: start;
  }
  .loan-chat-form {
    grid-template-columns: 1fr;
  }
  .loan-chat-form button {
    justify-self: end;
  }
  .review-head {
    grid-template-columns: 1fr;
  }
  .review-tabs {
    justify-self: start;
  }
  .review-evidence {
    grid-template-columns: 1fr;
  }
  .evidence-reviewer,
  .evidence-focus {
    grid-template-columns: 1fr;
  }
  .evidence-document {
    position: static;
  }
  .evidence-focus dl {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .loan-meta {
    justify-content: start;
  }
  .doc-queue-meta {
    justify-content: start;
  }
  .actions {
    justify-content: start;
    flex-wrap: wrap;
  }
  .loan-table-header {
    display: none;
  }
  .loan-row,
  .loan-table-header {
    grid-template-columns: 1fr;
  }
  .loan-row {
    gap: 10px;
    align-items: start;
    padding: 16px;
  }
  .loan-meta {
    justify-content: start;
  }
  .sync-callout {
    grid-template-columns: 1fr;
  }
  .loan-title-row {
    display: grid;
    gap: 8px;
  }
  .loan-number {
    padding-left: 0;
    border-left: 0;
  }
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 18% 0%, rgba(23, 73, 66, .13), transparent 30%),
    radial-gradient(circle at 92% 12%, rgba(129, 90, 34, .09), transparent 24%),
    linear-gradient(180deg, #fffaf1 0%, var(--paper) 100%);
}

.login-shell {
  width: min(430px, calc(100vw - 32px));
  display: grid;
  gap: 12px;
}

.login-panel {
  display: grid;
  gap: 19px;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.login-brand {
  margin-bottom: 4px;
}

.login-panel h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.05;
}

.login-panel p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.45;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 780;
  color: var(--ink-soft);
}

.login-form label span {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.login-form label small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 720;
}

.login-form input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 11px 12px;
  background: rgba(255,255,255,.82);
  color: var(--ink);
  font: inherit;
}

.login-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 73, 66, .12);
}

.login-form button,
.logout-form button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 780;
  cursor: pointer;
}

.login-form button {
  padding: 12px 14px;
}

.login-footnote {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.logout-form {
  margin: 0;
}

.logout-form button {
  min-height: 34px;
  padding: 0 11px;
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.logout-form button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
