:root {
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --brand: #0369a1;
  --brand-deep: #0c4a6e;
  --accent: #7c3aed;
  --green: #15803d;
  --amber: #b45309;
  --red: #b91c1c;
  --font: "Segoe UI", system-ui, sans-serif;
  --shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(3, 105, 161, 0.12), transparent 35%),
    radial-gradient(circle at 90% 10%, rgba(124, 58, 237, 0.1), transparent 30%),
    var(--bg);
  line-height: 1.5;
}
a { color: var(--brand-deep); }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.85rem 1.25rem; background: rgba(255,255,255,0.95);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; gap: 0.6rem; align-items: center; font-weight: 750; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(145deg, var(--brand), var(--accent));
  color: #fff; display: grid; place-items: center; font-size: 0.7rem; font-weight: 800;
}
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: 0.72rem; }
.nav { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.main { width: min(1120px, calc(100% - 2rem)); margin: 1.25rem auto 2.5rem; }
.view { display: none !important; }
.view.active { display: block !important; }
.panel {
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1rem;
}
.panel h2, .panel h3 { margin-top: 0; letter-spacing: -0.02em; }
.btn {
  border: none; border-radius: 999px; padding: 0.6rem 1rem; font-weight: 650;
  cursor: pointer; display: inline-flex; align-items: center; gap: 0.3rem;
}
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-deep)); color: #fff; }
.btn-accent { background: linear-gradient(135deg, #8b5cf6, var(--accent)); color: #fff; }
.btn-green { background: linear-gradient(135deg, #22c55e, var(--green)); color: #fff; }
.btn-secondary { background: #fff; border: 1px solid var(--line); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.85rem; }
.btn-lg { padding: 0.85rem 1.25rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.85rem; }
.stack { display: flex; flex-direction: column; gap: 0.75rem; }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field label { font-size: 0.84rem; font-weight: 650; color: #334155; }
.field input, .field select, .field textarea {
  border: 1px solid var(--line); border-radius: 10px; padding: 0.65rem 0.8rem;
}
.field textarea { min-height: 80px; }
.hint { font-size: 0.8rem; color: var(--muted); }
.hero {
  background: linear-gradient(135deg, #0c4a6e, #1e1b4b);
  color: #fff; border-radius: 18px; padding: 1.4rem; margin-bottom: 1rem;
}
.hero h1 { margin: 0 0 0.35rem; font-size: 1.6rem; letter-spacing: -0.03em; }
.hero p { margin: 0; opacity: 0.92; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; margin-bottom: 1rem; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 0.85rem; }
.stat .l { font-size: 0.78rem; color: var(--muted); }
.stat .v { font-size: 1.2rem; font-weight: 750; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.data th, table.data td { text-align: left; padding: 0.65rem 0.45rem; border-bottom: 1px solid var(--line); }
table.data th { font-size: 0.75rem; text-transform: uppercase; color: var(--muted); }
.badge {
  display: inline-flex; padding: 0.15rem 0.5rem; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; background: #e2e8f0;
}
.badge.approved, .badge.funded { background: #dcfce7; color: var(--green); }
.badge.declined { background: #fee2e2; color: var(--red); }
.badge.pending_manual, .badge.second_look, .badge.first_look { background: #fef3c7; color: var(--amber); }
.badge.paid_off { background: #ede9fe; color: #6d28d9; }
.alert { border-radius: 10px; padding: 0.7rem 0.85rem; font-size: 0.9rem; margin: 0.5rem 0; }
.alert.info { background: #e0f2fe; border: 1px solid #bae6fd; color: #075985; }
.alert.ok { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.alert.warn { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.score-bar { height: 10px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.score-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--accent)); }
.callout {
  border-left: 4px solid var(--brand); background: #f8fafc;
  padding: 0.75rem 1rem; border-radius: 0 10px 10px 0; margin: 0.6rem 0;
}
.money { font-variant-numeric: tabular-nums; font-weight: 650; }
.mono { font-family: ui-monospace, monospace; font-size: 0.85rem; }
.muted { color: var(--muted); }
.steps { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }
.step {
  padding: 0.35rem 0.7rem; border-radius: 999px; background: #e2e8f0;
  font-size: 0.8rem; font-weight: 650; color: var(--muted);
}
.step.on { background: #e0f2fe; color: var(--brand-deep); }
.step.done { background: #dcfce7; color: var(--green); }
.auth { min-height: 70vh; display: grid; place-items: center; }
.auth .panel { width: min(480px, 100%); }
#toast {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 99; max-width: 380px;
  display: none; box-shadow: var(--shadow);
}
/* Dual-path demo */
.path-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.path-card {
  border: 2px solid var(--line); border-radius: 16px; padding: 1.25rem;
  background: linear-gradient(180deg, #fff, #f8fafc); cursor: pointer; transition: 0.15s;
}
.path-card:hover { border-color: var(--brand); transform: translateY(-2px); }
.path-card.applicant { border-color: #a5b4fc; }
.path-card.admin { border-color: #7dd3fc; }
.mode-pill {
  display: inline-flex; padding: 0.25rem 0.65rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 750; background: #e0e7ff; color: #3730a3;
}
.mode-pill.admin { background: #e0f2fe; color: #075985; }

/* TILA / disclosures */
.tila-box {
  border: 2px solid #0f172a; border-radius: 8px; padding: 1rem; margin: 1rem 0; background: #fff;
}
.tila-title { font-weight: 800; font-size: 1rem; margin-bottom: 0.5rem; letter-spacing: 0.02em; }
.tila-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  border: 1px solid #0f172a; margin: 0.75rem 0;
}
.tila-cell {
  border: 1px solid #0f172a; padding: 0.75rem; min-height: 100px;
}
.tila-cell span { display: block; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.tila-cell strong { display: block; font-size: 1.35rem; margin: 0.35rem 0; letter-spacing: -0.02em; }
.tila-cell em { display: block; font-size: 0.75rem; color: #475569; font-style: normal; }
.disclosure-block {
  border: 1px solid var(--line); border-radius: 12px; padding: 0.85rem 1rem; margin: 0.65rem 0; background: #f8fafc;
}
.disclosure-block h4 { margin: 0 0 0.4rem; font-size: 0.95rem; }
.disclosure-block p { margin: 0.35rem 0; font-size: 0.88rem; color: #334155; }
.consent-row {
  display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.55rem 0;
  border-bottom: 1px solid var(--line); font-size: 0.9rem;
}
.xrpl-steps { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0; }
.xrpl-step {
  flex: 1; min-width: 120px; text-align: center; padding: 0.65rem;
  border-radius: 12px; border: 1px solid var(--line); background: #fff; font-size: 0.82rem; font-weight: 650;
}
.xrpl-step.done { background: #dcfce7; border-color: #86efac; color: var(--green); }
.xrpl-step.current { background: #e0f2fe; border-color: #7dd3fc; color: var(--brand-deep); }
.portal-wallet {
  font-family: ui-monospace, monospace; background: #0f172a; color: #e2e8f0;
  padding: 0.75rem 1rem; border-radius: 10px; word-break: break-all; font-size: 0.85rem;
}

/* E-sign protocol */
.esign-steps { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 1rem; }
.esign-step-pill {
  padding: 0.35rem 0.7rem; border-radius: 999px; background: #e2e8f0;
  font-size: 0.78rem; font-weight: 650; color: var(--muted);
}
.esign-step-pill.on { background: #e0f2fe; color: var(--brand-deep); }
.esign-step-pill.done { background: #dcfce7; color: var(--green); }
.doc-card {
  border: 1px solid var(--line); border-radius: 12px; padding: 0.85rem 1rem; margin: 0.5rem 0;
  background: #fff; display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-start; justify-content: space-between;
}
.doc-card.opened { border-color: #86efac; background: #f0fdf4; }
.doc-viewer {
  border: 1px solid var(--line); border-radius: 12px; padding: 1rem; margin: 1rem 0;
  background: #f8fafc; max-height: 420px; overflow: auto;
}
.cert-box {
  border: 2px solid #0f172a; border-radius: 12px; padding: 1.25rem; margin: 1rem 0;
  background: linear-gradient(180deg, #fff, #f8fafc);
}
.cert-title { font-weight: 800; font-size: 1.1rem; letter-spacing: 0.02em; margin-bottom: 0.5rem; }
.sign-name-input {
  font-family: "Segoe Script", "Brush Script MT", cursive, serif;
  font-size: 1.5rem; padding: 0.75rem 1rem; border: 2px solid #0f172a; border-radius: 8px; width: 100%;
}

@media (max-width: 900px) {
  .grid-2, .grid-3, .stats, .path-cards, .tila-grid { grid-template-columns: 1fr; }
}
