/* SBA Loan Exchange — Staff Console styles (Phase 31, D-01).
 *
 * External same-origin stylesheet so the strict admin CSP holds with
 * style-src 'self' (NO inline <style> block and NO inline style="" attribute in
 * any admin/*.html). ALL console styling — the left-nav shell, sidebar, content
 * area, status cards (green/red), the Chart.js container, alert/badge styling,
 * and the Tabulator table chrome — lives here, selector-based. Dynamic styles in
 * js/console.js are set via the DOM .style API or by toggling these classes,
 * never via an injected style="" string (which style-src 'self' would block).
 *
 * Palette mirrors the proven frontend/admin.html dark theme for visual continuity.
 */

:root {
  color-scheme: dark;
  --g: #2e7d32;
  --g2: #4caf50;
  --g3: #81c784;
  --o2: #ef6c00;
  --o3: #ffb74d;
  --b2: #1976d2;
  --b3: #64b5f6;
  --dark: #0a0a0a;
  --dark2: #111;
  --dark3: #161616;
  --dark4: #1c1c1c;
  --border: #222;
  --border2: #2a2a2a;
  --border3: #333;
  --txt: #e8e8e8;
  --txt2: #a0a0a0;
  --txt3: #8a8a8a;
  --gold: #f9a825;
  --red: #e53935;
  --crit: #e53935;
  --warn: #ffb74d;
  --info: #64b5f6;
  --head: Georgia, "Times New Roman", serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  background: var(--dark);
  color: var(--txt);
  font-family: var(--body);
  font-size: 14px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ─────────────────────────────────────────────
   CONSOLE SHELL — persistent left-nav + swappable main
   ───────────────────────────────────────────── */
.console {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

@media (max-width: 760px) {
  .console {
    grid-template-columns: 1fr;
  }
}

/* SIDEBAR */
.sidebar {
  background: var(--dark2);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  width: 30px;
  height: 30px;
  background: var(--g);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: #fff;
}

.brand-text {
  font-family: var(--head);
  font-size: 16px;
}

.brand-accent {
  color: var(--g2);
}

.staff-badge {
  display: inline-block;
  align-self: flex-start;
  padding: 3px 10px;
  border: 1px solid #2e7d3255;
  background: #2e7d3222;
  color: var(--g2);
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--txt2);
  padding: 10px 12px;
  font-size: 13px;
  font-family: var(--body);
  cursor: pointer;
  transition: all 0.15s;
}

.nav-item:hover {
  border-color: var(--border2);
  color: var(--txt);
  background: var(--dark3);
}

.nav-item.active {
  border-color: var(--g2);
  color: var(--g2);
  background: #2e7d3214;
}

/* canSee() hides nav items the role can't reach (D-07) by toggling the .is-hidden class. */
.is-hidden {
  display: none;
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.user-role {
  font-size: 11px;
  color: var(--txt3);
  text-transform: capitalize;
}

/* MAIN */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 58px;
  background: var(--dark2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.view-title {
  font-family: var(--head);
  font-size: 20px;
  font-weight: 500;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.refresh-meta {
  font-size: 11px;
  color: var(--txt3);
}

.content {
  padding: 24px;
  flex: 1;
}

/* BUTTONS */
.btn {
  background: var(--dark3);
  border: 1px solid var(--border2);
  color: var(--txt2);
  border-radius: 7px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--body);
  transition: all 0.15s;
}

.btn:hover {
  border-color: var(--g2);
  color: var(--g2);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-ghost {
  background: none;
}

.mini {
  background: none;
  border: 1px solid var(--border2);
  color: var(--txt3);
  border-radius: 5px;
  padding: 4px 9px;
  font-size: 11px;
  cursor: pointer;
}

.mini:hover {
  border-color: var(--g2);
  color: var(--g2);
}

/* ─────────────────────────────────────────────
   PANELS + LAYOUT
   ───────────────────────────────────────────── */
.panel {
  background: var(--dark2);
  border: 1px solid var(--border2);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.panel-title {
  font-family: var(--head);
  font-size: 16px;
}

.panel-title .count {
  font-size: 12px;
  color: var(--txt3);
  margin-left: 8px;
}

.loading {
  text-align: center;
  padding: 40px;
  color: var(--txt3);
}

.empty {
  text-align: center;
  padding: 30px;
  color: var(--txt3);
  font-size: 13px;
}

.empty .big {
  font-size: 28px;
  margin-bottom: 8px;
}

.error-note {
  text-align: center;
  padding: 30px;
  color: var(--txt3);
  font-size: 13px;
}

/* ─────────────────────────────────────────────
   PIPELINE — Chart.js bar container + stalled callout (D-12)
   ───────────────────────────────────────────── */
.chart-wrap {
  position: relative;
  height: 320px;
  width: 100%;
}

.stalled-callout {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 9px;
  background: var(--dark3);
  border: 1px solid var(--border);
  border-left: 3px solid var(--o3);
  font-size: 13px;
}

.stalled-callout.zero {
  border-left-color: var(--g2);
}

.stalled-callout .stalled-n {
  font-family: var(--head);
  font-size: 18px;
  font-weight: 700;
  color: var(--o3);
}

.stalled-callout.zero .stalled-n {
  color: var(--g2);
}

.stalled-callout .stalled-label {
  color: var(--txt3);
}

/* ─────────────────────────────────────────────
   READINESS — green/red status cards (D-12)
   ───────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.status-card {
  background: var(--dark2);
  border: 1px solid var(--border2);
  border-radius: 12px;
  border-left-width: 4px;
  padding: 18px;
}

.status-card.ok {
  border-left-color: var(--g2);
}

.status-card.down {
  border-left-color: var(--red);
}

.status-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-card.ok .status-dot {
  background: var(--g2);
  box-shadow: 0 0 8px var(--g2);
}

.status-card.down .status-dot {
  background: var(--red);
  box-shadow: 0 0 8px var(--red);
}

.status-name {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-state {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-card.ok .status-state {
  color: var(--g2);
}

.status-card.down .status-state {
  color: var(--red);
}

.status-detail {
  font-size: 12.5px;
  color: var(--txt2);
  margin-bottom: 6px;
}

.status-checked {
  font-size: 11px;
  color: var(--txt3);
}

/* ─────────────────────────────────────────────
   ALERTS feed + money badge (D-14)
   ───────────────────────────────────────────── */
.alert {
  display: flex;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 9px;
  background: var(--dark3);
  border: 1px solid var(--border);
  margin-bottom: 9px;
  border-left-width: 3px;
}

.alert.critical {
  border-left-color: var(--crit);
}

.alert.warning {
  border-left-color: var(--warn);
}

.alert.info {
  border-left-color: var(--info);
}

.alert-body {
  flex: 1;
  min-width: 0;
}

.alert-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
}

.alert-detail {
  font-size: 11.5px;
  color: var(--txt3);
}

.alert-sev {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 4px;
  height: fit-content;
  font-weight: 700;
}

.alert-sev.critical {
  background: rgba(229, 57, 53, 0.15);
  color: var(--crit);
}

.alert-sev.warning {
  background: rgba(255, 183, 77, 0.15);
  color: var(--warn);
}

.alert-sev.info {
  background: rgba(100, 181, 246, 0.15);
  color: var(--info);
}

.alert-actions {
  display: flex;
  gap: 6px;
  align-items: flex-start;
}

/* Class-based money badge (D-14) — replaces UI.stageBadge's CSP-blocked style="" string. */
.money-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(249, 168, 37, 0.16);
  color: var(--gold);
  border: 1px solid #f9a82555;
}

/* ─────────────────────────────────────────────
   CREDIT-BOX editor (Phase 33, LEND-04 / D-03a) — the "Versioned" badge + the editor
   form grid + the inline-checkbox layout. Selector-based only (strict CSP style-src
   'self'); console.js sets NO inline style="". Reuses existing --* tokens (no new hex).
   ───────────────────────────────────────────── */

/* The "Versioned" badge — reuses the .money-badge visual recipe with the --gold token, but is
   NOT a money badge (it flags that a save writes a new version, preserving history). */
.versioned-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(249, 168, 37, 0.16);
  color: var(--gold);
  /* gold border via an rgba alpha (NOT a new theme hex) — mirrors the Phase-33 backdrop pattern. */
  border: 1px solid rgba(249, 168, 37, 0.33);
}

/* The helper note under the editor title (reuses .dialog-text sizing; muted). */
.helper-note {
  color: var(--txt3);
  margin: 4px 0 14px;
}

/* The editor field grid — a responsive two-column label/control layout inside each group section. */
.creditbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 4px 24px;
}

/* Inline-checkbox row (the boolean product-flag fields): the box + its label on one line. */
.form-group--check {
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-label--inline {
  margin-bottom: 0;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  color: var(--txt);
}

/* ─────────────────────────────────────────────
   DEALS oversight view (Phase 32, OVS-01/02/03) — search form, read-only detail,
   in-detail audit trail. Selector/class-based only (strict CSP style-src 'self');
   js/console.js sets NO inline style="". Reuses .panel / .empty / .btn / the
   Tabulator chrome below, plus the dark-theme tokens. READ-ONLY surface: no
   approve/distribute/edit affordance is styled (none exists — §9 gate intact).
   ───────────────────────────────────────────── */

/* Search form — a responsive flex row of filter controls + the Search button. */
.deal-search-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.filter-control {
  background: var(--dark3);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--txt);
  font-family: var(--body);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  flex: 1 1 160px;
  min-width: 120px;
}

.filter-control:focus {
  border-color: var(--g2);
  background: var(--dark4);
}

.filter-control::placeholder {
  color: var(--txt3);
}

/* The Search button keeps its natural width (not stretched by the flex row). */
.deal-search-form .btn {
  flex: 0 0 auto;
}

/* Read-only detail card. */
.deal-detail .deal-id {
  font-size: 11px;
  color: var(--txt3);
  font-family: monospace;
  margin-left: 10px;
  letter-spacing: 0.02em;
}

.deal-detail-section {
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

.deal-detail-section:first-of-type {
  border-top: none;
  padding-top: 4px;
}

.deal-section-title {
  font-family: var(--head);
  font-size: 14px;
  color: var(--txt);
  margin-bottom: 12px;
}

.deal-section-title .muted-note {
  font-family: var(--body);
  font-size: 11px;
  color: var(--txt3);
  margin-left: 6px;
}

/* Deal facts + parties — a two-column label/value grid. */
.deal-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px 24px;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--dark3);
  font-size: 13px;
}

.meta-label {
  color: var(--txt3);
}

.meta-value {
  color: var(--txt);
  text-align: right;
  word-break: break-word;
}

/* Read-only lender_matches (proposal status only — no action button). */
.match-list,
.doc-list,
.task-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.match-row,
.doc-row,
.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  background: var(--dark3);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12.5px;
}

.match-rank {
  flex: 0 0 32px;
  color: var(--txt3);
  font-weight: 700;
}

.match-name,
.doc-name,
.task-title {
  flex: 1 1 auto;
  color: var(--txt);
  min-width: 0;
  word-break: break-word;
}

.match-status,
.doc-status {
  flex: 0 0 auto;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--txt2);
  padding: 2px 8px;
  border: 1px solid var(--border2);
  border-radius: 5px;
}

.doc-type {
  flex: 0 0 auto;
  color: var(--txt3);
  font-size: 11.5px;
}

.doc-date,
.task-due {
  flex: 0 0 auto;
  color: var(--txt3);
  font-size: 11.5px;
}

/* ─────────────────────────────────────────────
   TABULATOR chrome (queues + integrations tables) — dark-theme overrides
   ───────────────────────────────────────────── */
.tabulator {
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: 10px;
  font-size: 12.5px;
}

.tabulator .tabulator-header {
  background: var(--dark3);
  border-bottom: 1px solid var(--border);
  color: var(--txt3);
}

.tabulator .tabulator-header .tabulator-col {
  background: var(--dark3);
  border-right: 1px solid var(--border);
}

.tabulator .tabulator-header .tabulator-col .tabulator-col-title {
  color: var(--txt3);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.tabulator .tabulator-row {
  background: var(--dark2);
  border-bottom: 1px solid var(--border);
  color: var(--txt);
}

.tabulator .tabulator-row.tabulator-row-even {
  background: var(--dark3);
}

.tabulator .tabulator-row:hover {
  background: var(--dark4);
}

.tabulator .tabulator-row .tabulator-cell {
  border-right: 1px solid var(--border);
  padding: 9px 10px;
}

.tabulator .tabulator-footer {
  background: var(--dark3);
  border-top: 1px solid var(--border);
  color: var(--txt3);
}

/* a non-zero count cell highlight (toggled by the table's formatter classes) */
.cell-warn {
  color: var(--o3);
  font-weight: 700;
}

.cell-fail {
  color: var(--red);
  font-weight: 700;
}

/* ─────────────────────────────────────────────
   STAFF SIGN-IN (login.html, OPS-01 / D-08) — selector-based; no inline style.
   The AAL2 flow steps are single-column cards on a centered shell; step
   visibility is toggled by the `is-hidden` class from js/login.js (never an
   injected style=""). Re-skinned "Internal — Staff sign-in" over the same dark
   palette as the console for visual continuity.
   ───────────────────────────────────────────── */
.login-body {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-shell {
  width: 100%;
  max-width: 420px;
}

.login-card {
  background: var(--dark2);
  border: 1px solid var(--border2);
  border-radius: 14px;
  padding: 32px 30px 30px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.login-card .staff-badge {
  margin-bottom: 22px;
}

.login-title {
  font-family: var(--head);
  font-size: 24px;
  font-weight: 500;
  margin-bottom: 6px;
}

.login-title.accent {
  color: var(--g2);
}

.login-sub {
  font-size: 13px;
  color: var(--txt3);
  line-height: 1.6;
  margin-bottom: 22px;
}

/* The error banner is hidden until js/login.js toggles `active`. */
.login-error {
  display: none;
  background: rgba(229, 57, 53, 0.1);
  border: 1px solid var(--red);
  border-radius: 8px;
  padding: 10px 13px;
  font-size: 12.5px;
  color: var(--red);
  margin-bottom: 16px;
}

.login-error.active {
  display: block;
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--txt3);
  margin-bottom: 7px;
}

.form-control {
  width: 100%;
  background: var(--dark3);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 14px;
  color: var(--txt);
  font-family: var(--body);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.form-control:focus {
  border-color: var(--g2);
  background: var(--dark4);
}

.form-control::placeholder {
  color: var(--txt3);
}

.code-input {
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.3em;
  font-family: monospace;
  color: var(--g2);
}

.code-input::placeholder {
  font-size: 18px;
  letter-spacing: 0.18em;
  font-weight: 400;
}

.btn-primary {
  background: var(--g);
  border: 1px solid var(--g);
  color: #fff;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--g2);
  border-color: var(--g2);
  color: #fff;
}

.login-submit {
  width: 100%;
  padding: 12px;
  margin-top: 6px;
  font-size: 14px;
}

.login-aux {
  margin-top: 16px;
  text-align: center;
  font-size: 12.5px;
  color: var(--txt3);
}

.link-btn {
  background: none;
  border: none;
  color: var(--g2);
  font-family: var(--body);
  font-size: 12.5px;
  cursor: pointer;
  padding: 0;
}

.link-btn:hover {
  text-decoration: underline;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  font-size: 12.5px;
  color: var(--txt3);
  font-family: var(--body);
  cursor: pointer;
  padding: 0;
  margin-bottom: 18px;
}

.back-link:hover {
  color: var(--txt);
}

/* Centered result/success/no-access steps. */
.login-centered {
  text-align: center;
  padding: 14px 0 6px;
}

.login-mark {
  font-size: 46px;
  line-height: 1;
  color: var(--g2);
  margin-bottom: 14px;
}

.login-mark.muted {
  color: var(--txt3);
}

/* Enrollment — QR + manual key. */
.enroll-qr-wrap {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
  text-align: center;
}

.enroll-qr {
  width: 180px;
  height: 180px;
  display: inline-block;
}

.enroll-secret {
  font-family: monospace;
  font-size: 13.5px;
  letter-spacing: 0.06em;
  color: var(--txt);
  word-break: break-all;
  background: var(--dark3);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 12px 14px;
}

/* Recovery codes. */
.recovery-list {
  background: var(--dark3);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 14px;
  font-family: monospace;
  font-size: 13.5px;
  line-height: 2;
  letter-spacing: 0.05em;
  color: var(--g3);
}

.recovery-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.recovery-actions .login-submit {
  flex: 1;
  margin-top: 0;
}

.recovery-ack-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 12.5px;
  color: var(--txt2);
  margin-bottom: 16px;
  cursor: pointer;
}

.recovery-ack-row input {
  margin-top: 3px;
}

/* ─────────────────────────────────────────────
   TOAST (UI.showToast — admin/js/api.js, WR-01)
   ─────────────────────────────────────────────
   Class-based toast styling. RELOCATED here from UI.showToast's runtime
   `t.style.cssText = "..."` string, which the strict admin CSP (style-src
   'self', no 'unsafe-inline') blocks for inline styles set via the CSSOM.
   UI.showToast now toggles `.toast` + a `.toast--{type}` variant via
   classList (CSP-clean), mirroring the class-based pattern console.js/login.js
   already use for the money badge and login error banner. */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  background: var(--dark4);
  color: var(--txt);
  border-left: 3px solid var(--info);
  padding: 14px 20px;
  border-radius: 6px;
  font-size: 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  max-width: 360px;
  animation: slideIn 0.2s ease;
  transition: opacity 0.3s;
}

.toast--success {
  border-left-color: var(--g2);
}

.toast--error {
  border-left-color: var(--red);
}

.toast--info {
  border-left-color: var(--info);
}

.toast--warning {
  border-left-color: var(--o2);
}

/* UI.showToast adds this to fade the toast out before removal (opacity is a
   presentation property NOT governed by style-src, but the class keeps the
   CSP-clean class-toggle convention end to end). */
.toast.is-leaving {
  opacity: 0;
}

/* Toast slide-in animation (Phase 31, T-31-08 fix). RELOCATED here from a runtime
 * `document.createElement("style")` injection in admin/js/api.js, which the strict
 * admin CSP (style-src 'self', no 'unsafe-inline') blocked at runtime. Lives in this
 * `<link>`ed same-origin stylesheet so `animation: slideIn` (now resolved via the
 * `.toast` class above) applies without any injected `<style>` element. */
@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ─────────────────────────────────────────────
 * LENDERS — write-action controls, confirm dialog, engagement-status badges
 * (Phase 33, LEND-02/03, D-02 — the FIRST write surface).
 *
 * All selector-based, in this <link>ed same-origin stylesheet (style-src 'self').
 * The console toggles the .is-open / .is-hidden classes — there is NO runtime
 * `document.createElement("style")` injection (the T-31-08 lesson) and NO inline
 * style="" attribute. Every color references an existing :root --* token (no new
 * hex literal); the dimming backdrop uses an rgba(0,0,0,…) overlay (not a hex).
 * ───────────────────────────────────────────── */

/* The detail's scoring-admin action row (rescore / pause / reinstate buttons). */
.lender-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Destructive button (pause) — red, reusing the --red token. Reinstate uses the
 * existing green .btn-primary; rescore uses the neutral .btn. */
.btn-danger {
  background: var(--dark3);
  border: 1px solid var(--red);
  color: var(--red);
  font-weight: 600;
}

.btn-danger:hover {
  background: var(--red);
  border-color: var(--red);
  color: var(--txt);
}

.btn-danger:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Confirm-dialog backdrop — a dimmed full-viewport overlay. The rgba(0,0,0,…) dim
 * is an overlay alpha, NOT a new theme hex. Hidden until .is-open is toggled. */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--scrim);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.dialog-backdrop.is-open {
  opacity: 1;
}

/* The centered confirm card — reuses the .panel chrome (--dark2 bg, --border2). */
.dialog-card {
  width: 100%;
  max-width: 440px;
  margin: 0;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

.dialog-body {
  margin-top: 4px;
}

.dialog-text {
  font-size: 14px;
  color: var(--txt2);
  line-height: 1.5;
  margin-bottom: 16px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* Inline field-level validation error (below the offending control), red per the
 * UI-SPEC. Toggled visible/hidden by the .is-hidden class from console.js. */
.field-error {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--red);
}

/* Engagement-status badges — extend the existing .status-state recipe (uppercase
 * 11px/700) with per-status color modifiers. Reuse the token vars only:
 *   active → green, warned/grace/paused → amber, suspended → red.
 * An unknown status keeps the neutral base .status-state (muted) color. */
.status-state {
  color: var(--txt3);
}

.status-state--active {
  color: var(--g2);
}

.status-state--warned,
.status-state--grace,
.status-state--paused {
  color: var(--warn);
}

.status-state--suspended {
  color: var(--red);
}

/* ─────────────────────────────────────────────
   LENDER ONBOARDING dialog (Quick 260627-aqb) — the "Register a lender" modal
   (single create + CSV import) hosted inside the Lenders view. Selector/class-based
   ONLY (strict CSP style-src 'self'); js/console.js sets NO inline style="". Reuses
   the .dialog-card / .form-group / .field-error / .btn chrome + the dark-theme tokens.
   ───────────────────────────────────────────── */

/* The onboarding modal is wider than the 440px confirm card (it hosts a form + a
   dry-run preview table). Overrides .dialog-card's max-width only. */
.dialog-card--wide {
  max-width: 680px;
}

/* Tab strip — two buttons sharing a bottom border; the active one is underlined green
   (mirrors lender-create.html's .tabs/.tab, rebuilt CSP-clean with .is-active). */
.onboard-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border2);
}

.onboard-tab {
  padding: 10px 16px;
  margin-bottom: -1px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--txt2);
  font-size: 14px;
  font-family: var(--body);
  cursor: pointer;
}

.onboard-tab:hover {
  color: var(--txt);
}

.onboard-tab.is-active {
  color: var(--g2);
  border-bottom-color: var(--g2);
}

/* CSV textarea — monospace so columns line up, like the source page's import box. */
.onboard-csv {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  resize: vertical;
}

/* The import action row wraps (it carries up to four buttons). */
.onboard-import-actions {
  flex-wrap: wrap;
}

/* Dry-run summary row — the count pills. */
.onboard-import-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0;
}

/* Per-result status pill — created=green, skipped_exists=gold, error=red. Reuses the
   token vars only (rgba alphas for the tinted backgrounds, NOT new theme hexes). */
.import-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid transparent;
}

.import-pill--created {
  background: rgba(76, 175, 80, 0.14);
  color: var(--g2);
  border-color: rgba(76, 175, 80, 0.4);
}

.import-pill--skipped {
  background: rgba(249, 168, 37, 0.12);
  color: var(--gold);
  border-color: rgba(249, 168, 37, 0.35);
}

.import-pill--error {
  background: rgba(229, 57, 53, 0.12);
  color: var(--red);
  border-color: rgba(229, 57, 53, 0.4);
}

/* The dry-run results table — scrolls horizontally on narrow viewports. */
.onboard-import-tablewrap {
  overflow-x: auto;
  margin-top: 8px;
}

.onboard-import-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.onboard-import-table th,
.onboard-import-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border2);
  vertical-align: top;
}

.onboard-import-table th {
  color: var(--txt3);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.onboard-import-errs {
  color: var(--red);
  font-size: 11px;
}

/* ─────────────────────────────────────────────
   PHASE 47 — credit memo inputs (deals oversight)
   The staff-assisted memo-inputs View ⇄ Edit panel inside the deal detail
   (js/console.js renderMemoInputsRead/Edit — MEMO-01 / D-10). CSP-clean:
   selector/class-based only (strict style-src 'self'); console.js sets NO
   inline style="" for this panel. Every color references an existing :root
   --* token. The save reaches the EXISTING gated PATCH /v2/deals/:id — no
   approve/distribute affordance is styled here (§9 gate surface unchanged).
   ───────────────────────────────────────────── */

/* One memo field group (5 groups per the locked Phase-47 spec). */
.memo-group {
  padding: 10px 0 4px;
}

/* Group header row: title + hint on the left, the n/m count badge on the right. */
.memo-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.memo-group-title {
  font-family: var(--head);
  font-size: 13px;
  color: var(--txt);
}

/* Per-group memo-purpose hint (D-07) — mirrors .muted-note sizing. */
.memo-group-hint {
  font-size: 11px;
  color: var(--txt3);
  margin-top: 2px;
}

/* Neutral completeness count "n/m" (D-09 — counts only, no readiness claims). */
.memo-group-count {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--txt3);
  background: var(--dark3);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 2px 8px;
}

/* Startup-projections group when the deal is not a startup: dimmed, NEVER hidden (D-06). */
.memo-group--dimmed {
  opacity: 0.55;
}

.memo-group-note {
  font-size: 11px;
  color: var(--txt3);
  font-style: italic;
  margin-bottom: 8px;
}

/* Edit-form field grid — same responsive two-column layout as .creditbox-grid. */
.memo-inputs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 4px 24px;
}

/* Inline per-field validation error (bounds-only copy, never echoes the value —
   T-47-17). Hidden by default; .show displays it. */
.memo-field-error {
  display: none;
  font-size: 11px;
  color: var(--red);
  margin-top: 4px;
}

.memo-field-error.show {
  display: block;
}

/* Footer row for the Edit / Save / Cancel buttons. */
.memo-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

/* ── GENERATED CREDIT MEMO (Phase 51 staff gate view · consumes CreditMemoAPI / Phase 50) ── */
.amemo-empty { background: var(--dark3); border: 1px dashed var(--border2); border-radius: 8px; padding: 20px; text-align: center; color: var(--txt2); font-size: 13px; }
.amemo-empty-t { color: var(--txt); font-weight: 600; margin-bottom: 6px; }
.amemo-empty b { color: var(--gold); }
.amemo-empty .btn { margin-top: 12px; }
.amemo-banner { border: 1px solid; border-bottom: none; border-radius: 8px 8px 0 0; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.amemo-verdict { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; letter-spacing: .01em; }
.amemo-dot { width: 10px; height: 10px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.amemo-sub { font-size: 12px; color: var(--txt2); margin-top: 3px; font-weight: 400; }
.amemo-badge { font-size: 9.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--txt3); border: 1px solid var(--border2); border-radius: 20px; padding: 3px 9px; white-space: nowrap; }
.amv-approve { background: rgba(76,175,80,.09); border-color: rgba(76,175,80,.4); color: var(--g2); }
.amv-cond { background: rgba(249,168,37,.10); border-color: rgba(249,168,37,.4); color: var(--gold); }
.amv-decline { background: rgba(229,57,53,.10); border-color: rgba(229,57,53,.4); color: var(--verdict-bad); }
.amv-neutral { background: var(--dark3); border-color: var(--border2); color: var(--txt2); }
.amemo-body { background: var(--dark2); border: 1px solid var(--border2); border-top: none; border-radius: 0 0 8px 8px; padding: 16px; }
.amemo-lead { font-size: 13px; line-height: 1.6; color: var(--txt); margin: 0 0 16px; }
.amemo-figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 9px; margin-bottom: 16px; }
.amemo-fig { background: var(--dark3); border: 1px solid var(--border); border-radius: 7px; padding: 10px 12px; }
.amemo-fig .afl { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--txt3); margin-bottom: 4px; }
.amemo-fig .afv { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--txt); }
.amemo-fig .afv.good { color: var(--g2); } .amemo-fig .afv.bad { color: var(--verdict-bad); } .amemo-fig .afv.warn { color: var(--gold); }
.amemo-fig .afn { font-size: 10px; color: var(--txt3); margin-top: 2px; }
.amemo-sec { border-top: 1px solid var(--border); padding-top: 13px; margin-top: 13px; }
.amemo-sec:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.amemo-sec h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--txt2); margin: 0 0 8px; font-weight: 600; }
.amemo-sec p { font-size: 12.5px; line-height: 1.6; color: var(--txt); margin: 0; }
.amemo-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.amemo-list li { position: relative; padding-left: 18px; font-size: 12px; line-height: 1.55; color: var(--txt); }
.amemo-list li::before { content: ""; position: absolute; left: 0; top: .5em; width: 6px; height: 6px; border-radius: 2px; }
.amemo-list.good li::before { background: var(--g2); } .amemo-list.risk li::before { background: var(--gold); } .amemo-list.cond li::before { background: var(--b3); }
.amemo-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.amemo-caveat { font-size: 11px; color: var(--txt3); margin-top: 10px; font-style: italic; line-height: 1.5; }

/* IN-02 (T-52-IN02): the AI-provenance badge the console renders (console.js:2298-2303 emits
   class="muted-note memo-ai-badge") was previously unstyled inline text. Copied VERBATIM from the
   broker surface (frontend/broker.html:242) so the admin badge is the same pill. All three vars
   (--txt3, --dark4, --border2) are defined in this stylesheet. CSS-only — no markup change. */
.memo-ai-badge{display:inline-block;margin-left:6px;font-size:9px;color:var(--txt3);background:var(--dark4);border:1px solid var(--border2);padding:1px 6px;border-radius:8px;text-transform:none;letter-spacing:0;vertical-align:middle;max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
