* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  /* Botminds brand: navy #0A1628 · blue #0492EB */
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --surface-2: #EDF1F5;
  --border: #E2E7EC;
  --border-2: #CFD7E0;
  --text: #0A1628;
  --text-2: #53606E;
  --text-3: #8A95A2;
  --accent: #0492EB;
  --accent-soft: #E0F1FD;
  --accent-bg: #EFF7FE;
  --success: #15604A;
  --success-soft: #E6F0EB;
  --warn: #B45309;
  --warn-soft: #FEF3E2;
  --danger: #9F1239;
  --danger-soft: #FDE7EC;
  --info: #1E3A8A;
  --info-soft: #E5EAF6;
  --purple: #5B21B6;
  --purple-soft: #EFE9FC;
}
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'ss01', 'cv11';
}
.mono { font-family: 'JetBrains Mono', monospace; font-feature-settings: 'zero', 'ss01'; }

/* APP SHELL */
.app {
  max-width: 1320px;
  margin: 0 auto;
  background: var(--surface);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  min-height: 100vh;
}
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.3px;
}
.brand-logo {
  height: 28px;
  width: auto;
  display: block;
}
.nav-tabs {
  display: flex;
  gap: 2px;
  background: var(--surface-2);
  padding: 3px;
  border-radius: 8px;
}
.nav-tab {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  border: 0;
  background: transparent;
  font-family: inherit;
  transition: all 0.15s;
}
.nav-tab:hover { color: var(--text); }
.nav-tab.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.user-cluster {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-2);
}
.avatar {
  width: 30px; height: 30px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 500;
}

/* SCREENS */
.screen { display: none; padding: 28px; }
.screen.active { display: block; }
.screen-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
}
.screen-title {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.5px;
}
.screen-sub {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 2px;
}

/* PILLS */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 999px;
  line-height: 1.4;
  border: 1px solid transparent;
}
.pill-progress { background: var(--info-soft); color: var(--info); }
.pill-done { background: var(--success-soft); color: var(--success); }
.pill-critical { background: var(--accent-bg); color: var(--accent); border-color: rgba(4, 146, 235,0.2); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-wait { background: var(--surface-2); color: var(--text-2); }
.pill-purple { background: var(--purple-soft); color: var(--purple); }

.live-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
  animation: pulse 1.8s infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}
.muted { color: var(--text-2); }
.tiny { font-size: 11px; color: var(--text-3); }
.mini { font-size: 12px; color: var(--text-2); }

/* KPI STRIP */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}
.kpi-label {
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.2px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.kpi-value {
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.6px;
  line-height: 1.1;
}
.kpi-delta {
  font-size: 11px;
  margin-top: 5px;
  color: var(--success);
  display: flex;
  align-items: center;
  gap: 3px;
}
.kpi-delta.neg { color: var(--danger); }
.kpi-delta.flat { color: var(--text-3); }
.progress {
  height: 4px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}
.progress-fill {
  height: 100%;
  background: var(--text);
  border-radius: 999px;
}
.progress-fill.warn { background: var(--accent); }
.progress-fill.good { background: var(--success); }

/* SLA TRACKER */
.sla-tracker {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}
.sla-title { font-size: 12px; color: var(--text-2); margin-bottom: 12px; letter-spacing: 0.2px; }
.sla-row {
  display: grid;
  grid-template-columns: 1.2fr 80px 1fr 50px;
  gap: 10px;
  align-items: center;
  padding: 7px 0;
  border-top: 1px solid var(--border);
  font-size: 12px;
}
.sla-row:first-of-type { border-top: 0; }
.sla-bar { height: 5px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.sla-bar-fill { height: 100%; border-radius: 3px; }
.sla-bar-fill.ok { background: var(--success); }
.sla-bar-fill.warn { background: var(--warn); }
.sla-bar-fill.breach { background: var(--danger); }

/* WORKBENCH GRID */
.workbench-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
}
.task-card {
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 0 0 6px var(--accent-bg);
}
.task-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.task-question {
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.3px;
  line-height: 1.35;
  margin-bottom: 6px;
}
.task-flag {
  background: var(--surface-2);
  border-left: 2px solid var(--accent);
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  color: var(--text-2);
  margin: 14px 0 20px;
}
.evidence {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 22px;
}
.doc-card {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 14px;
}
.doc-head {
  font-size: 11px;
  color: var(--text-3);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.doc-body {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-2);
}
.doc-body strong {
  background: #FDE6B8;
  color: #6B3A06;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 400;
}
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.action-group { display: flex; gap: 8px; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:hover { background: var(--surface-2); }
.btn-approve { background: var(--success); border-color: var(--success); color: white; }
.btn-approve:hover { background: #0F4D3B; }
.btn-reject { background: var(--surface); border-color: var(--border-2); color: var(--text); }
.btn-ghost { background: transparent; border: 0; color: var(--text-2); padding: 10px 12px; }
.btn-ghost:hover { background: var(--surface-2); }
.key {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 10px;
  padding: 1px 4px;
  color: var(--text-2);
  font-family: 'JetBrains Mono', monospace;
}
.btn-approve .key { background: rgba(255,255,255,0.2); border-color: rgba(255,255,255,0.3); color: rgba(255,255,255,0.9); }
/* removed: xp-tag (gamification) */

/* QUEUE */
.queue-section { margin-top: 24px; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-title { font-size: 14px; font-weight: 500; }
.queue-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.queue-item:hover { border-color: var(--border-2); background: var(--surface-2); }
.queue-item.task-highlight { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.task-card.task-highlight { box-shadow: 0 0 0 6px var(--accent-bg), 0 0 16px var(--accent-soft); }
.task-filter-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 8px 14px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--accent);
}
.task-filter-banner.active { display: flex; }
.task-filter-banner .tfb-clear {
  cursor: pointer;
  font-weight: 500;
  text-decoration: underline;
}
.queue-item.task-dimmed, .task-card.task-dimmed { opacity: 0.3; }
.queue-text { flex: 1; font-size: 13px; }
.queue-meta { font-size: 11px; color: var(--text-3); display: flex; gap: 14px; }

/* SIDE RAIL */
.side-rail { display: flex; flex-direction: column; gap: 16px; }
.rail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}
.rail-head {
  font-size: 12px;
  color: var(--text-2);
  letter-spacing: 0.2px;
  margin-bottom: 10px;
}
.badge-row { display: flex; gap: 6px; flex-wrap: wrap; }
.badge-tile {
  width: 38px; height: 38px;
  background: var(--surface-2);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.badge-tile.earned { background: var(--accent-bg); }
.impact-line {
  font-size: 12px;
  color: var(--text-2);
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.impact-line:last-child { border: 0; padding-bottom: 0; }
.impact-line strong { color: var(--text); font-weight: 500; }

/* JOBS */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
}
.chip:hover { background: var(--surface-2); }
.chip.active { background: var(--text); color: white; border-color: var(--text); }
.jobs-table {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.table-head {
  display: grid;
  grid-template-columns: 80px 1.4fr 120px 90px 80px 80px;
  gap: 12px;
  padding: 12px 18px;
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.table-row {
  display: grid;
  grid-template-columns: 80px 1.4fr 120px 90px 80px 80px;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  cursor: pointer;
  transition: background 0.1s;
}
.table-row:hover { background: var(--surface-2); }
.table-row:last-child { border-bottom: 0; }
.job-id { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text-2); }
.job-name { font-size: 13px; font-weight: 500; }
.job-agent { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.sla-warn { color: var(--warn); font-weight: 500; }
.sla-danger { color: var(--danger); font-weight: 500; }
.elapsed { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text-2); }

/* JOB DETAIL */
.detail-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
}
.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}
.detail-header {
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.detail-title {
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.3px;
  margin-bottom: 4px;
}
.detail-sub { font-size: 12px; color: var(--text-2); }
.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-top: 14px;
}
.meta-item {}
.meta-label { font-size: 10px; color: var(--text-3); letter-spacing: 0.3px; margin-bottom: 3px; }
.meta-value { font-size: 13px; font-weight: 500; }

/* AGENTS */
.agents-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
}
.agent-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.agent-card.alert {
  border-color: rgba(4, 146, 235,0.4);
  background: linear-gradient(180deg, var(--accent-bg) 0%, var(--surface) 60%);
}
.agent-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.agent-icon {
  width: 34px; height: 34px;
  background: var(--surface-2);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}
.agent-name { font-size: 13px; font-weight: 500; }
.agent-status { font-size: 11px; color: var(--success); margin-top: 2px; }
.agent-status.working { color: var(--accent); }
.agent-tasks-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-3);
  margin-top: 4px;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface-2);
  transition: all 0.15s;
}
.agent-tasks-link:hover { background: var(--accent-soft); color: var(--accent); }
.agent-tasks-link .atl-pending { color: var(--accent); font-weight: 500; }
.agent-tasks-link .atl-arrow { font-size: 10px; opacity: 0.5; }
.agent-tasks-link:hover .atl-arrow { opacity: 1; }
.finding { font-size: 12px; color: var(--text-2); padding: 4px 0; display: flex; align-items: flex-start; gap: 7px; line-height: 1.5; }
.f-check { color: var(--success); flex-shrink: 0; }
.f-warn { color: var(--warn); flex-shrink: 0; }
.f-alert { color: var(--danger); flex-shrink: 0; }

/* CREDIT NOTE */
.credit-note {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-top: 20px;
  overflow: hidden;
}
.credit-note-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.credit-note-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.credit-note-title { font-size: 13px; font-weight: 600; }
.credit-note-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
}
.credit-note-badge.draft { background: var(--accent-soft); color: var(--accent); }
.credit-note-badge.ready { background: var(--success-soft); color: var(--success); }
.credit-note-badge.sent { background: var(--purple-soft); color: var(--purple); }
.credit-note-actions {
  display: flex;
  gap: 6px;
}
.cn-btn {
  font-size: 11px;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  transition: all 0.15s;
}
.cn-btn:hover { border-color: var(--border-2); background: var(--surface-2); }
.cn-btn.primary { background: var(--text); color: var(--surface); border-color: var(--text); }
.cn-btn.primary:hover { opacity: 0.85; }
.credit-note-body { padding: 18px; }
.cn-section { margin-bottom: 16px; }
.cn-section:last-child { margin-bottom: 0; }
.cn-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-3);
  margin-bottom: 6px;
}
.cn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 20px;
}
.cn-field { font-size: 12px; }
.cn-field-label { color: var(--text-3); font-size: 11px; }
.cn-field-value { color: var(--text); font-weight: 500; }
.cn-findings {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cn-finding-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.5;
}
.cn-finding-icon { flex-shrink: 0; }
.cn-risk-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cn-risk-flag {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 500;
}
.cn-risk-flag.clear { background: var(--success-soft); color: var(--success); }
.cn-risk-flag.warn { background: var(--warn-soft); color: var(--warn); }
.cn-risk-flag.danger { background: var(--danger-soft); color: var(--danger); }
.cn-risk-flag.info { background: var(--info-soft); color: var(--info); }
.cn-editable {
  width: 100%;
  min-height: 80px;
  padding: 10px 12px;
  border: 1px dashed var(--border-2);
  border-radius: 8px;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
  background: var(--surface);
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
}
.cn-editable:focus { border-color: var(--accent); border-style: solid; }
.cn-editable-hint {
  font-size: 10px;
  color: var(--text-3);
  margin-top: 4px;
  font-style: italic;
}
.cn-divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}

/* DECISIONS PAGE */
.decision-list { display: flex; flex-direction: column; gap: 16px; }
.decision-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: box-shadow 0.15s;
}
.decision-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.04); }
.decision-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  cursor: pointer;
  border-bottom: 1px solid transparent;
  transition: background 0.15s;
}
.decision-card-head:hover { background: var(--surface-2); }
.decision-card.open .decision-card-head { border-bottom-color: var(--border); background: var(--surface-2); }
.dc-left { display: flex; align-items: center; gap: 12px; }
.dc-icon { font-size: 15px; }
.dc-borrower { font-size: 13px; font-weight: 600; }
.dc-case-id { font-size: 11px; color: var(--text-3); font-family: 'JetBrains Mono', monospace; }
.dc-stage { font-size: 11px; padding: 2px 8px; border-radius: 4px; font-weight: 500; }
.dc-stage.origination { background: var(--info-soft); color: var(--info); }
.dc-stage.drawdown { background: var(--warn-soft); color: var(--warn); }
.dc-stage.repayment { background: var(--success-soft); color: var(--success); }
.dc-stage.overdue { background: var(--danger-soft); color: var(--danger); }
.dc-right { display: flex; align-items: center; gap: 10px; }
.dc-chevron {
  font-size: 12px;
  color: var(--text-3);
  transition: transform 0.2s;
}
.decision-card.open .dc-chevron { transform: rotate(90deg); }
.decision-card-body {
  display: none;
  padding: 0;
}
.decision-card.open .decision-card-body { display: block; }
.dc-content { padding: 18px; }
.dc-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 900px) { .dc-two-col { grid-template-columns: 1fr; } }

/* ACTIVITY TRAIL */
.activity-trail {
  padding: 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.activity-trail-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-3);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.at-list { display: flex; flex-direction: column; gap: 0; }
.at-item {
  display: flex;
  gap: 12px;
  padding: 6px 0;
  font-size: 12px;
  line-height: 1.5;
  position: relative;
}
.at-item::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 22px;
  bottom: -6px;
  width: 1px;
  background: var(--border);
}
.at-item:last-child::before { display: none; }
.at-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 10px;
  margin-top: 1px;
}
.at-dot.agent { background: var(--info-soft); color: var(--info); }
.at-dot.human { background: var(--accent-soft); color: var(--accent); }
.at-dot.review { background: var(--purple-soft); color: var(--purple); }
.at-dot.system { background: var(--surface); border: 1px solid var(--border); color: var(--text-3); }
.at-dot.danger { background: var(--danger-soft); color: var(--danger); }
.at-body { flex: 1; }
.at-action { color: var(--text); }
.at-action strong { font-weight: 500; }
.at-meta { color: var(--text-3); font-size: 11px; }
.at-tag {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 500;
  margin-left: 4px;
}
.at-tag.agent-tag { background: var(--info-soft); color: var(--info); }
.at-tag.human-tag { background: var(--accent-soft); color: var(--accent); }
.at-tag.review-tag { background: var(--purple-soft); color: var(--purple); }

/* DOCUMENTS CARD */
.docs-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-top: 16px;
}
.docs-card-title {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.docs-card-count {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 400;
}
.doc-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 2px;
}
.doc-row:hover { background: var(--surface-2); }
.doc-row-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.doc-row-info { flex: 1; min-width: 0; }
.doc-row-name { font-size: 12px; font-weight: 500; color: var(--text); }
.doc-row-meta { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.doc-row-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.doc-row-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}
.doc-row-badge.extracted { background: var(--success-soft); color: var(--success); }
.doc-row-badge.flagged { background: var(--danger-soft); color: var(--danger); }
.doc-row-badge.verified { background: var(--info-soft); color: var(--info); }
.doc-row-open {
  font-size: 11px;
  color: var(--accent);
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.15s;
}
.doc-row:hover .doc-row-open { opacity: 1; }

/* DOCUMENTS LIST PAGE */
.docs-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 12px;
  overflow: hidden;
}
.docs-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  cursor: pointer;
  gap: 12px;
}
.docs-group-head:hover { background: var(--surface-2); }
.dg-left { display: flex; align-items: center; gap: 10px; }
.dg-case-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: 4px;
}
.dg-borrower { font-size: 13px; font-weight: 500; color: var(--text); }
.dg-stage {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--text-2);
}
.dg-count { font-size: 11px; color: var(--text-3); font-family: 'JetBrains Mono', monospace; }
.dg-chevron {
  font-size: 11px;
  color: var(--text-3);
  transition: transform 0.2s;
}
.docs-group.open .dg-chevron { transform: rotate(90deg); }
.docs-group-body {
  display: none;
  border-top: 1px solid var(--border);
}
.docs-group.open .docs-group-body { display: block; }
.dg-doc-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px 10px 46px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid var(--border);
}
.dg-doc-row:last-child { border-bottom: none; }
.dg-doc-row:hover { background: var(--surface-2); }
.dg-doc-icon { font-size: 14px; flex-shrink: 0; }
.dg-doc-info { flex: 1; min-width: 0; }
.dg-doc-name { font-size: 12px; font-weight: 500; color: var(--text); }
.dg-doc-meta { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.dg-doc-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.dg-doc-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}
.dg-doc-badge.extracted { background: var(--success-soft); color: var(--success); }
.dg-doc-badge.flagged { background: var(--danger-soft); color: var(--danger); }
.dg-doc-badge.verified { background: var(--info-soft); color: var(--info); }
.dg-doc-badge.pending { background: var(--warn-soft); color: var(--warn); }
.dg-doc-fields {
  font-size: 10px;
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
}
.dg-doc-open {
  font-size: 11px;
  color: var(--accent);
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.15s;
}
.dg-doc-row:hover .dg-doc-open { opacity: 1; }

/* DOCUMENT DETAIL PAGE */
.doc-detail-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 16px;
}
.doc-detail-left {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  min-height: 500px;
}
.doc-detail-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.doc-preview-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.doc-preview-body {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  line-height: 1.7;
  color: var(--text-2);
  white-space: pre-wrap;
}
.doc-preview-body .hl {
  background: #fef3c7;
  padding: 1px 3px;
  border-radius: 2px;
  color: var(--text);
  font-weight: 500;
}
.fields-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}
.fields-card-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.fields-group-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  font-weight: 600;
  margin: 12px 0 6px 0;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.fields-group-label:first-child { border-top: none; margin-top: 0; padding-top: 0; }
.field-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 4px 0;
  gap: 12px;
}
.field-label { font-size: 11px; color: var(--text-3); flex-shrink: 0; }
.field-value {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
}
.field-value.flagged { color: var(--danger); }
.field-confidence {
  font-size: 9px;
  color: var(--success);
  font-family: 'JetBrains Mono', monospace;
}
.insights-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}
.insights-card-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.insight-item {
  display: flex;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.insight-item:last-child { border-bottom: none; }
.insight-icon { font-size: 12px; flex-shrink: 0; margin-top: 1px; }
.insight-body { flex: 1; }
.insight-text { font-size: 12px; color: var(--text); line-height: 1.5; }
.insight-agent { font-size: 10px; color: var(--text-3); margin-top: 2px; }
.doc-back-btn {
  font-size: 12px;
  color: var(--text-2);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 4px;
}
.doc-back-btn:hover { color: var(--accent); }

/* TIMELINE */
.timeline-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}
.timeline-title { font-size: 13px; font-weight: 500; margin-bottom: 14px; }
.tl-item {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  position: relative;
}
.tl-item:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 9px;
  top: 28px;
  bottom: -4px;
  width: 1px;
  background: var(--border);
}
.tl-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  flex-shrink: 0;
}
.tl-dot.done { background: var(--success-soft); color: var(--success); }
.tl-dot.active { background: var(--accent-bg); color: var(--accent); animation: pulse 2s infinite; }
.tl-dot.pending { background: var(--surface-2); color: var(--text-3); }
.tl-content {}
.tl-label { font-size: 12px; font-weight: 500; color: var(--text); }
.tl-time { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* removed: leaderboard, badges (gamification) */

/* AGENT DETAIL */
.agent-detail-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  align-items: start;
}
.agent-left-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}
.agent-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.agent-sidebar .agent-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.agent-sidebar .agent-profile .agent-icon-lg {
  width: 44px; height: 44px;
  background: var(--surface-2);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.agent-sidebar .agent-profile-name { font-size: 14px; font-weight: 500; }
.agent-sidebar .agent-profile-version { font-size: 11px; color: var(--text-3); font-family: 'JetBrains Mono', monospace; }
.agent-stat-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.agent-stat-row:last-child { border-bottom: 0; }
.agent-stat-label { color: var(--text-2); }
.agent-stat-value { font-weight: 500; font-family: 'JetBrains Mono', monospace; }

.trace-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.trace-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.trace-header-title { font-size: 14px; font-weight: 500; }
.trace-tabs {
  display: flex;
  gap: 2px;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.trace-tab {
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: transparent;
  border-top: 0; border-left: 0; border-right: 0;
  font-family: inherit;
}
.trace-tab.active { color: var(--text); border-bottom-color: var(--text); font-weight: 500; background: var(--surface); }
.trace-body { padding: 22px; }

/* Reasoning steps */
.reasoning-step {
  position: relative;
  padding-left: 28px;
  padding-bottom: 24px;
  border-left: 1px solid var(--border);
  margin-left: 8px;
}
.reasoning-step:last-child { border-left: 0; padding-bottom: 0; }
.reasoning-step::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border-2);
}
.reasoning-step.complete::before { background: var(--success-soft); border-color: var(--success); }
.reasoning-step.active::before { background: var(--accent-bg); border-color: var(--accent); animation: pulse 2s infinite; }
.reasoning-step.flagged::before { background: var(--danger-soft); border-color: var(--danger); }
.step-label {
  font-size: 10px;
  color: var(--text-3);
  letter-spacing: 0.3px;
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: 4px;
}
.step-title { font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.step-body { font-size: 12px; color: var(--text-2); line-height: 1.7; }

/* Document evidence blocks */
.doc-evidence {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 10px;
  overflow: hidden;
}
.doc-evidence-head {
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-3);
}
.doc-evidence-head .doc-type {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: 'JetBrains Mono', monospace;
}
.doc-evidence-body {
  padding: 12px 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  line-height: 1.8;
  color: var(--text-2);
}
.doc-evidence-body .highlight {
  background: #FDE6B8;
  color: #6B3A06;
  padding: 1px 4px;
  border-radius: 3px;
}
.doc-evidence-body .extracted {
  background: var(--success-soft);
  color: var(--success);
  padding: 1px 4px;
  border-radius: 3px;
}
.doc-evidence-body .flagged-text {
  background: var(--danger-soft);
  color: var(--danger);
  padding: 1px 4px;
  border-radius: 3px;
}

/* Confidence meter */
.confidence-meter {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  font-size: 11px;
}
.conf-bar {
  flex: 1;
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
  max-width: 120px;
}
.conf-fill { height: 100%; border-radius: 3px; }
.conf-fill.high { background: var(--success); }
.conf-fill.mid { background: var(--warn); }
.conf-fill.low { background: var(--danger); }

/* Conclusion block */
.conclusion-block {
  background: var(--surface-2);
  border-left: 3px solid var(--text);
  border-radius: 0 10px 10px 0;
  padding: 14px 18px;
  margin-top: 12px;
}
.conclusion-label { font-size: 10px; color: var(--text-3); letter-spacing: 0.3px; margin-bottom: 6px; }
.conclusion-text { font-size: 13px; font-weight: 500; line-height: 1.5; }
.conclusion-sub { font-size: 12px; color: var(--text-2); margin-top: 6px; line-height: 1.6; }

/* Back nav */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  margin-bottom: 20px;
  padding: 6px 0;
}
.back-link:hover { color: var(--text); }

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 16px;
}
.breadcrumb a, .breadcrumb span.bc-link {
  color: var(--text-2);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s;
}
.breadcrumb a:hover, .breadcrumb span.bc-link:hover { color: var(--accent); }
.breadcrumb .bc-sep { color: var(--border-2); font-size: 10px; }
.breadcrumb .bc-current { color: var(--text); font-weight: 500; }

/* HUMAN TASKS BLOCK */
.human-tasks-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.human-tasks-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.human-tasks-header-title {
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.human-tasks-header-title .ht-icon {
  font-size: 12px;
}
.human-tasks-count {
  font-size: 10px;
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
}
.ht-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--surface-2);
}
.ht-item:last-child { border-bottom: 0; }
.ht-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.ht-item-title {
  font-size: 12px;
  font-weight: 500;
}
.ht-item-desc {
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.5;
  margin-top: 3px;
}
.ht-item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-size: 10px;
}
.ht-meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  background: var(--surface-2);
  border-radius: 4px;
  color: var(--text-2);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
}
.ht-meta-chip.done { background: var(--success-soft); color: var(--success); }
.ht-meta-chip.active { background: var(--accent-soft); color: var(--accent); }
.ht-meta-chip.pending { background: var(--surface-2); color: var(--text-3); }
.ht-status-pill {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
}
.ht-status-pill.done { background: var(--success-soft); color: var(--success); }
.ht-status-pill.active { background: var(--accent-soft); color: var(--accent); }
.ht-status-pill.pending { background: var(--surface-2); color: var(--text-3); }
.ht-item-docs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

/* DOCUMENT VIEWER OVERLAY */
.doc-viewer-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(24,24,22,0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.doc-viewer-overlay.open { display: flex; }
.doc-viewer {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 920px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0,0,0,0.18);
  overflow: hidden;
}
.doc-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.doc-viewer-title {
  font-size: 14px;
  font-weight: 500;
}
.doc-viewer-meta {
  font-size: 11px;
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
  margin-top: 3px;
}
.doc-viewer-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-2);
  transition: all 0.15s;
}
.doc-viewer-close:hover { background: var(--border); color: var(--text); }
.doc-viewer-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}
.doc-toolbar-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}
.doc-toolbar-pill.info { background: var(--info-soft); color: var(--info); }
.doc-toolbar-pill.success { background: var(--success-soft); color: var(--success); }
.doc-toolbar-pill.danger { background: var(--danger-soft); color: var(--danger); }
.doc-viewer-body {
  overflow-y: auto;
  padding: 28px;
  flex: 1;
}
.doc-page {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 32px;
  font-size: 13px;
  line-height: 1.9;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.doc-page .doc-title-block {
  text-align: center;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.doc-page .doc-title-block h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}
.doc-page .doc-title-block .doc-subtitle {
  font-size: 12px;
  color: var(--text-2);
}
.doc-page .doc-field-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--surface-2);
}
.doc-page .doc-field-label {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 500;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.doc-page .doc-field-value {
  font-size: 13px;
  color: var(--text);
}
/* Highlight styles for extracted fields */
.hl-extracted {
  background: #D1FAE5;
  border: 1px solid #6EE7B7;
  border-radius: 3px;
  padding: 1px 4px;
  font-weight: 500;
  position: relative;
}
.hl-extracted::after {
  content: '✓ extracted';
  position: absolute;
  top: -18px;
  left: 0;
  font-size: 9px;
  color: var(--success);
  font-weight: 500;
  white-space: nowrap;
  letter-spacing: 0.3px;
}
.hl-flagged {
  background: #FDE7EC;
  border: 1px solid #FBBCD0;
  border-radius: 3px;
  padding: 1px 4px;
  font-weight: 500;
  position: relative;
}
.hl-flagged::after {
  content: '⚠ flagged';
  position: absolute;
  top: -18px;
  left: 0;
  font-size: 9px;
  color: var(--danger);
  font-weight: 500;
  white-space: nowrap;
}
.hl-used {
  background: #FEF3E2;
  border: 1px solid #FCD34D;
  border-radius: 3px;
  padding: 1px 4px;
  font-weight: 500;
}
.doc-page .section-divider {
  margin: 20px 0;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.doc-page table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 12px;
}
.doc-page table th {
  text-align: left;
  padding: 8px 10px;
  background: var(--surface-2);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
}
.doc-page table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--surface-2);
}
.doc-page table tr.hl-row {
  background: #FDE7EC;
}
.doc-page .stamp {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.doc-page .stamp.resolved { background: var(--success-soft); color: var(--success); }
.doc-page .stamp.active { background: var(--danger-soft); color: var(--danger); }
.doc-page .stamp.discharged { background: var(--info-soft); color: var(--info); }

/* Clickable source doc links */
.doc-source-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--info);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  font-weight: 500;
}
.doc-source-link:hover {
  background: var(--info-soft);
  border-color: var(--info);
}
.doc-evidence-head .doc-source-link {
  margin-left: auto;
}
/* Task card document links */
.task-docs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--surface-2);
}
.task-doc-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}
.task-doc-link:hover {
  background: var(--info-soft);
  border-color: var(--info);
  color: var(--info);
}
.task-doc-link .doc-hl-count {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 99px;
  font-weight: 500;
}

/* PROTO BADGE */
.proto-badge {
  position: fixed;
  bottom: 22px;
  left: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px 6px 8px;
  font-size: 11px;
  color: var(--text-2);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 90;
  box-shadow: 0 4px 14px rgba(0,0,0,0.06);
}
.proto-badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s infinite;
}

/* ===== USER TOGGLE ===== */
/* ===== VIEW-AS IMPERSONATION (demo-only, admin-real-role gated) =====
   Pill in the topbar next to the user-menu lets an admin shadow another
   role for the session. Persistent banner above the topnav makes it
   impossible to forget you're impersonating. */
.view-as-banner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  background: var(--warn-soft); color: var(--warn);
  padding: 6px 16px;
  font-size: 12px;
  border-bottom: 1px solid var(--warn);
  position: sticky; top: 0; z-index: 60;
}
.view-as-banner strong { font-weight: 600; }
.view-as-banner-exit {
  background: transparent; border: 1px solid var(--warn);
  color: var(--warn); border-radius: 5px;
  padding: 3px 9px; font-size: 11.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.view-as-banner-exit:hover { background: var(--warn); color: #fff; }

.view-as-menu { position: relative; margin-right: 4px; }
.view-as-trigger {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  font-family: inherit; font-size: 11.5px;
  background: var(--surface-2); color: var(--text-2);
  border: 1px dashed var(--border);
  border-radius: 6px;
  cursor: pointer;
}
.view-as-trigger:hover { color: var(--accent); border-color: var(--accent); }
.view-as-trigger-label {
  text-transform: uppercase; letter-spacing: 0.4px;
  font-size: 9.5px; color: var(--text-3); font-weight: 600;
}
.view-as-trigger-current { font-weight: 600; color: var(--text); }
.view-as-trigger-chevron { font-size: 10px; color: var(--text-3); }
.view-as-dropdown {
  position: absolute; right: 0; top: calc(100% + 4px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  min-width: 220px;
  padding: 6px 0;
  display: none;
  z-index: 80;
}
.view-as-menu.open .view-as-dropdown { display: block; }
.view-as-dropdown-head {
  padding: 8px 14px 4px;
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-3); font-weight: 700;
}
.view-as-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 7px 14px;
  background: transparent; border: 0;
  font-family: inherit; font-size: 12.5px; color: var(--text);
  cursor: pointer; text-align: left;
}
.view-as-item:hover { background: var(--accent-bg); color: var(--accent); }
.view-as-item.active { color: var(--accent); font-weight: 600; }
.view-as-item.active .view-as-item-dot {
  background: var(--accent); border-color: var(--accent);
}
.view-as-item-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--text-3);
  flex-shrink: 0;
}
.view-as-item-label { flex: 1; }
.view-as-item-meta { font-size: 10.5px; color: var(--text-3); }
.view-as-divider {
  margin: 5px 0;
  border-top: 1px solid var(--border-light);
}

/* USER MENU */
.user-menu {
  position: relative;
}
.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 10px 5px 5px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  transition: all 0.15s;
}
.user-menu-trigger:hover {
  background: var(--surface-2);
  border-color: var(--border);
}
.user-menu-trigger .avatar {
  width: 30px; height: 30px;
  font-size: 11px;
}
.user-menu-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.3;
}
.user-menu-name {
  font-weight: 500;
  font-size: 13px;
}
.user-menu-role {
  font-size: 11px;
  color: var(--text-3);
}
.user-menu-chevron {
  font-size: 10px;
  color: var(--text-3);
  margin-left: 2px;
  transition: transform 0.2s;
}
.user-menu.open .user-menu-chevron { transform: rotate(180deg); }
.user-menu-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  z-index: 100;
  overflow: hidden;
}
.user-menu.open .user-menu-dropdown { display: block; }
.user-menu-header {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.user-menu-header-name {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 1px;
}
.user-menu-header-email {
  font-size: 11px;
  color: var(--text-3);
}
.user-menu-items {
  padding: 6px;
}
.user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  transition: background 0.1s;
  text-align: left;
}
.user-menu-item:hover { background: var(--surface-2); }
.user-menu-item-icon {
  width: 18px;
  text-align: center;
  font-size: 14px;
  flex-shrink: 0;
}
.user-menu-item-label { flex: 1; }
.user-menu-item-hint {
  font-size: 11px;
  color: var(--text-3);
}
/* Right-aligned subtitle inside a user-menu-item — used by the
   "What's new · v0.1.0 · ceb6df7" version chip. */
.user-menu-item-sub {
  font-size: 10.5px;
  color: var(--text-3);
}
.user-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 6px;
}
.user-menu-item.switch-role {
  color: var(--accent);
}
.user-menu-item.switch-role:hover {
  background: var(--accent-soft);
}
.user-menu-item.logout { color: var(--text-2); }
.user-menu-item.logout:hover { background: var(--surface-2); }
.avatar.ew-avatar {
  background: var(--info-soft);
  color: var(--info);
}

/* ===== EDWARD ACTIONS ===== */
.edward-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.edward-actions .ea-btn {
  font-size: 12px;
  padding: 8px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  transition: all 0.15s;
}
.edward-actions .ea-btn:hover { opacity: 0.85; }
.edward-actions .ea-btn.reject {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-soft);
}
.edward-actions .ea-btn.sendback {
  border-color: var(--warn);
  color: var(--warn);
  background: var(--warn-soft);
}
.edward-actions .ea-btn.approve {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.edward-actions .ea-spacer { flex: 1; }

/* ===== EDWARD STATUS BANNER ===== */
.edward-status-banner {
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}
.edward-status-banner.approved {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid rgba(21,96,74,0.2);
}
.edward-status-banner.rejected {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(159,18,57,0.2);
}
.edward-status-banner.sentback {
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid rgba(180,83,9,0.2);
}

/* ===== SENDBACK PANEL ===== */
.sendback-panel {
  margin-top: 10px;
  padding: 14px;
  background: var(--surface-2);
  border-radius: 10px;
  border: 1px solid var(--border);
  display: none;
}
.sendback-panel.open { display: block; }
.sendback-panel label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}
.sendback-panel textarea {
  width: 100%;
  min-height: 60px;
  padding: 10px 12px;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
  background: var(--surface);
  resize: vertical;
  outline: none;
}
.sendback-panel textarea:focus { border-color: var(--accent); }
.sendback-panel .sendback-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  justify-content: flex-end;
}

/* ===== MODAL OVERLAY ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-overlay.open { display: flex; }

/* ===== LETTER MODAL ===== */
.letter-modal {
  background: var(--surface);
  border-radius: 14px;
  max-width: 680px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.letter-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}
.letter-modal-head h2 {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.3px;
}
.letter-modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-3);
  padding: 4px;
}
.letter-modal-close:hover { color: var(--text); }
.letter-body {
  padding: 28px 32px;
  font-size: 13px;
  line-height: 1.8;
  color: var(--text-2);
}
.letter-body .letter-header {
  text-align: right;
  margin-bottom: 24px;
  font-size: 12px;
  color: var(--text-3);
}
.letter-body .letter-recipient {
  margin-bottom: 20px;
}
.letter-body .letter-subject {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  text-decoration: underline;
}
.letter-body .letter-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 12px;
}
.letter-body .letter-table td {
  padding: 6px 12px;
  border: 1px solid var(--border);
}
.letter-body .letter-table td:first-child {
  font-weight: 500;
  color: var(--text);
  width: 180px;
  background: var(--surface-2);
}
.letter-body .letter-sign {
  margin-top: 28px;
  padding-top: 16px;
}
.letter-modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
}
.letter-modal-foot .lm-btn {
  font-size: 12px;
  padding: 8px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  transition: all 0.15s;
}
.letter-modal-foot .lm-btn:hover { background: var(--surface-2); }
.letter-modal-foot .lm-btn.primary {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}
.letter-modal-foot .lm-btn.primary:hover { opacity: 0.85; }

/* ===== EMAIL MODAL ===== */
.email-modal {
  background: var(--surface);
  border-radius: 14px;
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.email-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
.email-modal-head h2 {
  font-size: 15px;
  font-weight: 500;
}
.email-modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-3);
}
.email-modal-close:hover { color: var(--text); }
.email-fields {
  padding: 16px 24px 0;
}
.email-field {
  display: flex;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.email-field-label {
  width: 60px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}
.email-field-input {
  flex: 1;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: transparent;
}
.email-body-wrap {
  padding: 0 24px;
}
.email-body {
  width: 100%;
  min-height: 180px;
  padding: 14px 0;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  background: transparent;
  resize: vertical;
}
.email-attachments {
  padding: 0 24px 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.attachment-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-2);
}
.attachment-badge .att-icon {
  color: var(--danger);
  font-size: 13px;
}
.email-modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
}
.email-modal-foot .em-btn {
  font-size: 12px;
  padding: 8px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  transition: all 0.15s;
}
.email-modal-foot .em-btn:hover { background: var(--surface-2); }
.email-modal-foot .em-btn.send {
  background: var(--info);
  color: #fff;
  border-color: var(--info);
}
.email-modal-foot .em-btn.send:hover { opacity: 0.85; }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--text);
  color: var(--surface);
  padding: 12px 22px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  z-index: 300;
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.3s ease;
  pointer-events: none;
}
.toast.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ===== USER VISIBILITY ===== */
body.user-edward [data-user="felice"] { display: none !important; }
body.user-felice [data-user="edward"] { display: none !important; }

/* Edward view: read-only recommendation */
body.user-edward .cn-editable {
  border-style: solid;
  border-color: var(--border);
  background: var(--surface-2);
  pointer-events: none;
  color: var(--text-2);
}

/* Edward (Credit Officer): case-detail edit controls are read-only, but the
   Decisions workspace IS his job — Approve / Reject / Send-back (`.cn-btn`)
   must stay visible. Removing `.cn-btn` here fixes the decision buttons being
   hidden for credit officers (the gating already controls which show). */
body.user-edward .task-action-btn,
body.user-edward .inline-approve-btn {
  display: none !important;
}
body.user-edward .case-read-only-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  margin-bottom: 20px;
  background: var(--info-soft);
  color: var(--info);
  border: 1px solid rgba(30, 58, 138, 0.15);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
}
body.user-felice .case-read-only-banner { display: none; }

/* TASK CARD ANIMATIONS */
@keyframes taskCompleteFlash {
  0% { background: var(--surface); }
  30% { background: var(--success-soft); box-shadow: 0 0 0 6px rgba(21, 96, 74, 0.12); }
  100% { background: var(--success-soft); }
}
@keyframes taskCompleteCheck {
  0% { opacity: 0; transform: scale(0.5); }
  50% { opacity: 1; transform: scale(1.1); }
  100% { opacity: 1; transform: scale(1); }
}
.task-card.task-complete-flash,
.decision-card.decision-complete-flash {
  animation: taskCompleteFlash 0.5s ease forwards;
  position: relative;
}
.task-card.task-complete-flash::after,
.decision-card.decision-complete-flash::after {
  content: '\2713';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  font-size: 64px;
  color: var(--success);
  opacity: 0;
  animation: taskCompleteCheck 0.4s ease 0.15s forwards;
  pointer-events: none;
  z-index: 10;
}
.decision-card.decision-complete-flash.reject-flash::after {
  content: '\2717';
  color: var(--danger);
}
.decision-card.decision-complete-flash.sendback-flash::after {
  content: '\21A9';
  color: var(--accent);
}
.decision-card.decision-completing {
  transition: max-height 0.5s ease, opacity 0.4s ease, padding 0.4s ease, margin 0.4s ease, border-width 0.4s ease;
  max-height: 0 !important;
  opacity: 0;
  padding: 0 !important;
  margin: 0 !important;
  border-width: 0 !important;
  overflow: hidden;
}
.task-card.completing {
  transition: max-height 0.4s ease, opacity 0.4s ease, padding 0.4s ease, margin 0.4s ease, border-width 0.4s ease;
  max-height: 0 !important;
  opacity: 0;
  padding: 0 24px;
  margin: 0;
  border-width: 0;
  overflow: hidden;
}
.task-refine-panel {
  margin-top: 10px;
  padding: 14px;
  background: var(--surface-2);
  border-radius: 10px;
  border: 1px solid var(--border);
  display: none;
}
.task-refine-panel.open {
  display: block;
  animation: slideDown 0.25s ease;
}
@keyframes slideDown {
  from { opacity: 0; max-height: 0; padding: 0 14px; }
  to { opacity: 1; max-height: 200px; padding: 14px; }
}
.task-refine-panel label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}
.task-refine-panel textarea {
  width: 100%;
  min-height: 60px;
  padding: 10px 12px;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
  background: var(--surface);
  resize: vertical;
  outline: none;
}
.task-refine-panel textarea:focus { border-color: var(--accent); }
.task-refine-panel .refine-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  justify-content: flex-end;
}
.pill-refining {
  background: var(--purple-soft);
  color: var(--purple);
}
.task-card-enter {
  animation: taskCardEnter 0.35s ease;
}
@keyframes taskCardEnter {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}
.queue-item-enter {
  animation: queueItemEnter 0.3s ease;
}
@keyframes queueItemEnter {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* PDF.js canvas renderer + rubber-band linking */
.doc-realdoc-container {
  width: 100%;
  max-height: 760px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
}
.pdf-loading {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-3);
  font-size: 12px;
}
.pdf-page-wrap {
  position: relative;
  margin: 0 auto 14px;
  background: white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  display: block;
  line-height: 0;
}
.pdf-page-wrap:last-child { margin-bottom: 0; }
.pdf-page-wrap canvas {
  display: block;
  width: 100% !important;
  height: auto !important;
}
.pdf-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.pdf-bbox {
  position: absolute;
  border: 1.5px solid transparent;
  border-radius: 3px;
  background: transparent;
  pointer-events: auto;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, box-shadow 0.18s;
}
.pdf-bbox:hover {
  background: rgba(4,146,235,0.12);
  border-color: rgba(4,146,235,0.45);
}
.pdf-bbox.linked {
  background: rgba(4,146,235,0.22);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(4,146,235,0.18);
  animation: bboxPulse 1.4s ease-in-out infinite;
}
@keyframes bboxPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(4,146,235,0.18); }
  50%      { box-shadow: 0 0 0 7px rgba(4,146,235,0.28); }
}
.field-item[data-link-id] { cursor: pointer; transition: background 0.15s; border-radius: 5px; }
.field-item[data-link-id]:hover { background: var(--accent-soft); }
.field-item.linked {
  background: var(--accent-soft);
  outline: 1px solid var(--accent);
  outline-offset: 0;
}
.field-item[data-link-id] .field-label::after {
  content: '↔';
  margin-left: 5px;
  color: var(--accent);
  font-size: 10px;
  opacity: 0.55;
}

/* Language toggle for extracted fields */
.lang-toggle {
  display: inline-flex;
  margin-left: auto;
  background: var(--surface-2);
  border-radius: 7px;
  padding: 2px;
  gap: 0;
}
.lang-toggle button {
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 5px;
  color: var(--text-3);
  cursor: pointer;
  transition: all 0.15s;
}
.lang-toggle button:hover { color: var(--text); }
.lang-toggle button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.field-value { word-break: break-word; }

/* Real document embed (PDF / image) for side-by-side viewer */
.doc-realdoc-frame {
  width: 100%;
  height: 760px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}
.doc-realdoc-img {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: block;
}
.doc-realdoc-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  font-size: 11px;
}
.doc-realdoc-actions a {
  color: var(--text-2);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  background: var(--surface);
}
.doc-realdoc-actions a:hover { color: var(--text); border-color: var(--text-3); }
.doc-realdoc-meta {
  font-size: 10px;
  color: var(--text-3);
  margin-left: auto;
  align-self: center;
  font-family: 'JetBrains Mono', monospace;
}

/* Data source flag chip on doc rows */
.dg-doc-source {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  vertical-align: middle;
  font-family: inherit;
  border: 1px solid transparent;
}
.dg-doc-source.borrower { background: var(--accent-soft); color: var(--accent); border-color: rgba(4, 146, 235,0.18); }
.dg-doc-source.third-party { background: var(--info-soft); color: var(--info); border-color: rgba(30, 58, 138, 0.15); }
.dg-doc-source.internal { background: var(--purple-soft); color: var(--purple); border-color: rgba(91, 33, 182, 0.15); }
.dg-doc-source.compiled { background: var(--success-soft); color: var(--success); border-color: rgba(21, 96, 74, 0.15); }

/* Agent rerun button + streaming pane */
.agent-rerun-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}
.agent-rerun-btn:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--text-3);
}
.agent-rerun-btn:disabled { cursor: not-allowed; opacity: 0.55; }
.agent-rerun-btn.running {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
  opacity: 1;
}
.agent-rerun-btn.stop {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger);
  opacity: 1;
  cursor: pointer;
}
.agent-stream-pane {
  margin-bottom: 16px;
  padding: 12px 14px 10px;
  background: linear-gradient(180deg, var(--accent-bg) 0%, var(--surface) 100%);
  border: 1px solid var(--accent);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(4, 146, 235,0.08);
}
.agent-stream-pane-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
}
.agent-stream-pulse {
  width: 7px; height: 7px;
  background: var(--accent);
  border-radius: 50%;
  animation: streamPulse 1.1s ease-in-out infinite;
}
@keyframes streamPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.55); }
}
.agent-stream-pane-head .asp-elapsed {
  margin-left: auto;
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}
.agent-stream-body {
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}
.agent-stream-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 3px 0;
  font-size: 12px;
  color: var(--text-2);
  opacity: 0;
  animation: streamLineIn 0.28s ease forwards;
}
@keyframes streamLineIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}
.agent-stream-line .asl-time {
  flex-shrink: 0;
  width: 56px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-3);
}
.agent-stream-line .asl-icon { flex-shrink: 0; width: 14px; text-align: center; font-size: 11px; }
.agent-stream-line .asl-text { flex: 1; min-width: 0; }
.agent-stream-line.done { color: var(--text); }
.agent-stream-line.done .asl-icon { color: var(--success); }
.agent-stream-line.flag .asl-icon { color: var(--accent); }
.agent-stream-line.danger .asl-icon { color: var(--danger); }
.agent-stream-line.danger { color: var(--danger); }
.agent-stream-pane.finished {
  border-color: var(--success);
  background: linear-gradient(180deg, var(--success-soft) 0%, var(--surface) 100%);
}
.agent-stream-pane.finished .agent-stream-pane-head { color: var(--success); }
.agent-stream-pane.finished .agent-stream-pulse { background: var(--success); animation: none; }
.reasoning-step.rerun-hidden { display: none !important; }
.reasoning-step.rerun-revealing { animation: stepRevealIn 0.45s ease both; }
@keyframes stepRevealIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== PORTFOLIO WATCH ===== */
.pf-kpi-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.pf-kpi-sub { font-size: 11px; color: var(--text-3); margin-top: 5px; }
.pf-kpi-bar {
  height: 4px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}
.pf-kpi-bar > div { height: 100%; border-radius: 999px; background: var(--accent); }
.pf-layout {
  display: grid;
  grid-template-columns: 1.65fr 1fr;
  gap: 18px;
  align-items: start;
}
.pf-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.pf-panel + .pf-panel { margin-top: 18px; }
.pf-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
}
.pf-panel-title { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.pf-panel-meta { font-size: 11px; color: var(--text-3); }
.pf-filter-row { display: flex; gap: 6px; }
.pf-filter-chip {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-family: inherit;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid transparent;
  cursor: pointer;
}
.pf-filter-chip:hover { color: var(--text); }
.pf-filter-chip.active { background: var(--surface); color: var(--text); border-color: var(--border-2); font-weight: 500; }
.vm-filter-chip {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-family: inherit;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid transparent;
  cursor: pointer;
}
.vm-filter-chip:hover { color: var(--text); }
.vm-filter-chip.active { background: var(--surface); color: var(--text); border-color: var(--border-2); font-weight: 500; }
/* panel tabs */
.pf-panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.pf-panel-tab {
  background: transparent;
  border: 0;
  padding: 11px 18px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  display: flex;
  align-items: center;
  gap: 8px;
}
.pf-panel-tab:hover { color: var(--text-2); }
.pf-panel-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  background: var(--surface);
}
.pf-panel-tab-count {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
}
.pf-panel-tab.active .pf-panel-tab-count {
  background: var(--surface-2);
  color: var(--text-2);
}
.pf-panel-tab-count.danger {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger);
}
/* volume monitor table */
.vm-head, .vm-row {
  display: grid;
  grid-template-columns: 2.6fr 0.9fr 0.9fr 0.9fr 1.6fr 1fr;
  gap: 10px;
  align-items: center;
}
.vm-head {
  padding: 10px 18px;
  background: var(--surface-2);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
}
.vm-row {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.1s;
}
.vm-row:last-child { border-bottom: 0; }
.vm-row:hover { background: var(--surface-2); }
.vm-row.adverse { background: #FEF2F2; }
.vm-row.adverse:hover { background: #FEE2E2; }
.vm-row.critical { background: #FEE2E2; }
.vm-row.critical:hover { background: #FECACA; }
.vm-borrower-name { font-weight: 600; font-size: 12.5px; color: var(--text); }
.vm-borrower-sub { font-size: 10.5px; color: var(--text-3); margin-top: 2px; }
.vm-role-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
}
.vm-role-chip.trader { background: #EEF2FF; color: #4338CA; border-color: #C7D2FE; }
.vm-role-chip.forwarder { background: #ECFDF5; color: #047857; border-color: #A7F3D0; }
.vm-containers-cell { font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 600; color: var(--text); }
.vm-containers-sub { font-size: 10px; color: var(--text-3); margin-top: 2px; font-family: 'JetBrains Mono', monospace; }
.vm-mom {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 5px;
  display: inline-block;
}
.vm-mom.up { background: #ECFDF5; color: #047857; }
.vm-mom.down { background: #FEE2E2; color: #B91C1C; }
.vm-mom.flat { background: var(--surface-2); color: var(--text-3); }
.vm-flag-chip {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  margin-right: 4px;
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.vm-flag-chip.trend { background: #FEE2E2; color: #B91C1C; }
.vm-flag-chip.no-activity { background: #F1F5F9; color: #475569; border: 1px solid #CBD5E1; }
.vm-flag-chip.non-eligible { background: #FEF3E2; color: #92400E; }
.vm-flag-chip.delinquency { background: #7F1D1D; color: #FECACA; }
.vm-flag-chip.in-portfolio { background: var(--accent-soft); color: var(--accent); }
.vm-last { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-3); }
.vm-last-portfolio { color: var(--accent); font-weight: 600; }
.pf-table-head, .pf-row {
  display: grid;
  grid-template-columns: 2.2fr 1.15fr 1.55fr 1.4fr 1fr;
  gap: 12px;
  align-items: center;
}
.pf-table-head {
  padding: 9px 18px;
  font-size: 9.5px;
  letter-spacing: 0.5px;
  color: var(--text-3);
  text-transform: uppercase;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.pf-row {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.13s;
}
.pf-row:last-child { border-bottom: 0; }
.pf-row:hover { background: var(--surface-2); }
.pf-borrower-name { font-size: 13px; font-weight: 500; }
.pf-borrower-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.pf-amount { font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.pf-amount-sub { font-size: 10px; color: var(--text-3); margin-top: 2px; }
.pf-util-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 5px; }
.pf-util-pct { font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 600; }
.pf-util-bar {
  height: 6px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.pf-util-fill { height: 100%; border-radius: 999px; background: var(--success); }
.pf-util-fill.mid { background: var(--accent); }
.pf-util-fill.high { background: var(--danger); }
.pf-vol { display: flex; align-items: center; gap: 9px; }
.pf-spark { display: flex; align-items: flex-end; gap: 2px; height: 26px; }
.pf-spark-bar { width: 5px; background: var(--border-2); border-radius: 1px; }
.pf-spark-bar.last { background: var(--text-2); }
.pf-spark-bar.up { background: var(--success); }
.pf-spark-bar.down { background: var(--danger); }
.pf-vol-meta { font-size: 11px; line-height: 1.4; }
.pf-vol-num { font-weight: 500; }
.pf-trend { font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 600; display: block; margin-top: 1px; }
.pf-trend.up { color: var(--success); }
.pf-trend.down { color: var(--danger); }
.pf-trend.flat { color: var(--text-3); }
.pf-health {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.pf-health.strong { background: var(--success-soft); color: var(--success); }
.pf-health.stable { background: var(--info-soft); color: var(--info); }
.pf-health.monitor { background: var(--accent-bg); color: var(--accent); }
.pf-health.watch { background: var(--warn-soft); color: var(--warn); }
.pf-health.risk { background: var(--danger-soft); color: var(--danger); }
.pf-sig-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 9px 0;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-2);
}
.pf-sig-row:first-child { border-top: 0; }
.pf-sig-row strong { font-weight: 500; color: var(--text); font-size: 12px; font-family: 'JetBrains Mono', monospace; }
.pf-events { max-height: 560px; overflow-y: auto; }
.pf-event {
  display: flex;
  gap: 11px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.13s;
}
.pf-event:last-child { border-bottom: 0; }
.pf-event:hover { background: var(--surface-2); }
.pf-event-icon {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.pf-event-icon.critical { background: var(--danger-soft); }
.pf-event-icon.warning { background: var(--warn-soft); }
.pf-event-icon.positive { background: var(--success-soft); }
.pf-event-icon.info { background: var(--info-soft); }
.pf-event-body { flex: 1; min-width: 0; }
.pf-event-title { font-size: 12px; font-weight: 600; margin-bottom: 3px; }
.pf-event-sev {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 2px 5px;
  border-radius: 4px;
  margin-right: 6px;
}
.pf-event-sev.critical { background: var(--danger-soft); color: var(--danger); }
.pf-event-sev.warning { background: var(--warn-soft); color: var(--warn); }
.pf-event-sev.positive { background: var(--success-soft); color: var(--success); }
.pf-event-sev.info { background: var(--info-soft); color: var(--info); }
.pf-event-desc { font-size: 11px; color: var(--text-2); line-height: 1.55; }
.pf-event-time { font-size: 10px; color: var(--text-3); margin-top: 5px; font-family: 'JetBrains Mono', monospace; }

/* ===== FACILITY DETAIL ===== */
.fd-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}
.fd-head-title { font-size: 22px; font-weight: 500; letter-spacing: -0.5px; }
.fd-head-sub { font-size: 13px; color: var(--text-2); margin-top: 4px; }
.fd-head-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.fd-kpi-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.fd-layout { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; align-items: start; }
.fd-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.fd-card + .fd-card { margin-top: 18px; }
.fd-card-head {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.fd-card-meta { font-size: 11px; color: var(--text-3); font-weight: 400; }
.fd-card-body { padding: 16px 18px; }
.fd-terms { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 22px; }
.fd-term-full { grid-column: 1 / -1; }
.fd-term-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-3); }
.fd-term-value { font-size: 13px; margin-top: 3px; }
.fd-dd-head, .fd-dd-row {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr 1.2fr;
  gap: 10px;
  align-items: center;
}
.fd-dd-head {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-3);
  padding-bottom: 9px;
  border-bottom: 1px solid var(--border);
}
.fd-dd-row { padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.fd-dd-row:last-child { border-bottom: 0; padding-bottom: 0; }
.fd-chart { display: flex; align-items: flex-end; gap: 5px; height: 150px; }
.fd-chart-col { flex: 1; height: 100%; display: flex; flex-direction: column; }
.fd-chart-barwrap { flex: 1; display: flex; align-items: flex-end; }
.fd-chart-bar { width: 100%; background: var(--info-soft); border-radius: 3px 3px 0 0; min-height: 2px; }
.fd-chart-bar.last { background: var(--accent); }
.fd-chart-label { font-size: 9px; text-align: center; color: var(--text-3); margin-top: 5px; }
.fd-vol-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 16px; }
.fd-vol-stat { background: var(--surface-2); border-radius: 8px; padding: 9px 11px; }
.fd-vol-stat-label { font-size: 10px; color: var(--text-3); }
.fd-vol-stat-value { font-size: 14px; font-weight: 500; margin-top: 3px; }
.fd-risk-banner {
  padding: 11px 13px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  border-left: 3px solid;
  margin-bottom: 12px;
}
.fd-risk-note { font-size: 12px; line-height: 1.6; color: var(--text-2); }
.fd-cov-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  font-size: 12px;
}
.fd-cov-row:first-child { border-top: 0; }
.fd-cov-row.fail { color: var(--danger); }
.fd-cov-icon {
  width: 17px; height: 17px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  flex-shrink: 0;
}
.fd-cov-icon.ok { background: var(--success-soft); color: var(--success); }
.fd-cov-icon.fail { background: var(--danger-soft); color: var(--danger); }

/* ===== SUPPORTING CONSTRUCTS LAUNCHER ===== */
.topnav-right { display: flex; align-items: center; gap: 8px; }
.apps-menu { position: relative; }
.apps-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  color: var(--text-3);
  transition: all 0.15s;
}
.apps-trigger:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.apps-trigger.active { background: var(--surface-2); border-color: var(--border-2); color: var(--text); }
.apps-menu.open .apps-trigger { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.apps-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  z-index: 100;
  padding: 5px;
}
.apps-menu.open .apps-dropdown { display: block; }
.apps-dropdown-head {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 8px 9px 6px;
}
.apps-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background 0.13s;
}
.apps-item:hover { background: var(--surface-2); }
.apps-item-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.apps-item-text { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.apps-item-label { font-size: 13px; font-weight: 500; color: var(--text); }
.apps-item-desc { font-size: 11px; color: var(--text-3); }
.apps-item-soon {
  margin-left: auto;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 5px;
  flex-shrink: 0;
}

/* Studio placeholder */
.studio-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 24px;
  background: var(--surface);
  border: 1px dashed var(--border-2);
  border-radius: 14px;
}
.studio-ph-icon { font-size: 38px; margin-bottom: 14px; }
.studio-ph-title { font-size: 18px; font-weight: 500; margin-bottom: 8px; }
.studio-ph-text { font-size: 13px; color: var(--text-2); max-width: 440px; line-height: 1.65; }

/* ===== NOTIFICATIONS BELL ===== */
.notif-menu { position: relative; }
.notif-trigger {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  color: var(--text-2);
  transition: all 0.15s;
}
.notif-trigger:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.notif-menu.open .notif-trigger { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.notif-trigger.ring { animation: bellRing 0.85s ease; transform-origin: 50% 4px; }
@keyframes bellRing {
  0%, 100% { transform: rotate(0); }
  15% { transform: rotate(15deg); }
  30% { transform: rotate(-13deg); }
  45% { transform: rotate(10deg); }
  60% { transform: rotate(-7deg); }
  75% { transform: rotate(4deg); }
}
.notif-badge {
  position: absolute;
  top: 1px; right: 1px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--surface);
  font-family: 'JetBrains Mono', monospace;
}
.notif-badge.hidden { display: none; }
.notif-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 348px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  z-index: 100;
  overflow: hidden;
}
.notif-menu.open .notif-dropdown { display: block; }
.notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
}
.notif-markall {
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
}
.notif-markall:hover { text-decoration: underline; }
.notif-list { max-height: 392px; overflow-y: auto; }
.notif-empty { padding: 34px 16px; text-align: center; color: var(--text-3); font-size: 12px; }
.notif-item {
  display: flex;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.13s;
  position: relative;
}
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: var(--accent-bg); }
.notif-item.unread:hover { background: var(--accent-soft); }
.notif-item-icon {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}
.notif-item-icon.critical { background: var(--danger-soft); }
.notif-item-icon.warning { background: var(--warn-soft); }
.notif-item-icon.info { background: var(--info-soft); }
.notif-item-icon.success { background: var(--success-soft); }
.notif-item-body { flex: 1; min-width: 0; padding-right: 12px; }
.notif-item-title { font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.notif-item-desc { font-size: 11px; color: var(--text-2); line-height: 1.5; }
.notif-item-time { font-size: 10px; color: var(--text-3); margin-top: 4px; font-family: 'JetBrains Mono', monospace; }
.notif-item-dot {
  position: absolute;
  top: 14px; right: 12px;
  width: 7px; height: 7px;
  background: var(--accent);
  border-radius: 50%;
}
.notif-item.notif-new { animation: notifIn 0.45s ease; }
@keyframes notifIn {
  from { opacity: 0; transform: translateY(-7px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== STUDIO — workflow templates & agent hub ===== */
.studio-form-field { margin-bottom: 16px; }
.studio-form-label { font-size: 11px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.studio-input, .studio-select, .studio-textarea {
  width: 100%;
  max-width: 440px;
  padding: 8px 11px;
  border: 1px solid var(--border-2);
  border-radius: 7px;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--text);
  background: var(--surface);
}
.studio-input:focus, .studio-select:focus, .studio-textarea:focus { outline: 0; border-color: var(--accent); }
.studio-textarea { max-width: 100%; resize: vertical; min-height: 78px; line-height: 1.55; }
.hub-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 15px 16px;
}
.hub-card-icon {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  margin-bottom: 10px;
}
.hub-card-name { font-size: 13px; font-weight: 600; }
.hub-card-desc { font-size: 11.5px; color: var(--text-2); line-height: 1.5; margin-top: 5px; flex: 1; }
.hub-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}
.hub-deployed { font-size: 11px; font-weight: 600; color: var(--success); white-space: nowrap; }
.ah-intro {
  background: var(--accent-bg);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 14px;
}
/* ===== AGENT WORKBENCH ===== */
.ws-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 14px;
}
.ws-head-text { flex: 1; }
.ws-head-title { font-size: 13px; font-weight: 600; color: var(--text); }
.ws-head-sub { font-size: 11.5px; color: var(--text-3); margin-top: 3px; line-height: 1.5; }
.ws-draft-row {
  display: grid;
  grid-template-columns: 32px 2fr 1fr 1fr 0.9fr 0.9fr;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.ws-draft-row:hover { border-color: var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,0.04); }
.ws-draft-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}
.ws-status {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
}
.ws-status.draft   { background: #F1F5F9; color: #475569; border-color: #CBD5E1; }
.ws-status.testing { background: #FEF3E2; color: #92400E; border-color: #FCD7A1; }
.ws-status.ready   { background: #E0F1FD; color: #0C5A93; border-color: #93D5FA; }
.ws-status .ws-status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.ws-empty {
  padding: 36px 18px;
  text-align: center;
  border: 2px dashed var(--border);
  border-radius: 10px;
  color: var(--text-3);
  font-size: 12.5px;
  background: var(--surface);
}
.ws-empty .ws-empty-icon { font-size: 32px; opacity: 0.4; margin-bottom: 6px; }
/* authoring screen */
.ws-author-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 14px;
  align-items: start;
}
.ws-test-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  position: sticky;
  top: 14px;
}
.ws-test-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  color: var(--text-3);
  margin-bottom: 8px;
}
.ws-test-controls {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
}
.ws-mock-select {
  flex: 1;
}
.ws-results {
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.ws-result {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 12px;
}
.ws-result-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.ws-result-status {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.ws-result-status.success { background: #DCFCE7; color: #14532D; }
.ws-result-status.partial { background: #FEF3E2; color: #92400E; }
.ws-result-status.failure { background: #FEE2E2; color: #991B1B; }
.ws-result-ts { font-size: 10.5px; color: var(--text-3); font-family: 'JetBrains Mono', monospace; }
.ws-result-input {
  font-size: 11px;
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: 6px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ws-result-artifact {
  font-size: 11px;
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.ws-result-artifact code {
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10.5px;
  word-break: break-all;
}
.ws-artifact-empty {
  margin-top: 8px;
  padding: 14px 12px;
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  font-size: 11.5px;
  color: var(--text-3);
  text-align: center;
}
.ws-artifact-card {
  margin-top: 8px;
  padding: 0;
  background: var(--accent-bg);
  border: 1px solid var(--accent);
  border-radius: 8px;
  overflow: hidden;
}
.ws-artifact-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
}
.ws-artifact-icon {
  width: 30px; height: 30px;
  border-radius: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.ws-artifact-body { flex: 1; min-width: 0; }
.ws-artifact-path {
  font-size: 10.5px;
  margin-bottom: 4px;
}
.ws-artifact-path code {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
  word-break: break-all;
}
.ws-artifact-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ws-artifact-meta {
  font-size: 10.5px;
  color: var(--text-3);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ws-artifact-view {
  background: var(--surface);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}
.ws-artifact-view:hover { background: var(--accent); color: #fff; }
/* "Browse artifacts" button */
.ws-browse-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text);
  transition: all 0.12s;
  font-family: inherit;
}
.ws-browse-btn:hover { border-color: var(--accent); background: var(--accent-bg); }
.ws-browse-icon { font-size: 16px; }
.ws-browse-text { flex: 1; text-align: left; font-weight: 500; }
.ws-browse-hint { font-size: 11px; color: var(--text-3); }
/* File-browser modal */
.ewf-fb-modal {
  background: var(--surface);
  border-radius: 12px;
  width: 980px;
  max-width: 95vw;
  height: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  overflow: hidden;
}
.ewf-fb-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
}
.ewf-fb-title { font-size: 16px; font-weight: 600; color: var(--text); }
.ewf-fb-sub { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.ewf-fb-close {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 30px; height: 30px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-2);
}
.ewf-fb-close:hover { background: var(--surface-2); }
.ewf-fb-search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 22px 0;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.ewf-fb-search-bar:focus-within { border-color: var(--accent); background: var(--surface); }
.ewf-fb-search-icon { font-size: 14px; opacity: 0.7; }
.ewf-fb-search-bar input {
  flex: 1;
  border: 0;
  background: transparent;
  outline: 0;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
}
.ewf-fb-body {
  flex: 1;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 0;
  margin: 14px 22px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  min-height: 0;
}
.ewf-fb-sidebar {
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 8px 0;
}
.ewf-fb-section {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  color: var(--text-3);
  padding: 12px 14px 4px;
}
.ewf-fb-folder {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-2);
  border-left: 3px solid transparent;
  transition: background 0.1s, border-color 0.1s;
}
.ewf-fb-folder:hover { background: var(--surface); }
.ewf-fb-folder.active {
  background: var(--surface);
  border-left-color: var(--accent);
  color: var(--text);
}
.ewf-fb-folder-icon { font-size: 13px; flex-shrink: 0; }
.ewf-fb-folder-name { flex: 1; min-width: 0; }
.ewf-fb-folder-id { font-weight: 600; font-size: 12px; color: var(--text); }
.ewf-fb-folder-borrower { font-size: 10.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ewf-fb-folder-count {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
}
.ewf-fb-folder.active .ewf-fb-folder-count {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.ewf-fb-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
}
.ewf-fb-main-head {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.ewf-fb-main-title { font-size: 13px; font-weight: 600; color: var(--text); }
.ewf-fb-main-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.ewf-fb-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.ewf-fb-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.1s, border-color 0.1s;
}
.ewf-fb-item:hover { background: var(--surface-2); }
.ewf-fb-item.selected {
  background: var(--accent-bg);
  border-color: var(--accent);
}
.ewf-fb-item-icon {
  width: 32px; height: 32px;
  border-radius: 7px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.ewf-fb-item.selected .ewf-fb-item-icon {
  background: var(--surface);
  border-color: var(--accent);
}
.ewf-fb-item-body { flex: 1; min-width: 0; }
.ewf-fb-item-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ewf-fb-item-path {
  font-size: 10.5px;
  margin-top: 3px;
}
.ewf-fb-item-path code {
  font-family: 'JetBrains Mono', monospace;
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--accent);
}
.ewf-fb-item.selected .ewf-fb-item-path code {
  background: var(--surface);
  border: 1px solid var(--accent);
}
.ewf-fb-item-meta {
  font-size: 10.5px;
  color: var(--text-3);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ewf-fb-empty {
  padding: 60px 24px;
  text-align: center;
  color: var(--text-3);
  font-size: 12.5px;
}
.ewf-fb-empty-icon { font-size: 28px; opacity: 0.4; margin-bottom: 10px; }
.ewf-fb-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.ws-result-output {
  font-size: 11.5px;
  color: var(--text-2);
  line-height: 1.55;
  white-space: pre-wrap;
}
.ws-stream {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  min-height: 80px;
  max-height: 220px;
  overflow-y: auto;
  margin-top: 10px;
  white-space: pre-wrap;
  line-height: 1.55;
}
.ws-stream-line { display: block; }
.ws-stream-line.thinking { color: var(--text-3); font-style: italic; }
.ws-stream-line.tool { color: #0C5A93; }
.ws-stream-line.result { color: var(--text); }
.ws-stream-cursor::after {
  content: '▌';
  color: var(--accent);
  animation: wsCursor 1s steps(1) infinite;
}
@keyframes wsCursor {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}
.ws-publish-bar {
  background: var(--accent-bg);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text);
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.tmpl-choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}
.tmpl-choice:hover { border-color: var(--accent); }
.studio-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.studio-tab {
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-3);
  padding: 8px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.studio-tab:hover { color: var(--text); }
.studio-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.gov-editor-header { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; align-items: flex-start; }
.gov-editor-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600; color: var(--text-3); margin-bottom: 5px; }
#govEditingSelect {
  font-family: inherit;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 10px;
  cursor: pointer;
  max-width: 380px;
  width: auto;
  outline: none;
}
#govEditingSelect:hover { border-color: var(--accent); color: var(--accent); }
#govEditingSelect:focus { border-color: var(--accent); }
.gov-editor-meta { font-size: 11.5px; color: var(--text-3); margin-top: 6px; }
.gov-editor-meta .dirty { color: var(--accent); font-weight: 600; margin-left: 6px; }

/* ===== PRIVACY MODE — blur PII across the UI so demo recordings can be
   safely shared without leaking customer data. Uses CSS filter:blur on
   live elements (not text replacement) so the surface still "looks
   right" — you can tell that's a borrower name / a number / an email,
   you just can't read the specifics. Toggled via togglePrivacy() in
   _base.html which adds .privacy-on to <body>. */

/* The embedded PDF can't be text-substituted, so blur the canvas. */
body.privacy-on .doc-realdoc-container {
  filter: blur(7px);
  -webkit-filter: blur(7px);
  transition: filter 0.18s ease;
}

/* Borrower + people names across the app — cases list, case detail
   header, BSA counterparties, user menu, breadcrumbs, monitor portfolio,
   audit log actors. */
body.privacy-on .job-name,
body.privacy-on .job-agent,
body.privacy-on .cdv2-title,
body.privacy-on .cdv2-section-title,
body.privacy-on .bc-current,
body.privacy-on .bsa-cp-name,
body.privacy-on .user-menu-name,
body.privacy-on .user-menu-header-name,
body.privacy-on .user-menu-header-email,
body.privacy-on .st-name,
body.privacy-on .bq-from-borrower .bq-item strong,
/* Numeric IDs in the case-detail meta line + meta-grid values + tables. */
body.privacy-on .job-id,
body.privacy-on .cdv2-meta .mono,
body.privacy-on .meta-value,
body.privacy-on .st-mono,
body.privacy-on .loan-tx-table .mono,
body.privacy-on .loan-tx-ids .mono,
/* Activity log labels (often include borrower names + amounts) */
body.privacy-on .cdv2-activity-row .activity-text,
body.privacy-on .activity-row-actor,
body.privacy-on .activity-row-detail,
/* Bell-menu notification bodies */
body.privacy-on .notif-item-body,
body.privacy-on .notif-item-title,
/* Drawdown / repayment tx-IDs */
body.privacy-on .loan-tx-id {
  filter: blur(5px);
  -webkit-filter: blur(5px);
  user-select: none;
  transition: filter 0.18s ease;
}

/* Sticky indicator chip so the demo driver always knows privacy mode is
   on. Click to toggle off (alternate path to the user-menu switch). */
.privacy-badge {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 100;
  background: var(--text);
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  display: none;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
  cursor: pointer;
  border: 0;
  font-family: inherit;
}
.privacy-badge:hover { background: #000; }
body.privacy-on .privacy-badge { display: inline-flex; }

/* ===== STUDIO ===== */
#studio.screen { padding: 0; }
.studio-layout { display: flex; align-items: stretch; min-height: calc(100vh - 61px); }
.studio-sidebar {
  width: 228px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 18px 12px;
  /* Column layout so the version chip can dock to the bottom. */
  display: flex;
  flex-direction: column;
}
/* Version "What's new" card at the bottom of the Studio sidebar.
   Inspired by the desktop-app "Relaunch to update" pattern — subtle
   card with an icon, two-line text block, and a chevron. Clicking
   opens the Changelog panel via studioNav('changelog'). */
.studio-version-card {
  margin-top: auto;     /* pushes to the bottom of the flex column */
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 9px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  color: var(--text);
  transition: border-color 0.1s, background 0.1s;
}
.studio-version-card:hover { border-color: var(--accent); background: var(--surface); }
.studio-version-card.active { border-color: var(--accent); background: var(--accent-bg); }
.studio-version-icon {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}
.studio-version-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.studio-version-title { font-size: 12.5px; font-weight: 600; color: var(--text); }
.studio-version-sub { font-size: 10.5px; color: var(--text-3); }
.studio-version-arrow { color: var(--text-3); font-size: 14px; flex-shrink: 0; }
.studio-version-card:hover .studio-version-arrow { color: var(--accent); }

/* Changelog panel — release entry list. */
.changelog-list { display: flex; flex-direction: column; gap: 10px; }
.changelog-entry {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px 16px;
}
.changelog-entry.latest { border-color: var(--accent); }
.changelog-head { display: flex; align-items: center; gap: 10px; width: 100%; margin: 0; padding: 0; background: none; border: 0; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.changelog-entry.expanded .changelog-head { margin-bottom: 8px; }
.changelog-version { font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 600; color: var(--text); }
.changelog-date { font-size: 11.5px; color: var(--text-3); }
.changelog-latest-pill {
  margin-left: auto;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.changelog-body { font-size: 12.5px; line-height: 1.45; color: var(--text-2); }
.changelog-body h4.ch-section {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  font-weight: 600;
  margin: 9px 0 3px;
}
.changelog-body h4.ch-section:first-child { margin-top: 0; }
.changelog-body ul { padding-left: 16px; margin: 3px 0 4px; }
.changelog-body li { margin-bottom: 2px; }
.changelog-body p { margin: 3px 0; }
.changelog-body code {
  font-size: 11.5px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--surface-2);
  font-family: 'JetBrains Mono', monospace;
}
.changelog-body a { color: var(--accent); }

/* Collapsible minor-version cards + pagination (What's new panel). */
.changelog-relcount { font-size: 10.5px; color: var(--text-3); padding: 1px 6px; border: 1px solid var(--border); border-radius: 999px; }
.changelog-caret { margin-left: auto; color: var(--text-3); font-size: 11px; transition: transform 0.12s ease; }
.changelog-entry.expanded .changelog-caret { transform: rotate(90deg); }
.changelog-summary { font-size: 12px; color: var(--text-3); margin-top: 5px; line-height: 1.4; }
.changelog-entry:not(.expanded) .changelog-body { display: none; }
.changelog-entry.expanded .changelog-summary { display: none; }
.cl-patch + .cl-patch { margin-top: 9px; padding-top: 9px; border-top: 1px dashed var(--border); }
.cl-patch-ver { font-size: 10.5px; color: var(--text-3); margin-bottom: 3px; }
.changelog-pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; }
.cl-pg-btn { font-size: 12px; padding: 4px 11px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text-2); cursor: pointer; }
.cl-pg-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--text); }
.cl-pg-btn:disabled { opacity: 0.4; cursor: default; }
.cl-pg-info { font-size: 11.5px; color: var(--text-3); }

.studio-sidebar-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-3);
  font-weight: 600;
  padding: 0 10px 10px;
}
.studio-nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  border-radius: 7px;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  text-align: left;
  margin-bottom: 2px;
}
.studio-nav-item:hover { background: var(--surface-2); color: var(--text); }
.studio-nav-item.active { background: var(--accent-bg); color: var(--accent); font-weight: 500; }
.studio-nav-icon { width: 17px; text-align: center; font-size: 13px; flex-shrink: 0; }
.studio-main { flex: 1; padding: 26px 28px; min-width: 0; }
.studio-panel { display: none; }
.studio-panel.active { display: block; }
.studio-phead {
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.studio-ptitle { font-size: 19px; font-weight: 500; letter-spacing: -0.4px; }
.studio-psub { font-size: 13px; color: var(--text-2); margin-top: 3px; }
.studio-btn {
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 7px 13px;
  border-radius: 7px;
  cursor: pointer;
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--text);
  flex-shrink: 0;
}
.studio-btn:hover { border-color: var(--text-3); }
.studio-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.studio-btn.primary:hover { background: #0379c4; }
.studio-btn.primary:disabled { background: var(--text-3); border-color: var(--text-3); cursor: not-allowed; opacity: 0.6; }
.studio-btn.danger { color: #B91C1C; border-color: #FCA5A5; }
.studio-btn.danger:hover { background: #FEE2E2; border-color: #F87171; }
.studio-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}
.studio-grid { display: grid; gap: 14px; }
.studio-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  font-weight: 600;
  margin: 24px 0 11px;
}
.studio-section-label:first-child { margin-top: 0; }
.studio-table {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}
.st-head, .st-row {
  display: grid;
  grid-template-columns: var(--cols);
  gap: 12px;
  align-items: center;
}
.st-head {
  padding: 10px 16px;
  background: var(--surface-2);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
}
.st-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}
.st-row:last-child { border-bottom: 0; }
.st-row.clickable { cursor: pointer; transition: background 0.12s; }
.st-row.clickable:hover { background: var(--surface-2); }
.st-name { font-weight: 500; }
.st-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.st-mono { font-family: 'JetBrains Mono', monospace; font-size: 11px; }
.studio-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.studio-dot.on { background: var(--success); }
.studio-dot.off { background: var(--text-3); }
.studio-dot.warn { background: var(--accent); }
.studio-switch {
  width: 34px; height: 19px;
  border-radius: 999px;
  background: var(--border-2);
  position: relative;
  cursor: pointer;
  border: 0;
  flex-shrink: 0;
  transition: background 0.15s;
}
.studio-switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}
.studio-switch.on { background: var(--accent); }
.studio-switch.on::after { transform: translateX(15px); }
.studio-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text-2);
}
.studio-tag.critical { background: var(--danger-soft); color: var(--danger); }
.studio-tag.warning { background: var(--warn-soft); color: var(--warn); }
.studio-tag.material { background: var(--accent-soft); color: var(--accent); }
.studio-breadcrumb {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 14px;
}
.studio-breadcrumb .bc-link { color: var(--text-2); cursor: pointer; }
.studio-breadcrumb .bc-link:hover { color: var(--accent); }
/* workflow pipeline */
.wf-pipeline {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.wf-stage {
  padding: 5px 11px;
  border-radius: 7px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-2);
}
.wf-stage.human { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }
.wf-stage.system { border-color: #B45309; color: #92400E; background: #FEF3E2; }
.wf-arrow { color: var(--text-3); font-size: 11px; }

/* ─── Unified Case Pipeline: backbone + per-product overlays ─── */

/* The 8-stage backbone — a vertical list of stage cards with the
   agents that can run at each stage. */
.wf-backbone {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wf-bb-stage {
  position: relative;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  border-left: 3px solid var(--accent);
}
.wf-bb-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.wf-bb-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  background: var(--accent); color: #fff;
  border-radius: 50%;
  font-size: 11px; font-weight: 700;
  flex: 0 0 auto;
}
.wf-bb-name { font-size: 13px; font-weight: 600; color: var(--text); }
.wf-bb-desc { font-size: 12px; color: var(--text-2); line-height: 1.5; margin-bottom: 8px; }
.wf-bb-agents { display: flex; flex-wrap: wrap; gap: 6px; }
.wf-bb-agent, .wf-bb-human {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 11px;
  color: var(--text-2);
}
.wf-bb-human { color: var(--accent); border-color: var(--accent); background: var(--accent-bg); }

/* Product-picker pills + per-product overlay panes */
.wf-product-pills {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 10px 0 16px;
}
.wf-product-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit; font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  transition: border-color 0.1s, background 0.1s;
}
.wf-product-pill:hover { border-color: var(--accent); }
.wf-product-pill.active {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.wf-product-pill-icon { font-size: 15px; }
.wf-product-pill-count {
  font-size: 10.5px;
  padding: 1px 6px;
  background: var(--surface-2);
  border-radius: 3px;
  color: var(--text-3);
}
.wf-product-pill.active .wf-product-pill-count {
  background: var(--accent); color: #fff;
}

.wf-overlay-pane { display: none; }
.wf-overlay-pane.active { display: block; }

.wf-deltas {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wf-delta {
  padding: 10px 14px;
  background: var(--surface-2);
  border-radius: 6px;
  border-left: 3px solid var(--border);
}
.wf-delta-add    { border-left-color: var(--success); }
.wf-delta-remove { border-left-color: var(--danger); }
.wf-delta-branch { border-left-color: var(--accent); }

.wf-delta-stage-label {
  font-size: 10px;
  color: var(--text-3);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.wf-delta-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 4px;
}
.wf-delta-sign {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px;
  border-radius: 4px;
  font-size: 12px; font-weight: 700;
  flex: 0 0 auto;
}
.wf-delta-add    .wf-delta-sign { background: var(--success); color: #fff; }
.wf-delta-remove .wf-delta-sign { background: var(--danger); color: #fff; }
.wf-delta-branch .wf-delta-sign { background: var(--accent); color: #fff; }
.wf-delta-text { font-weight: 500; }
.wf-delta-agent {
  font-size: 11px;
  padding: 2px 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-2);
}
.wf-delta-note { font-size: 12px; color: var(--text-2); line-height: 1.5; }
/* edit workflow — node-graph builder */
.ewf-builder {
  display: grid;
  grid-template-columns: 220px 1fr 300px;
  gap: 14px;
  align-items: start;
}
.ewf-iconbtn {
  width: 26px; height: 26px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 12px;
  color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
}
.ewf-iconbtn:hover { background: var(--surface-2); color: var(--text); }
.ewf-iconbtn.danger:hover { background: #FEE2E2; color: #B91C1C; border-color: #FCA5A5; }
.ewf-iconbtn:disabled { opacity: 0.35; cursor: not-allowed; }
/* palette */
.ewf-palette {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  position: sticky;
  top: 14px;
}
.ewf-palette-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  color: var(--text-3);
  margin-bottom: 4px;
}
.ewf-palette-hint { font-size: 11px; color: var(--text-3); margin-bottom: 12px; }
.ewf-palette-tile {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  cursor: grab;
  transition: all 0.12s;
  user-select: none;
}
.ewf-palette-tile:last-of-type { margin-bottom: 0; }
.ewf-palette-tile:hover { transform: translateX(2px); border-color: var(--accent); }
.ewf-palette-tile:active { cursor: grabbing; }
.ewf-palette-tile.dragging { opacity: 0.5; }
.ewf-palette-tile.agent { border-left: 3px solid #15795C; }
.ewf-palette-tile.human { border-left: 3px solid var(--accent); }
.ewf-palette-tile.system { border-left: 3px solid #B45309; }
.ewf-palette-icon {
  width: 32px; height: 32px;
  border-radius: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.ewf-palette-name { font-size: 12.5px; font-weight: 600; color: var(--text); }
.ewf-palette-desc { font-size: 10.5px; color: var(--text-3); margin-top: 1px; }
/* canvas / graph */
.ewf-canvas {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 360px;
  overflow: auto;
  position: relative;
  padding: 0;
  transition: background 0.15s, border-color 0.15s;
}
.ewf-canvas.drop-active {
  background: var(--accent-bg);
  border-color: var(--accent);
}
.ewf-canvas-empty {
  margin: 24px;
  padding: 56px 24px;
  text-align: center;
  border: 2px dashed var(--border);
  border-radius: 10px;
  color: var(--text-3);
  font-size: 12.5px;
  background: var(--surface);
  transition: all 0.15s;
}
.ewf-canvas-empty .ewf-empty-icon { font-size: 32px; opacity: 0.4; margin-bottom: 8px; }
.ewf-canvas-empty.drop-active {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
}
.ewf-graph { position: relative; margin: 0 auto; }
.ewf-edges {
  position: absolute;
  top: 0; left: 0;
  pointer-events: none;
  overflow: visible;
}
.ewf-edge-group { pointer-events: auto; }
.ewf-edge-line {
  stroke: #94A3B8;
  stroke-width: 2;
  fill: none;
  transition: stroke 0.12s, stroke-width 0.12s;
}
.ewf-edge-hit {
  stroke: transparent;
  stroke-width: 14;
  fill: none;
  cursor: pointer;
}
.ewf-edge-group:hover .ewf-edge-line {
  stroke: #E11D48;
  stroke-width: 2.5;
}
.ewf-edge-pending {
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 6 4;
  fill: none;
  pointer-events: none;
}
/* node card */
.ewf-stage-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.12s, box-shadow 0.12s;
  user-select: none;
  cursor: pointer;
  box-sizing: border-box;
}
.ewf-stage-card:hover { border-color: var(--accent); box-shadow: 0 1px 6px rgba(0,0,0,0.05); }
.ewf-stage-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-bg);
}
.ewf-stage-card.source {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent), 0 0 0 6px var(--accent-bg);
}
.ewf-stage-card.agent { border-left: 3px solid #15795C; }
.ewf-stage-card.human { border-left: 3px solid var(--accent); }
.ewf-stage-card.system { border-left: 3px solid #B45309; }
.ewf-stage-inner {
  display: grid;
  grid-template-columns: 22px 28px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 12px 14px;
  height: 100%;
  box-sizing: border-box;
}
.ewf-stage-text { min-width: 0; }
.ewf-stage-name {
  font-size: 13px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ewf-stage-sub {
  font-size: 11px; color: var(--text-3); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ewf-stage-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 10px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
  font-family: 'JetBrains Mono', monospace;
}
.ewf-stage-icon {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.ewf-stage-warn {
  color: #B45309; background: #FEF3E2;
  border: 1px solid #FCD7A1;
  border-radius: 50%;
  width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
}
/* ports */
.ewf-port {
  position: absolute;
  left: 50%;
  margin-left: -7px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid #94A3B8;
  cursor: crosshair;
  z-index: 3;
  transition: transform 0.12s, background 0.12s, border-color 0.12s, box-shadow 0.12s;
  box-sizing: border-box;
}
.ewf-port:hover {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.3);
  box-shadow: 0 0 0 4px var(--accent-bg);
}
.ewf-port.target-eligible {
  border-color: var(--accent);
  background: var(--accent-bg);
  animation: ewfPulse 1.5s ease-in-out infinite;
}
@keyframes ewfPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-bg); }
  50%      { box-shadow: 0 0 0 6px var(--accent-bg); }
}
.ewf-port.in { top: -7px; }
.ewf-port.out { bottom: -7px; }
.ewf-stage-card.source .ewf-port.out {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.3);
}
/* inspector */
.ewf-inspector {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  position: sticky;
  top: 14px;
}
.ewf-inspector-empty {
  padding: 24px 8px;
  text-align: center;
}
.ewf-inspector-empty .ewf-empty-icon { font-size: 28px; opacity: 0.35; margin-bottom: 8px; }
.ewf-inspector-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  font-weight: 600; color: var(--text-3); margin-bottom: 6px;
}
.ewf-inspector-hint { font-size: 12px; color: var(--text-3); line-height: 1.5; }
.ewf-inspector-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
/* whitelabel */
/* ===== LLM PROVIDER CARDS ===== */
.llm-tab-count {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
  margin-left: 4px;
}
.studio-tab.active .llm-tab-count { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }
.llm-cfg-card {
  display: grid;
  grid-template-columns: 56px 1.6fr 1fr 1fr 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.llm-cfg-card:hover { border-color: var(--accent); box-shadow: 0 1px 6px rgba(0,0,0,0.06); }
.llm-cfg-card:last-child { margin-bottom: 0; }
.llm-icon {
  width: 48px; height: 48px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  color: #fff;
  font-weight: 700;
  font-family: 'DM Sans', sans-serif;
}
.llm-cfg-name { font-size: 14px; font-weight: 600; color: var(--text); }
.llm-cfg-sub { font-size: 11px; color: var(--text-3); margin-top: 3px; }
.llm-models-line {
  font-size: 10.5px;
  color: var(--text-3);
  margin-top: 6px;
  font-family: 'JetBrains Mono', monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.llm-cfg-metric-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-3);
  font-weight: 600;
  margin-bottom: 2px;
}
.llm-cfg-metric-value { font-size: 13px; font-weight: 600; color: var(--text); font-family: 'JetBrains Mono', monospace; }
.llm-status-active {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  background: #DCFCE7;
  color: #14532D;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
}
.llm-status-active::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #16A34A;
  box-shadow: 0 0 0 3px rgba(22,163,74,0.18);
}
/* supported tab — provider grid */
.llm-cat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  color: var(--text-3);
  margin: 18px 0 8px;
}
.llm-cat-label:first-child { margin-top: 4px; }
.llm-supported-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.llm-sup-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.llm-sup-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.llm-sup-head .llm-icon {
  width: 38px; height: 38px;
  font-size: 18px;
  border-radius: 9px;
}
.llm-sup-name { font-size: 13px; font-weight: 600; color: var(--text); }
.llm-sup-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.llm-sup-models {
  font-size: 10.5px;
  color: var(--text-2);
  font-family: 'JetBrains Mono', monospace;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  flex: 1;
  line-height: 1.5;
}
.llm-sup-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  gap: 8px;
}
.llm-sup-cat-chip {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.llm-sup-configured {
  font-size: 11px;
  font-weight: 600;
  color: #14532D;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.llm-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 8px;
}
.llm-cfg-block {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 14px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.llm-cfg-block-row { display: flex; flex-direction: column; gap: 4px; }
.llm-cfg-block-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-3);
  font-weight: 600;
}
.llm-cfg-block-value { font-size: 12.5px; color: var(--text); font-family: 'JetBrains Mono', monospace; }
.wl-swatch-row { display: flex; gap: 10px; margin-top: 8px; }
/* currency chips on General › Locale */
.ccy-chip {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-3);
  cursor: pointer;
  user-select: none;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.ccy-chip:hover { color: var(--text); border-color: var(--text-3); }
.ccy-chip.on {
  background: var(--accent-bg);
  color: var(--accent);
  border-color: var(--accent);
}
.wl-swatch {
  width: 34px; height: 34px;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border);
}
.wl-swatch.active { box-shadow: 0 0 0 2px var(--text); }
.wl-field { margin-bottom: 18px; }
.wl-field-label { font-size: 11px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.wl-input {
  width: 100%;
  max-width: 380px;
  padding: 8px 11px;
  border: 1px solid var(--border-2);
  border-radius: 7px;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--text);
}
.wl-verified {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--success);
  margin-left: 8px;
}

/* ===== DATA VIEW TOGGLE (flat / grouped) ===== */
.docs-view-toggle {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 7px;
  padding: 2px;
  flex-shrink: 0;
}
.docs-view-toggle button {
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: 5px;
  color: var(--text-3);
  cursor: pointer;
  transition: all 0.13s;
}
.docs-view-toggle button:hover { color: var(--text); }
.docs-view-toggle button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.dg-doc-case {
  display: none;
  margin-left: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 600;
  color: var(--accent);
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
  vertical-align: middle;
}
#documents.flat-view .dg-doc-case { display: inline-block; }
#documents.flat-view .docs-group { margin-bottom: 0; border-radius: 0; border-bottom: 0; }
#documents.flat-view .docs-group:last-of-type { border-bottom: 1px solid var(--border); }
#documents.flat-view .docs-group-head { display: none; }
#documents.flat-view .docs-group-body { display: block; border-top: 0; }
#documents.flat-view .dg-doc-row { padding-left: 18px; }

/* ===== COPILOT ===== */
.copilot-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s;
}
.copilot-btn:hover { background: var(--accent); color: #fff; }
.copilot-drawer {
  position: fixed;
  top: 0; right: 0;
  width: 392px;
  max-width: 92vw;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -10px 0 36px rgba(10,22,40,0.12);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
}
.copilot-drawer.open { transform: translateX(0); }
.copilot-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.copilot-head-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #0a1628);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.copilot-head-text { flex: 1; min-width: 0; }
.copilot-head-title { font-size: 14px; font-weight: 600; }
.copilot-head-ctx { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.copilot-close {
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--text-3);
  font-size: 17px;
  line-height: 1;
  padding: 2px 4px;
}
.copilot-close:hover { color: var(--text); }
.copilot-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 13px;
}
.copilot-msg { display: flex; gap: 8px; }
.copilot-msg.user { flex-direction: row-reverse; }
.copilot-msg-avatar {
  width: 24px; height: 24px;
  border-radius: 6px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}
.copilot-msg.bot .copilot-msg-avatar { background: linear-gradient(135deg, var(--accent), #0a1628); color: #fff; }
.copilot-msg.user .copilot-msg-avatar { background: var(--surface-2); color: var(--text-2); }
.copilot-bubble {
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.55;
  max-width: 290px;
}
.copilot-msg.bot .copilot-bubble { background: var(--surface-2); color: var(--text); border-top-left-radius: 3px; }
.copilot-msg.user .copilot-bubble { background: var(--accent); color: #fff; border-top-right-radius: 3px; }
.copilot-bubble p { margin: 0 0 7px; }
.copilot-bubble p:last-child { margin-bottom: 0; }
.copilot-bubble ul { margin: 5px 0; padding-left: 17px; }
.copilot-bubble li { margin-bottom: 3px; }
.copilot-bubble strong { font-weight: 600; }
.copilot-typing { display: flex; gap: 3px; padding: 5px 2px; }
.copilot-typing span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  animation: copilotDot 1.2s infinite ease-in-out;
}
.copilot-typing span:nth-child(2) { animation-delay: 0.18s; }
.copilot-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes copilotDot {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}
.copilot-suggest {
  padding: 10px 14px 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-top: 1px solid var(--border);
  align-items: center;
}
.copilot-suggest:empty { padding: 0; border-top: 0; }
.copilot-suggest-label {
  width: 100%;
  font-size: 10.5px;
  color: var(--text-3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 2px;
}
.copilot-chip {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--text-2);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.13s;
}
.copilot-chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }
.copilot-input-row {
  padding: 10px 14px 14px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.copilot-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--border-2);
  border-radius: 9px;
  padding: 9px 11px;
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.4;
  max-height: 88px;
  outline: none;
  color: var(--text);
}
.copilot-input:focus { border-color: var(--accent); }
.copilot-send {
  flex-shrink: 0;
  width: 34px; height: 34px;
  border-radius: 9px;
  border: 0;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}
.copilot-send:hover { background: #0379c4; }
/* Credit-note revision box */
.cn-revision {
  margin-top: 10px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--accent-bg);
  overflow: hidden;
  animation: cnRevIn 0.35s ease;
}
@keyframes cnRevIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.cn-revision-head {
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--accent-soft);
}
.cn-revision-body {
  padding: 11px 12px;
  font-size: 11.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text);
  max-height: 300px;
  overflow-y: auto;
  background: var(--surface);
}
.cn-add {
  background: var(--success-soft);
  color: var(--success);
  border-radius: 2px;
  padding: 0 2px;
}
.cn-revision-actions {
  display: flex;
  gap: 8px;
  padding: 9px 12px;
  border-top: 1px solid var(--accent-soft);
}
.cn-rev-btn {
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--text-2);
}
.cn-rev-btn:hover { border-color: var(--text-3); }
.cn-rev-btn.accept { background: var(--accent); color: #fff; border-color: var(--accent); }
.cn-rev-btn.accept:hover { background: #0379c4; }
.cn-editable.cn-flash { animation: cnFlash 1.1s ease; }
@keyframes cnFlash {
  0% { background: var(--success-soft); }
  100% { background: var(--surface); }
}

/* Print styles for approval letter */
@media print {
  body * { visibility: hidden; }
  #printLetterContent, #printLetterContent * { visibility: visible; }
  #printLetterContent { position: absolute; left: 0; top: 0; width: 100%; padding: 40px; }
}

/* ===== IN-APP CONFIRM MODAL (replaces window.confirm for hx-confirm) ===== */
.confirm-modal {
  background: var(--surface);
  border-radius: 14px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
  overflow: hidden;
  animation: confirm-modal-pop 0.15s ease-out;
}
@keyframes confirm-modal-pop {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.confirm-modal-body {
  padding: 22px 24px 18px;
}
.confirm-modal-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--text);
  margin-bottom: 6px;
}
.confirm-modal-question {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-2);
}
.confirm-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}
.confirm-modal-btn {
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-1);
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.confirm-modal-btn:hover {
  background: var(--surface-3, var(--surface-2));
}
.confirm-modal-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.confirm-modal-btn.primary:hover {
  filter: brightness(1.06);
}
.confirm-modal-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ===== COPILOT TYPING DOTS (phase 5b-ii) ===== */
.copilot-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 4px 2px;
}
.copilot-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  animation: copilot-bounce 1.2s infinite ease-in-out;
}
.copilot-dots span:nth-child(2) { animation-delay: 0.15s; }
.copilot-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes copilot-bounce {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40%           { opacity: 1;   transform: translateY(-3px); }
}

/* ============================================================
   BORROWER PORTAL — separate borrower-facing surface (Phase 1).
   Card-based layout, more whitespace than the dense ops UI.
   ============================================================ */
.portal-body { background: var(--surface-2); min-height: 100vh; }
.portal-topnav { background: var(--surface); }
.portal-pill {
  margin-left: 12px;
  font-size: 10.5px;
  padding: 3px 9px;
  border-radius: 4px;
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.portal-main {
  max-width: 920px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}
.portal-page { display: flex; flex-direction: column; gap: 18px; }

.portal-breadcrumb { font-size: 12px; color: var(--text-3); margin-bottom: 4px; }
.portal-breadcrumb a { color: var(--text-2); text-decoration: none; }
.portal-breadcrumb a:hover { color: var(--accent); }

.portal-hero {
  padding: 8px 4px 14px;
}
.portal-hero-eyebrow {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-3); font-weight: 600;
}
.portal-hero-title {
  font-size: 22px; font-weight: 600; color: var(--text); margin-top: 4px;
}
.portal-hero-sub { font-size: 13px; color: var(--text-2); margin-top: 4px; }

.portal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
}
.portal-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.portal-card-head h2 { font-size: 14px; font-weight: 600; color: var(--text); margin: 0; }
.portal-card-pill {
  font-size: 11px; padding: 3px 9px; border-radius: 4px;
  background: var(--surface-2); color: var(--text-3); font-weight: 500;
}
.portal-todo-pill { background: var(--warn-soft); color: var(--warn); }

.portal-todo { border-color: var(--warn); }
.portal-todo-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.portal-todo-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px;
  background: var(--surface-2); border-radius: 8px;
}
.portal-todo-subject { font-size: 13px; font-weight: 500; color: var(--text); }
.portal-todo-meta { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.portal-empty { text-align: center; padding: 36px 20px; }
.portal-empty-icon { font-size: 32px; color: var(--success); margin-bottom: 8px; }
.portal-empty-title { font-size: 14px; font-weight: 600; color: var(--text); }
.portal-empty-body { font-size: 12.5px; color: var(--text-3); margin-top: 4px; }
.portal-empty-inline { font-size: 12.5px; color: var(--text-3); padding: 14px 4px; }

.portal-case-list { display: flex; flex-direction: column; gap: 8px; }
.portal-case-row {
  display: grid; grid-template-columns: 1.4fr 1fr 1.2fr 30px;
  gap: 12px; align-items: center;
  padding: 12px 14px;
  background: var(--surface-2); border-radius: 8px;
  border: 1px solid transparent;
  text-decoration: none; color: inherit;
  transition: border-color 0.1s;
}
.portal-case-row:hover { border-color: var(--accent); }
.portal-case-code { font-size: 13px; font-weight: 600; color: var(--text); }
.portal-case-type { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.portal-case-stage-label { font-size: 10px; text-transform: uppercase; color: var(--text-3); letter-spacing: 0.4px; }
.portal-case-stage-value { font-size: 12.5px; color: var(--text); margin-top: 2px; }
.portal-case-status {
  font-size: 11px; padding: 3px 9px; border-radius: 4px; font-weight: 500;
}
.portal-case-status-on_track { background: var(--success-soft); color: var(--success); }
.portal-case-status-at_risk  { background: var(--warn-soft);    color: var(--warn); }
.portal-case-status-blocked  { background: var(--danger-soft);  color: var(--danger); }
.portal-case-status-completed { background: var(--accent-bg);   color: var(--accent); }
.portal-case-meta { font-size: 10.5px; color: var(--text-3); margin-top: 4px; }
.portal-case-col-arrow { font-size: 16px; color: var(--text-3); text-align: right; }

.portal-btn {
  display: inline-block;
  font-family: inherit;
  font-size: 12.5px;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.1s, border-color 0.1s;
}
.portal-btn:hover { border-color: var(--accent); }
.portal-btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.portal-btn-primary:hover { opacity: 0.92; }

/* Timeline */
.portal-timeline {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: row; gap: 0;
  position: relative;
}
.portal-timeline-step {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px;
  position: relative; padding: 0 4px;
}
.portal-timeline-step::before {
  content: ''; position: absolute; top: 11px; left: 50%; right: -50%;
  height: 2px; background: var(--border); z-index: 0;
}
.portal-timeline-step:last-child::before { display: none; }
.portal-timeline-dot {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--text-3);
  font-size: 11px;
  z-index: 1;
}
.portal-timeline-label {
  font-size: 11px; color: var(--text-3); text-align: center; line-height: 1.3;
}
.portal-timeline-done .portal-timeline-dot { background: var(--success); color: #fff; border-color: var(--success); }
.portal-timeline-done.portal-timeline-step::before { background: var(--success); }
.portal-timeline-done .portal-timeline-label { color: var(--text-2); }
.portal-timeline-current .portal-timeline-dot { background: var(--accent); color: #fff; border-color: var(--accent); }
.portal-timeline-current .portal-timeline-label { color: var(--text); font-weight: 600; }

/* Queries */
.portal-query-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.portal-query {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  background: var(--surface-2);
}
.portal-query-open { border-color: var(--warn); }
.portal-query-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.portal-query-subject { font-size: 13px; font-weight: 600; color: var(--text); }
.portal-query-status { font-size: 10.5px; padding: 2px 8px; border-radius: 4px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.3px; }
.portal-query-status-open { background: var(--warn-soft); color: var(--warn); }
.portal-query-status-answered { background: var(--accent-bg); color: var(--accent); }
.portal-query-status-closed { background: var(--success-soft); color: var(--success); }
.portal-query-body { font-size: 12.5px; color: var(--text-2); margin-bottom: 8px; line-height: 1.55; }
.portal-query-meta { font-size: 11px; color: var(--text-3); }
.portal-query-reply { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.portal-query-answer {
  margin-top: 10px; padding: 10px 12px;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: 4px;
  font-size: 12.5px; color: var(--text-2);
}
.portal-query-answer-label { font-size: 10.5px; color: var(--text-3); margin-bottom: 4px; }

/* Document upload + list */
.portal-upload { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; padding: 14px; background: var(--surface-2); border-radius: 8px; }
.portal-upload-row { display: flex; gap: 12px; }
.portal-upload-row > * { flex: 1; }
.portal-upload-file { display: flex; gap: 10px; align-items: flex-end; }
.portal-upload-file input[type="file"] { flex: 1; font-size: 12.5px; }
.portal-upload-help { font-size: 11px; color: var(--text-3); margin: 0; }

.portal-doc-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.portal-doc-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 6px;
  background: var(--surface-2);
}
.portal-doc-icon { font-size: 18px; flex-shrink: 0; }
.portal-doc-text { flex: 1; min-width: 0; }
.portal-doc-title { font-size: 12.5px; font-weight: 500; color: var(--text); }
.portal-doc-meta { font-size: 10.5px; color: var(--text-3); margin-top: 2px; }
.portal-doc-kind {
  font-size: 10.5px; padding: 2px 7px; border-radius: 4px;
  background: var(--surface); color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.3px;
}

/* Decision card */
.portal-decision-body { font-size: 12.5px; color: var(--text-2); line-height: 1.55; }
.portal-decision-approved { background: var(--success-soft); color: var(--success); }
.portal-decision-declined { background: var(--danger-soft); color: var(--danger); }
.portal-decision-pending  { background: var(--warn-soft); color: var(--warn); }

/* Contact */
.portal-contact-row { display: flex; align-items: center; gap: 12px; }
.portal-contact-name { font-size: 13px; font-weight: 600; color: var(--text); }
.portal-contact-meta { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.portal-contact-meta a { color: var(--accent); text-decoration: none; }

/* Login screen */
.portal-login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.portal-login-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 30px;
  text-align: center;
}
.portal-login-logo { width: 48px; height: 48px; margin: 0 auto 14px; display: block; }
.portal-login-brand { font-size: 16px; font-weight: 600; color: var(--text); }
.portal-login-subtitle { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; margin-bottom: 24px; }
.portal-login-form { display: flex; flex-direction: column; gap: 16px; text-align: left; }
.portal-login-btn {
  background: var(--accent); color: #fff;
  border: none; border-radius: 7px;
  padding: 11px 14px;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
}
.portal-login-btn:hover { opacity: 0.92; }
.portal-login-help { font-size: 11.5px; color: var(--text-3); line-height: 1.5; margin: 0; text-align: center; }
.portal-login-error { font-size: 12px; color: var(--danger); }
.portal-login-sent { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 18px 4px; }
.portal-login-sent-icon { font-size: 36px; color: var(--accent); }
.portal-login-sent-title { font-size: 15px; font-weight: 600; color: var(--text); }
.portal-login-sent-body { font-size: 12.5px; color: var(--text-2); line-height: 1.55; }
.portal-login-link { font-size: 12px; color: var(--accent); text-decoration: none; margin-top: 8px; }

/* ============================================================
   BORROWER QUERIES — internal case detail surface.
   Companion to the borrower portal: ops/credit raise + close queries
   here, and the borrower's reply lands as a Task. Styled to slot in
   between the docs card and the timeline card.
   ============================================================ */
.bq-card {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 16px;
}
.bq-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.bq-card-title {
  font-size: 13px; font-weight: 600; color: var(--text);
  display: flex; align-items: center; gap: 10px;
}
.bq-open-pill {
  font-size: 10.5px; padding: 2px 8px; border-radius: 4px;
  background: var(--warn-soft); color: var(--warn);
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px;
}
.bq-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.bq-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--surface-2);
}
.bq-item-open { border-color: var(--warn); }
.bq-item-answered { border-color: var(--accent); }
.bq-item-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.bq-item-subject { font-size: 12.5px; font-weight: 600; color: var(--text); }
.bq-item-status {
  font-size: 10px; padding: 2px 7px; border-radius: 4px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.bq-item-status-open { background: var(--warn-soft); color: var(--warn); }
.bq-item-status-answered { background: var(--accent-bg); color: var(--accent); }
.bq-item-status-closed { background: var(--success-soft); color: var(--success); }
.bq-item-body { font-size: 12px; color: var(--text-2); line-height: 1.5; margin-bottom: 6px; }
.bq-item-meta { font-size: 10.5px; color: var(--text-3); }
/* Action items — agent tasks share the borrower-query item look. */
.ai-task { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; background: var(--surface-2); }
.ai-task-pending { border-color: var(--warn); }
.ai-task-completed { opacity: 0.62; }
.ai-task-flag { font-size: 11.5px; color: var(--warn); margin-bottom: 6px; }
/* Case allocation timeline popup + reassign. */
.cdv2-alloc-btn { background: none; border: none; cursor: pointer; font-size: 13px; padding: 0 2px; opacity: 0.7; }
.cdv2-alloc-btn:hover { opacity: 1; }
.alloc-ov { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 9999; display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; overflow: auto; }
.alloc-modal { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; max-width: 480px; width: 100%; padding: 18px; }
.alloc-modal-head { display: flex; align-items: center; justify-content: space-between; font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 12px; }
.alloc-current { font-size: 13px; color: var(--text-2); margin-bottom: 12px; }
.alloc-reassign { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); margin-bottom: 14px; }
.alloc-reassign .wl-input { flex: 1; min-width: 120px; }
.alloc-tl-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-3); font-weight: 600; margin-bottom: 8px; }
.alloc-timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0; }
.alloc-tl-item { border-left: 2px solid var(--border); padding: 0 0 14px 14px; position: relative; }
.alloc-tl-item:before { content: ''; position: absolute; left: -5px; top: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.alloc-tl-item:last-child { padding-bottom: 0; }
.alloc-tl-to { font-size: 13px; font-weight: 600; color: var(--text); }
.alloc-tl-tag { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.3px; background: var(--surface-2); color: var(--text-3); padding: 1px 6px; border-radius: 4px; margin-left: 4px; }
.alloc-tl-meta { font-size: 11px; color: var(--text-3); margin-top: 2px; }
/* Inline live document-classifier run (case Documents tab). */
.dc-live { margin: 2px 0 12px; border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; background: var(--surface-2); }
.dc-head { font-size: 12.5px; font-weight: 600; color: var(--text); padding: 8px 12px; border-bottom: 1px solid var(--border); }
.dc-steps { padding: 6px 12px 10px; display: flex; flex-direction: column; gap: 3px; }
.dc-step { font-size: 11.5px; color: var(--text-2); font-family: 'JetBrains Mono', monospace; }
.bq-item-answer {
  margin-top: 8px; padding: 8px 10px;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: 3px;
  font-size: 12px; color: var(--text-2);
}
.bq-item-answer-label { font-size: 10.5px; color: var(--text-3); margin-bottom: 4px; }
.bq-empty { font-size: 12px; color: var(--text-3); padding: 6px 2px; }

/* ============================================================
   BANK STATEMENT ANALYSIS — case-detail card.
   8 ratio chips + totals strip + counterparty / monthly drilldowns.
   ============================================================ */
/* Full-width variant — applied on the dedicated BSA tab so the card
   uses the entire content area and drill-downs sit comfortably with
   no horizontal squeeze. */
.bsa-card-full { padding: 20px 22px; }
.bsa-card-full .bsa-grid {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.bsa-card-full .bsa-cashflow { min-height: 180px; }

/* Always-expanded drill-down section (replaces <details> on the BSA
   tab). Keeps the visual rhythm of the old collapsibles without the
   click-to-expand affordance. */
.bsa-section {
  border-top: 1px solid var(--border);
  margin-top: 16px;
  padding-top: 14px;
}
.bsa-section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.bsa-section-title { font-size: 13.5px; font-weight: 600; color: var(--text); margin: 0; }
.bsa-section-meta {
  font-size: 11px;
  color: var(--text-3);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 999px;
}
.bsa-section-meta-warn { background: var(--warn-soft, #fef3c7); color: var(--warn, #b45309); }
.bsa-section-warn { border-top-color: var(--warn, #f59e0b); }
.bsa-rf-clean {
  padding: 12px 14px;
  background: var(--ok-soft, #ecfdf5);
  color: var(--ok, #047857);
  border-radius: 6px;
  font-size: 12.5px;
  line-height: 1.6;
}

.bsa-card {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 16px;
}
.bsa-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.bsa-card-title {
  font-size: 13px; font-weight: 600; color: var(--text);
  display: flex; align-items: center; gap: 10px;
}
.bsa-card-icon { font-size: 16px; }
.bsa-grade {
  font-size: 10.5px; padding: 2px 8px; border-radius: 4px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.4px;
}
.bsa-grade-green { background: var(--success-soft); color: var(--success); }
.bsa-grade-amber { background: var(--warn-soft); color: var(--warn); }
.bsa-grade-red   { background: var(--danger-soft); color: var(--danger); }
.bsa-grade-info  { background: var(--surface-2); color: var(--text-3); }

.bsa-totals {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px; margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--surface-2); border-radius: 8px;
}
.bsa-totals-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--text-3); font-weight: 600;
}
.bsa-totals-value { font-size: 13px; font-weight: 600; color: var(--text); margin-top: 3px; }

.bsa-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}
.bsa-ratio {
  padding: 10px 12px;
  background: var(--surface-2);
  border-left: 3px solid var(--border);
  border-radius: 4px;
}
.bsa-ratio-green { border-left-color: var(--success); }
.bsa-ratio-amber { border-left-color: var(--warn); }
.bsa-ratio-red   { border-left-color: var(--danger); }
.bsa-ratio-info  { border-left-color: var(--text-3); }
.bsa-ratio-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--text-3); font-weight: 600;
}
.bsa-ratio-value { font-size: 16px; font-weight: 600; color: var(--text); margin: 3px 0 4px; }
.bsa-ratio-hint  { font-size: 11px; color: var(--text-2); }

.bsa-summary {
  margin-top: 14px; padding: 10px 12px;
  border-left: 3px solid var(--accent);
  background: var(--accent-bg);
  border-radius: 4px;
}
.bsa-summary-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--accent); font-weight: 600; margin-bottom: 4px;
}
.bsa-summary-body { font-size: 12px; color: var(--text); line-height: 1.55; }

.bsa-detail-toggle {
  cursor: pointer; font-size: 12px; color: var(--accent);
  font-weight: 500; padding: 4px 0;
}
.bsa-cp-table {
  width: 100%; border-collapse: collapse; margin-top: 8px;
  font-size: 11.5px;
}
.bsa-cp-table th {
  text-align: left; padding: 6px 8px;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.3px;
  color: var(--text-3); font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.bsa-cp-table td {
  padding: 6px 8px; border-bottom: 1px solid var(--border-light);
  color: var(--text-2);
}
.bsa-cp-table td.mono { font-family: 'JetBrains Mono', monospace; }
.bsa-cp-table .bsa-neg { color: var(--danger); }
.bsa-empty { font-size: 12px; color: var(--text-3); padding: 14px 4px; text-align: center; }

/* ============================================================
   BSA — collapsible drill-downs (cashflow / counterparties /
   red flags). Native <details>/<summary>, no JS.
   ============================================================ */
.bsa-detail {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}
.bsa-detail > summary {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
  font-size: 12px;
  color: var(--text);
}
.bsa-detail > summary::-webkit-details-marker { display: none; }
.bsa-detail > summary::before {
  content: '▸';
  font-size: 10px; color: var(--text-3);
  transition: transform 0.12s;
  display: inline-block;
}
.bsa-detail[open] > summary::before { transform: rotate(90deg); }
.bsa-detail-title { font-weight: 600; flex: 1; }
.bsa-detail-meta {
  font-size: 10.5px; padding: 2px 8px; border-radius: 10px;
  background: var(--surface-2); color: var(--text-2);
  font-weight: 600;
}
.bsa-detail-meta-warn { background: var(--warn-soft); color: var(--warn); }
.bsa-detail-warn { border-left: 3px solid var(--warn); }
.bsa-detail-body {
  padding: 0 12px 12px;
  border-top: 1px solid var(--border-light);
  padding-top: 10px;
}

/* 12-bar cashflow (inflow vs outflow per month). Pure-CSS heights. */
.bsa-cashflow {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 6px; height: 110px;
  padding: 6px 4px 0;
}
.bsa-cashflow-month {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  height: 100%;
}
.bsa-cashflow-bars {
  flex: 1; width: 100%;
  display: flex; align-items: flex-end; justify-content: center; gap: 2px;
}
.bsa-cashflow-bar {
  flex: 1; min-width: 0; max-width: 12px;
  border-radius: 2px 2px 0 0;
  min-height: 1px;
}
.bsa-cashflow-bar-in  { background: var(--success); }
.bsa-cashflow-bar-out { background: var(--danger);  opacity: 0.6; }
.bsa-cashflow-label {
  font-size: 9.5px; color: var(--text-3); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.3px;
  white-space: nowrap;
}
.bsa-cashflow-legend {
  display: flex; gap: 14px; margin-top: 10px;
  font-size: 11px; color: var(--text-2);
}
.bsa-cashflow-legend > span { display: inline-flex; align-items: center; gap: 5px; }
.bsa-cashflow-swatch {
  display: inline-block; width: 10px; height: 10px; border-radius: 2px;
}

/* Counterparty extras (table already styled by .bsa-cp-table). */
.bsa-cp-name { color: var(--text); font-weight: 500; }
.bsa-cp-pill {
  margin-left: 6px;
  font-size: 9.5px; padding: 1px 6px; border-radius: 3px;
  background: var(--success-soft); color: var(--success); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.bsa-cp-notes { color: var(--text-3); font-size: 11px; }

/* Red flag groups. */
.bsa-rf-group { margin-bottom: 10px; }
.bsa-rf-group:last-child { margin-bottom: 0; }
.bsa-rf-label {
  font-size: 11px; font-weight: 600; color: var(--text);
  margin-bottom: 4px;
}
.bsa-rf-list {
  margin: 0; padding-left: 20px;
  font-size: 11.5px; color: var(--text-2); line-height: 1.6;
}

/* ============================================================
   ANALYZER (Phase 6 shadow) — facility-math card.
   3 branch partials: origination, PO+Invoice, Working Capital.
   ============================================================ */
.analyzer-card {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}
.analyzer-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.analyzer-card-title {
  font-size: 13px; font-weight: 600; color: var(--text);
  display: flex; align-items: center; gap: 10px;
}
.analyzer-card-icon { font-size: 16px; }
.analyzer-shadow-chip {
  font-size: 10.5px; padding: 2px 8px; border-radius: 10px;
  background: var(--warn-soft); color: var(--warn); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.3px;
  cursor: help;
}

.analyzer-body { display: flex; flex-direction: column; gap: 14px; }

/* Headline row: requested → recommended + decision pill. */
.analyzer-headline {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 14px;
  background: var(--surface-2); border-radius: 8px;
}
.analyzer-headline-block { display: flex; flex-direction: column; gap: 3px; }
.analyzer-headline-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--text-3); font-weight: 600;
}
.analyzer-headline-value { font-size: 16px; font-weight: 600; color: var(--text); }
.analyzer-headline-arrow { font-size: 18px; color: var(--text-3); }
.analyzer-pill {
  display: inline-flex; align-items: center;
  margin-left: auto;
  font-size: 11px; padding: 3px 10px; border-radius: 10px;
  font-weight: 600;
  text-transform: capitalize; letter-spacing: 0.3px;
}

/* Stat row (used by origination + working capital). */
.analyzer-stat-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
.analyzer-stat {
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 6px;
}
.analyzer-stat-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--text-3); font-weight: 600;
}
.analyzer-stat-value { font-size: 14px; font-weight: 600; color: var(--text); margin-top: 3px; }

/* Origination — grade summary chips. */
.analyzer-grade-summary { display: flex; gap: 6px; margin-top: 5px; flex-wrap: wrap; }
.analyzer-grade-chip {
  font-size: 11px; padding: 2px 8px; border-radius: 4px; font-weight: 600;
}
.analyzer-grade-green { background: var(--success-soft); color: var(--success); }
.analyzer-grade-amber { background: var(--warn-soft); color: var(--warn); }
.analyzer-grade-red   { background: var(--danger-soft); color: var(--danger); }

.analyzer-rationale {
  font-size: 12px; color: var(--text); line-height: 1.55;
  padding: 10px 12px;
  border-left: 3px solid var(--accent);
  background: var(--accent-bg);
  border-radius: 4px;
}

/* PO + Invoice — two-stage layout. */
.analyzer-stages {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
@media (max-width: 720px) {
  .analyzer-stages { grid-template-columns: 1fr; }
}
.analyzer-stage {
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: 8px;
}
.analyzer-stage-head {
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.analyzer-stage-num {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--accent); font-weight: 700;
}
.analyzer-stage-name { font-size: 12px; font-weight: 600; color: var(--text); flex: 1; }
.analyzer-stage-days {
  font-size: 11px; color: var(--text-2);
  padding: 1px 6px; background: var(--surface); border-radius: 3px;
}
.analyzer-stage-rows { display: flex; flex-direction: column; gap: 5px; }
.analyzer-stage-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--text-2);
}
.analyzer-stage-row > span:first-child { color: var(--text-3); }
.analyzer-stage-row .mono { font-family: 'JetBrains Mono', monospace; color: var(--text); }
.analyzer-stage-row-total {
  padding-top: 6px; margin-top: 4px;
  border-top: 1px dashed var(--border);
  font-weight: 600;
}
.analyzer-stage-row-total > span:first-child { color: var(--text); }
.analyzer-stage-row-total .mono { font-weight: 700; }

/* Working Capital — utilisation bar. */
.analyzer-util {
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: 8px;
}
.analyzer-util-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 6px;
}
.analyzer-util-label {
  font-size: 11px; font-weight: 600; color: var(--text);
  text-transform: uppercase; letter-spacing: 0.3px;
}
.analyzer-util-value { font-size: 16px; font-weight: 700; color: var(--text); }
.analyzer-util-bar-track {
  height: 10px;
  background: var(--surface);
  border-radius: 5px;
  overflow: hidden;
}
.analyzer-util-bar {
  height: 100%;
  border-radius: 5px;
  transition: width 0.2s;
}
.analyzer-util-bar-green { background: var(--success); }
.analyzer-util-bar-amber { background: var(--warn); }
.analyzer-util-bar-red   { background: var(--danger); }
.analyzer-util-foot {
  display: flex; justify-content: space-between;
  margin-top: 6px;
  font-size: 11px; color: var(--text-3);
}

.analyzer-empty {
  font-size: 12px; color: var(--text-3); padding: 14px 4px; text-align: center;
}

/* Per-agent "↻ Re-run" link on the case-detail agent card (gap 4.2). */
.agent-rerun-link {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 6px;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-block;
  transition: background 0.1s, color 0.1s;
}
.agent-rerun-link:hover {
  background: var(--accent-bg);
  color: var(--accent);
}

/* Portal — borrower-side "Ask the team" form (gap 10.6). */
.portal-ask-form { display: flex; flex-direction: column; gap: 4px; padding: 12px; background: var(--surface-2); border-radius: 8px; }

/* Internal case-detail — direction styling for borrower-initiated queries. */
.bq-item.bq-from-borrower {
  border-left: 3px solid var(--accent);
  background: linear-gradient(to right, var(--accent-bg) 0px, var(--surface-2) 8px);
}
.bq-internal-reply textarea {
  width: 100%;
  font-family: inherit;
  font-size: 12px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* ============================================================
   CASE-DETAIL V2 — tabbed layout with sticky agent strip +
   always-visible right-pane agent reasoning trace.
   ============================================================ */
/* v2 case detail: claim the viewport below the sticky topnav so the right
   trace panel can be fixed-in-place (never scrolls with content) and the
   left tab content scrolls independently. Topnav is ~52px tall.
   NOTE: the flex layout is scoped to `.active` so inactive sections still
   honour the base `.screen { display: none }` rule.                        */
.case-detail-v2 { padding: 20px 28px 0; max-width: 100%; }
.case-detail-v2.active {
  height: calc(100vh - 52px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.case-detail-v2 .breadcrumb { flex: 0 0 auto; margin-bottom: 8px; }

/* Compact header */
.cdv2-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 18px;
}
.cdv2-header-main { flex: 1; min-width: 0; }
.cdv2-title {
  font-size: 19px; font-weight: 600; color: var(--text);
  margin: 0 0 4px;
}
.cdv2-meta { font-size: 12.5px; color: var(--text-3); }
/* Inline label preceding a Customer ID / Loan ID value in the case-detail
   meta line (gap 1.6). Reads as a tiny uppercase chip so the value next to
   it still dominates visually. */
.cdv2-id-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  font-weight: 600;
  margin-right: 2px;
}

/* Loan & transactions card on the Borrower tab (gap 1.6). Surfaces
   Customer ID / Loan ID at the card head and every Drawdown / Repayment
   Transaction ID inline so the customer sees the three-level relationship
   on one screen. */
.loan-tx-head {
  display: flex; align-items: baseline; justify-content: space-between;
  flex-wrap: wrap; gap: 8px 14px;
  margin-bottom: 12px;
}
.loan-tx-ids {
  display: flex; align-items: baseline; gap: 6px;
  font-size: 12px; color: var(--text-2);
}
.loan-tx-ids-sep { color: var(--text-3); }
.loan-tx-section-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--text-3); font-weight: 600;
  margin-bottom: 6px;
}
.loan-tx-table {
  width: 100%; border-collapse: collapse;
  font-size: 12px;
}
.loan-tx-table th {
  text-align: left; padding: 6px 8px;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.3px;
  color: var(--text-3); font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.loan-tx-table th.num,
.loan-tx-table td.num { text-align: right; }
.loan-tx-table td {
  padding: 6px 8px; border-bottom: 1px solid var(--border-light);
  color: var(--text-2);
}
.loan-tx-table tr:last-child td { border-bottom: none; }
.loan-tx-id { color: var(--text-3); }
.loan-tx-empty {
  font-size: 12px; color: var(--text-3);
  padding: 16px 4px; text-align: center;
}
.cdv2-status-on_track  { color: var(--success); font-weight: 500; }
.cdv2-status-at_risk   { color: var(--warn);    font-weight: 500; }
.cdv2-status-breach    { color: var(--danger);  font-weight: 500; }
.cdv2-status-blocked   { color: var(--danger);  font-weight: 500; }
.cdv2-status-completed { color: var(--accent);  font-weight: 500; }
.cdv2-header-pills { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }

/* Product chip — Phase 1 of Unified Case Pipeline. Cosmetic surface
   for case.product. Generic is the neutral default; specific products
   get a subtle accent so the operator can read product at a glance. */
.cdv2-product-chip {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2px;
  border: 1px solid;
  white-space: nowrap;
}
.cdv2-product-generic {
  background: var(--surface-2);
  color: var(--text-3);
  border-color: var(--border);
}
.cdv2-product-po {
  background: var(--accent-bg);
  color: var(--accent);
  border-color: var(--accent);
}
.cdv2-product-wc {
  background: var(--success-soft, #e8f5e9);
  color: var(--success);
  border-color: var(--success);
}
.cdv2-product-tf {
  background: var(--warn-soft, #fff3e0);
  color: var(--warn);
  border-color: var(--warn);
}

/* ─── Agent strip (sticky) ─── */
.cdv2-strip-wrap {
  flex: 0 0 auto;
  background: var(--bg);
  padding: 8px 0 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.cdv2-header { flex: 0 0 auto; }
.cdv2-strip-empty { font-size: 11.5px; color: var(--text-3); padding: 6px 4px; }

/* ─── Agent pipeline — connected nodes showing sequence + progress ─── */
.cdv2-pipeline {
  display: flex;
  align-items: flex-start;
  gap: 0;
  overflow-x: auto;
  padding: 6px 2px 4px;
}
.cdv2-pipeline::-webkit-scrollbar { height: 4px; }
.cdv2-pipeline::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.cdv2-pl-node {
  flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: center;
  gap: 6px;
  min-width: 86px;
  padding: 0 6px;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  border-radius: 6px;
  transition: background 0.12s;
}
.cdv2-pl-node:hover { background: var(--surface-2); }
.cdv2-pl-node:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.cdv2-pl-circle {
  position: relative;
  z-index: 1;
  width: 26px; height: 26px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  background: var(--surface-2);
  color: var(--text-3);
  border: 2px solid var(--border);
  box-sizing: border-box;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.cdv2-pl-label {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 500;
  white-space: nowrap;
  text-align: center;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

/* Status variants on the node */
.cdv2-pl-complete .cdv2-pl-circle { background: var(--success); color: #fff; border-color: var(--success); }
.cdv2-pl-complete .cdv2-pl-label  { color: var(--text-2); }

.cdv2-pl-flagged  .cdv2-pl-circle { background: var(--warn); color: #fff; border-color: var(--warn); }
.cdv2-pl-flagged  .cdv2-pl-label  { color: var(--warn); }

.cdv2-pl-failed   .cdv2-pl-circle { background: var(--danger); color: #fff; border-color: var(--danger); }
.cdv2-pl-failed   .cdv2-pl-label  { color: var(--danger); }

.cdv2-pl-running  .cdv2-pl-circle {
  background: var(--accent); color: #fff; border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-bg);
  animation: cdv2-pulse 1.4s ease-in-out infinite;
}
.cdv2-pl-running  .cdv2-pl-label  { color: var(--accent); font-weight: 600; }

.cdv2-pl-queued   .cdv2-pl-circle { background: var(--surface); border-style: dashed; }
.cdv2-pl-idle     .cdv2-pl-circle { background: transparent; }

/* Ghost chip — agents the product pipeline expects but that haven't
   fired yet (no AgentRun row). Muted so executed agents still dominate
   the strip. Not clickable: no cursor pointer, no hover effect. */
.cdv2-pl-ghost {
  opacity: 0.5;
  cursor: default;
}
.cdv2-pl-ghost:hover { background: transparent; }
.cdv2-pl-ghost .cdv2-pl-circle {
  background: transparent;
  border-style: dashed;
  color: var(--text-3);
}
.cdv2-pl-ghost .cdv2-pl-label { color: var(--text-3); font-weight: 400; }

/* "Active" = currently selected; right pane shows this agent's trace */
.cdv2-pl-node.active .cdv2-pl-circle { box-shadow: 0 0 0 3px var(--accent-bg); }
.cdv2-pl-node.active.cdv2-pl-running .cdv2-pl-circle { box-shadow: 0 0 0 5px var(--accent-bg); }
.cdv2-pl-node.active .cdv2-pl-label  { color: var(--text); font-weight: 600; }

/* Connecting line between consecutive nodes — aligned with circle centerline.
   The `done` variant fills the segment with success-green to visually show
   how far the pipeline has progressed.                                       */
.cdv2-pl-link {
  flex: 1 0 18px;
  min-width: 16px;
  max-width: 64px;
  height: 2px;
  margin-top: 12px;        /* aligns with circle center (26/2 - 2/2 = 12) */
  margin-left: -4px;
  margin-right: -4px;
  background: var(--border);
  border-radius: 1px;
  align-self: flex-start;
  transition: background 0.2s;
}
.cdv2-pl-link.done { background: var(--success); }

/* Live-status line below the strip */
.cdv2-strip-live {
  display: flex; align-items: center; gap: 8px;
  margin-top: 8px;
  padding: 4px 4px;
  font-size: 11.5px;
  color: var(--text-2);
}
.cdv2-live-dot {
  width: 6px; height: 6px; border-radius: 50%;
  display: inline-block;
  background: var(--text-3);
}
.cdv2-live-dot.cdv2-chip-running  { background: var(--accent); animation: cdv2-pulse 1.4s ease-in-out infinite; }
.cdv2-live-dot.cdv2-chip-complete { background: var(--success); }
.cdv2-live-dot.cdv2-chip-flagged  { background: var(--warn); }
.cdv2-live-dot.cdv2-chip-failed   { background: var(--danger); }
@keyframes cdv2-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.cdv2-live-agent { font-weight: 600; color: var(--text); }
.cdv2-live-sep { color: var(--text-3); }
.cdv2-live-msg { flex: 1; min-width: 0; }
.cdv2-live-time { color: var(--text-3); font-size: 10.5px; }

/* ─── Body two-pane layout ───
   The body fills the remaining viewport height after header + strip.
   Each pane scrolls independently — the right trace panel is fixed in
   place visually, while the left tab content scrolls behind its sticky
   tab bar.                                                                */
/* Two-column body — main tab content + collapsible reasoning column.
   Default state: right column expanded (full reasoning trace visible).
   When the section carries data-drawer-collapsed="1", the right column
   shrinks to a 44px vertical rail; only the [data-role="rail"] child
   is visible inside it. Clicking the rail expands the column back. */
.cdv2-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  overflow: hidden;
  padding-bottom: 24px;
  transition: grid-template-columns 220ms cubic-bezier(0.16, 1, 0.3, 1);
}
.case-detail-v2[data-drawer-collapsed="1"] .cdv2-body {
  grid-template-columns: minmax(0, 1fr) 44px;
}
.cdv2-left {
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
}
.cdv2-left .cdv2-tabs {
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
  margin-top: -2px;
}

/* Tabs */
.cdv2-tabs {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
  overflow-x: auto;
}
.cdv2-tabs::-webkit-scrollbar { height: 0; }
.cdv2-tab {
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 12.5px;
  padding: 9px 14px;
  color: var(--text-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.1s, border-color 0.1s;
}
.cdv2-tab:hover { color: var(--text-2); }
.cdv2-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 500;
}

/* Panes */
.cdv2-pane { display: none; }
.cdv2-pane.active { display: block; }

/* Section titles inside tabs */
.cdv2-section-title { font-size: 13px; font-weight: 600; color: var(--text); margin: 0 0 12px; }

/* Summary tab todos */
.cdv2-summary-todos { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.cdv2-todo {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--surface-2);
  border-radius: 8px;
  font-size: 12.5px;
}
.cdv2-todo-warn { background: var(--warn-soft); color: var(--warn); }
.cdv2-todo-info { background: var(--accent-bg); color: var(--accent); }
.cdv2-todo-count { font-size: 16px; font-weight: 600; min-width: 22px; text-align: center; }
.cdv2-todo-action { margin-left: auto; cursor: pointer; font-size: 11.5px; text-decoration: underline; }

/* Findings groups in Analysis tab */
.cdv2-findings-group { padding: 10px 0; border-top: 1px solid var(--border-light); }
.cdv2-findings-group:first-child { border-top: 0; padding-top: 0; }
.cdv2-findings-agent { font-size: 11.5px; font-weight: 600; color: var(--text); margin-bottom: 6px; }

.cdv2-empty { padding: 24px; text-align: center; color: var(--text-3); font-size: 12.5px; }

/* Credit Note tab — full inline render */
.cdv2-cn-card { padding: 18px 20px; }
.cdv2-cn-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
  padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.cdv2-cn-meta { font-size: 11.5px; color: var(--text-3); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cdv2-cn-open {
  font-size: 11.5px; color: var(--accent); text-decoration: none;
  white-space: nowrap; padding-top: 4px;
}
.cdv2-cn-open:hover { text-decoration: underline; }
.cdv2-cn-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px 18px; margin-bottom: 16px;
  padding-bottom: 14px; border-bottom: 1px solid var(--border-light);
}
.cdv2-cn-field { display: flex; flex-direction: column; gap: 3px; }
.cdv2-cn-flabel { font-size: 10.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.4px; }
.cdv2-cn-fvalue { font-size: 13px; color: var(--text); font-weight: 500; }
.cdv2-cn-section { margin-bottom: 18px; }
.cdv2-cn-section:last-child { margin-bottom: 0; }
.cdv2-cn-slabel {
  font-size: 11px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.cdv2-cn-risk-flags { display: flex; flex-wrap: wrap; gap: 6px; }
.cdv2-cn-flag {
  font-size: 11px; padding: 3px 8px; border-radius: 4px;
  background: var(--surface-2); color: var(--text-2);
}
.cdv2-cn-flag.danger { background: var(--danger-soft, #ffebee); color: var(--danger); }
.cdv2-cn-flag.warn   { background: var(--warn-soft, #fff3e0); color: var(--warn); }
.cdv2-cn-flag.info   { background: var(--accent-bg); color: var(--accent); }
.cdv2-cn-findings { display: flex; flex-direction: column; gap: 6px; }
.cdv2-cn-finding { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.cdv2-cn-finding-icon { font-weight: 600; font-size: 13px; }

/* The body — markdown-rendered credit note */
.cdv2-cn-body {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px 18px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
}
.cdv2-cn-body h1 { font-size: 15px; margin: 0 0 10px; font-weight: 600; }
.cdv2-cn-body h2 { font-size: 13.5px; margin: 16px 0 8px; font-weight: 600; }
.cdv2-cn-body h3 { font-size: 12.5px; margin: 12px 0 6px; font-weight: 600; color: var(--text-2); }
.cdv2-cn-body p { margin: 6px 0; }
.cdv2-cn-body strong { color: var(--text); font-weight: 600; }
.cdv2-cn-body ul, .cdv2-cn-body ol { margin: 8px 0 8px 22px; padding: 0; }
.cdv2-cn-body li { margin: 4px 0; }
.cdv2-cn-body table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 12px; }
.cdv2-cn-body th, .cdv2-cn-body td { padding: 6px 10px; border: 1px solid var(--border); text-align: left; }
.cdv2-cn-body th { background: var(--surface-2); font-weight: 600; }
.cdv2-cn-body code { background: var(--surface-2); padding: 1px 5px; border-radius: 3px; font-size: 11.5px; }
.cdv2-cn-body blockquote { margin: 8px 0; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--surface-2); color: var(--text-2); border-radius: 0 4px 4px 0; }
.cdv2-cn-empty { color: var(--text-3); font-style: italic; }

.cdv2-cn-felice {
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  border-radius: 0 6px 6px 0;
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.55;
}
.cdv2-cn-felice strong { color: var(--text); }

.cdv2-cn-banner {
  margin-top: 16px;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--text);
  border: 1px solid;
}
.cdv2-cn-banner.success { background: var(--success-soft, #e8f5e9); border-color: var(--success); }
.cdv2-cn-banner.danger  { background: var(--danger-soft, #ffebee);  border-color: var(--danger); }
.cdv2-cn-banner.warn    { background: var(--warn-soft, #fff3e0);    border-color: var(--warn); }

/* ─── Right column — agent reasoning trace ───
   Lives inside the cdv2-body grid as a normal column. Two states
   driven by [data-drawer-collapsed] on the .case-detail-v2 parent:
     - default (expanded) → full reasoning panel + chips visible
     - collapsed         → 44px vertical rail with rotated label;
                          click rail to re-expand. */
.cdv2-right {
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  align-self: stretch;
  position: relative;
  transition: padding 200ms ease;
}

/* Vertical rail shown when the column is collapsed. Hidden by
   default. Clicking it expands the column back. */
.cdv2-rail {
  display: none;
  position: absolute;
  inset: 0;
  align-items: flex-start;
  justify-content: center;
  padding-top: 16px;
  gap: 12px;
  cursor: pointer;
  background: transparent;
  border: none;
  width: 100%;
  height: 100%;
  font-family: inherit;
  color: var(--text-2);
  border-radius: 10px;
  transition: background 0.12s, color 0.12s;
}
.cdv2-rail:hover {
  background: var(--bg);
  color: var(--text);
}
.cdv2-rail-stack {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px;
}
.cdv2-rail-icon {
  font-size: 16px;
  line-height: 1;
}
.cdv2-rail-label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--text-2);
}
.cdv2-rail-chevron {
  font-size: 13px;
  color: var(--text-3);
}

/* Collapsed state: shrink padding, hide everything except the rail. */
.case-detail-v2[data-drawer-collapsed="1"] .cdv2-right {
  padding: 0;
  overflow: hidden;
}
.case-detail-v2[data-drawer-collapsed="1"] .cdv2-right > *:not(.cdv2-rail) {
  display: none !important;
}
.case-detail-v2[data-drawer-collapsed="1"] .cdv2-rail {
  display: flex;
}

/* Header toggle button (label "Reasoning" / "Show trace"). Sits next
   to the stage pill. Click to collapse / expand. */
.cdv2-drawer-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.cdv2-drawer-toggle:hover {
  background: var(--surface);
  border-color: var(--text-3);
  color: var(--text);
}
.cdv2-drawer-toggle-icon { font-size: 13px; line-height: 1; }
.cdv2-drawer-toggle-label { font-size: 12px; }

/* "Collapse trace" button inside the expanded header. Sits beside
   the "click any chip…" hint. */
.cdv2-drawer-close {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  width: 26px; height: 26px;
  font-size: 13px;
  line-height: 1;
  color: var(--text-3);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.cdv2-drawer-close:hover {
  background: var(--bg);
  color: var(--text);
}
.cdv2-right-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.cdv2-right-title { font-size: 12.5px; font-weight: 600; color: var(--text); }
.cdv2-right-hint { font-size: 10.5px; color: var(--text-3); }

/* Document modal — opened from the Documents tab. Reuses the
   .modal-overlay scaffolding (display:none → flex on `.open`). */
.cdv2-doc-row { cursor: pointer; transition: background 0.08s; }
.cdv2-doc-row:hover { background: var(--surface-2); }

.cdv2-doc-modal-card {
  background: var(--surface);
  border-radius: 12px;
  width: 100%;
  max-width: 920px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0,0,0,0.22);
  overflow: hidden;
}
.cdv2-doc-modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.cdv2-doc-modal-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cdv2-doc-modal-icon { font-size: 22px; line-height: 1; }
.cdv2-doc-modal-name { font-size: 15px; font-weight: 600; color: var(--text); }
.cdv2-doc-modal-sub  { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.cdv2-doc-modal-close {
  border: 0; background: transparent;
  font-size: 18px; color: var(--text-3);
  cursor: pointer; padding: 4px 8px;
  border-radius: 4px;
}
.cdv2-doc-modal-close:hover { background: var(--surface-2); color: var(--text); }

.cdv2-doc-modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px 22px;
  background: var(--bg);
}
.cdv2-doc-modal-foot {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 12px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.cdv2-doc-open { font-size: 12px; color: var(--accent); text-decoration: none; }
.cdv2-doc-open:hover { text-decoration: underline; }

/* Document body — markdown / HTML rendered */
.cdv2-doc-body {
  font-size: 13px; line-height: 1.6; color: var(--text);
  max-width: 100%; word-wrap: break-word; overflow-wrap: break-word;
}
.cdv2-doc-body h1, .cdv2-doc-body h2, .cdv2-doc-body h3 { font-weight: 600; margin: 12px 0 6px; }
.cdv2-doc-body h1 { font-size: 15px; }
.cdv2-doc-body h2 { font-size: 14px; }
.cdv2-doc-body h3 { font-size: 13px; color: var(--text-2); }
.cdv2-doc-body p { margin: 6px 0; }
.cdv2-doc-body ul, .cdv2-doc-body ol { margin: 8px 0 8px 22px; }
.cdv2-doc-body table { width: 100%; border-collapse: collapse; font-size: 12px; margin: 10px 0; }
.cdv2-doc-body th, .cdv2-doc-body td { padding: 6px 10px; border: 1px solid var(--border); text-align: left; }
.cdv2-doc-body th { background: var(--surface-2); font-weight: 600; }
.cdv2-doc-body img { max-width: 100%; height: auto; border-radius: 4px; }
.cdv2-doc-body pre { background: var(--surface-2); padding: 10px 12px; border-radius: 4px; overflow-x: auto; font-size: 11.5px; }
.cdv2-doc-iframe {
  width: 100%; height: 65vh; min-height: 420px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg);
}
.cdv2-doc-fallback { margin-top: 10px; font-size: 12px; text-align: center; }
.cdv2-doc-fallback a { color: var(--accent); text-decoration: none; }
.cdv2-doc-fallback a:hover { text-decoration: underline; }
/* Only the agent matching the active chip should render — the other
   trace divs stay hidden. (Lost in an earlier cleanup.)                 */
.cdv2-trace { display: none; }
.cdv2-trace.active { display: block; }

.cdv2-trace-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.cdv2-trace-title { font-size: 13px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 8px; }
.cdv2-trace-icon { font-size: 16px; }
.cdv2-trace-status {
  font-size: 10.5px; padding: 2px 8px; border-radius: 4px;
  background: var(--surface-2); font-weight: 500;
}

/* Inline reasoning steps — subtle and clickable (full detail opens in modal).
   Less visual weight than before: no surface fill, no coloured left border,
   tighter spacing, body truncated to 2 lines. Hover reveals "details →". */
.cdv2-steps { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.cdv2-step {
  position: relative;
  padding: 8px 4px 8px 4px;
  border-bottom: 1px solid var(--border-light, var(--border));
  cursor: pointer;
  transition: background 0.12s;
}
.cdv2-step:last-child { border-bottom: 0; }
.cdv2-step:hover { background: var(--surface-2); }
.cdv2-step::after {
  content: '↗';
  position: absolute;
  top: 8px; right: 6px;
  font-size: 11px;
  color: var(--text-3);
  opacity: 0;
  transition: opacity 0.12s;
}
.cdv2-step:hover::after { opacity: 1; }

.cdv2-step-head {
  display: flex; align-items: baseline; justify-content: flex-start;
  gap: 8px;
  margin-bottom: 2px;
}
.cdv2-step-label {
  font-size: 10px; color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 500;
}
.cdv2-step-conf {
  font-size: 10px; color: var(--text-3);
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 3px;
}
.cdv2-step-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 2px;
  padding-right: 16px;
}
.cdv2-step-body {
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ─── Step-detail modal — shared per case-detail section ─── */
.cdv2-step-modal-card {
  background: var(--surface);
  border-radius: 12px;
  width: 100%;
  max-width: 720px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0,0,0,0.22);
  overflow: hidden;
}
.cdv2-step-modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.cdv2-step-modal-eyebrow {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.cdv2-step-modal-case {
  font-size: 10.5px;
  color: var(--text-3);
  letter-spacing: 0.5px;
}
.cdv2-step-modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px 22px;
}
.cdv2-step-modal-foot {
  flex: 0 0 auto;
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 12px 22px;
  border-top: 1px solid var(--border);
}

/* Inside the modal body (rendered from the step's <template> clone) */
.cdv2-stepm-meta {
  font-size: 10.5px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.cdv2-stepm-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 6px;
  line-height: 1.3;
}
.cdv2-stepm-sub {
  font-size: 11.5px;
  color: var(--text-3);
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-light, var(--border));
}
.cdv2-stepm-sub strong { color: var(--text-2); font-weight: 600; }
.cdv2-stepm-section { margin-bottom: 16px; }
.cdv2-stepm-section:last-child { margin-bottom: 0; }
.cdv2-stepm-slabel {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.cdv2-stepm-body {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
}
.cdv2-stepm-json {
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-2);
  background: var(--surface-2);
  padding: 12px 14px;
  border-radius: 6px;
  margin: 0;
  overflow-x: auto;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  max-height: 320px;
  overflow-y: auto;
}

.cdv2-trace-empty { padding: 14px 6px; font-size: 12px; color: var(--text-3); text-align: center; }
.cdv2-trace-footer {
  margin-top: 14px; padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end;
}

/* Narrower screens — drop the fixed-viewport layout, let the page scroll
   naturally and stack the panes. Strip becomes sticky again so the agent
   chips stay visible while scrolling.                                      */
@media (max-width: 880px) {
  .case-detail-v2.active {
    height: auto;
    display: block;
    overflow: visible;
    padding: 24px 28px;
  }
  .cdv2-strip-wrap { position: sticky; top: 0; z-index: 5; }
  .cdv2-body {
    display: block;
    padding-bottom: 0;
    overflow: visible;
  }
  .cdv2-left { overflow-y: visible; padding-right: 0; }
  .cdv2-left .cdv2-tabs { position: static; background: transparent; }
  /* Reasoning drawer stays a fixed slide-in even on small screens —
     width clamps to 92vw via the base rule, so it doesn't overflow. */
}
