:root {
  --brand: #0b5cff;
  --brand-dark: #063aa6;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #16202e;
  --muted: #6b7688;
  --line: #e4e8f0;
  --credit: #157a4a;
  --debit: #b23b3b;
  --shadow: 0 6px 24px rgba(16, 32, 64, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 60px; background: var(--card);
  border-bottom: 1px solid var(--line); box-shadow: var(--shadow);
}
.brand { font-size: 20px; font-weight: 700; color: var(--text); }
.topbar nav { display: flex; align-items: center; gap: 18px; }
.topbar nav .who { color: var(--muted); font-size: 14px; }
.btn-link { color: var(--brand); }

/* Content */
.content { max-width: 960px; margin: 0 auto; padding: 32px 24px 120px; }

/* Flash */
.flash { max-width: 960px; margin: 16px auto -8px; padding: 12px 16px; border-radius: 8px; }
.flash-success { background: #e6f6ec; color: #14683f; }
.flash-error { background: #fdeaea; color: #a12626; }
.flash-info { background: #e9f0ff; color: #244a9c; }

/* Hero + cards */
.hero h1 { font-size: 34px; margin-bottom: 8px; }
.lede { color: var(--muted); max-width: 640px; }
.cta-row { display: flex; gap: 12px; margin: 20px 0; }
.hint { color: var(--muted); font-size: 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 28px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; box-shadow: var(--shadow); }
.card h3 { margin-top: 0; }

/* Buttons */
.btn, button, .btn-secondary {
  display: inline-block; border: none; cursor: pointer;
  background: var(--brand); color: #fff; padding: 10px 18px;
  border-radius: 8px; font-size: 15px; font-weight: 600;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn-secondary { background: #eaf0ff; color: var(--brand); }

/* Forms */
.form-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 28px; max-width: 460px; margin: 12px auto; box-shadow: var(--shadow);
}
.form-card label { display: block; margin: 14px 0; font-size: 14px; color: var(--muted); }
.form-card input {
  width: 100%; margin-top: 6px; padding: 10px 12px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 8px; color: var(--text);
}
.form-error { background: #fdeaea; color: #a12626; padding: 10px 12px; border-radius: 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
code { background: #eef1f7; padding: 1px 6px; border-radius: 5px; font-size: 13px; }

/* Dashboard */
.dash-head { display: flex; align-items: center; justify-content: space-between; }
.accounts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin: 20px 0; }
.account-card { background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: #fff; border-radius: 14px; padding: 20px; box-shadow: var(--shadow); }
.account-type { text-transform: uppercase; font-size: 12px; letter-spacing: 1px; opacity: .85; }
.account-number { font-family: monospace; margin: 6px 0; opacity: .9; }
.account-balance { font-size: 26px; font-weight: 700; }

.txns { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; box-shadow: var(--shadow); }
.txns table { width: 100%; border-collapse: collapse; font-size: 14px; }
.txns th, .txns td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); }
.txns .num { text-align: right; font-variant-numeric: tabular-nums; }
.credit { color: var(--credit); }
.debit { color: var(--debit); }

/* Inbox */
.inbox .email { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin: 14px 0; box-shadow: var(--shadow); }
.email-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; }
.email-body { white-space: pre-wrap; font-family: monospace; background: #f7f9fc; padding: 12px; border-radius: 8px; }
.empty { color: var(--muted); }
.payees { margin-top: 20px; }

/* ------------------------------------------------------------------ */
/* Chat widget                                                        */
/* ------------------------------------------------------------------ */
#chat-widget { position: fixed; right: 20px; bottom: 20px; z-index: 999; }
#chat-toggle {
  background: var(--brand); color: #fff; border-radius: 24px; padding: 12px 18px;
  font-weight: 600; box-shadow: var(--shadow); border: none; cursor: pointer;
}
#chat-panel {
  position: absolute; right: 0; bottom: 0; width: 380px; max-width: 92vw;
  height: 540px; max-height: 80vh; display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 12px 40px rgba(16,32,64,.22); overflow: hidden;
}
.chat-head { display: flex; justify-content: space-between; align-items: flex-start;
  padding: 12px 14px; background: var(--brand); color: #fff; }
.chat-head button { background: transparent; color: #fff; padding: 0 4px; }
.active-agent { font-size: 12px; opacity: .9; margin-top: 2px; }
.active-agent.busy::before { content: "● "; color: #7CFFB2; }

.chat-log { flex: 1; overflow-y: auto; padding: 14px; background: #f7f9fc; }
.msg { margin: 8px 0; padding: 9px 12px; border-radius: 12px; max-width: 85%; white-space: pre-wrap; font-size: 14px; }
.msg.user { background: var(--brand); color: #fff; margin-left: auto; border-bottom-right-radius: 3px; }
.msg.bot { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.msg .agent-tag { display: block; font-size: 11px; font-weight: 700; color: var(--brand); margin-bottom: 3px; text-transform: uppercase; letter-spacing: .4px; }

/* Event trail: handoffs + tool calls */
.trace { margin: 6px 0; font-size: 12px; color: var(--muted); }
.trace .handoff { display: inline-block; background: #eef4ff; color: var(--brand-dark);
  border: 1px solid #d6e2ff; border-radius: 20px; padding: 2px 10px; }
.trace .tool { display: inline-block; background: #f0f0f4; color: #555;
  border-radius: 20px; padding: 2px 10px; }
.trace .tool.running::after { content: " …"; }

/* Confirmation card for interrupts */
.confirm-card { background: #fff8e6; border: 1px solid #ffe08a; border-radius: 10px;
  padding: 12px; margin: 8px 0; font-size: 14px; }
.confirm-card .actions { margin-top: 10px; display: flex; gap: 8px; }
.confirm-card button { padding: 7px 16px; border-radius: 7px; }
.confirm-card .cancel { background: #eceff4; color: #333; }

.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.chat-form button { padding: 10px 16px; }
