:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --ink: #15211d;
  --muted: #46564f;
  --line: #d9e1de;
  --brand: #0d6b57;
  --brand-ink: #ffffff;
  --brand-soft: #e3f3ee;
  --avail: #0d6b57;
  --held-ink: #7a4b00;
  --held-bg: #fdf1d8;
  --pending-ink: #1d4a99;
  --pending-bg: #e6eefc;
  --ok-ink: #11653a;
  --ok-bg: #e4f5ea;
  --bad-ink: #9b1c1c;
  --bad-bg: #fcebeb;
  --unsure-ink: #55349a;
  --unsure-bg: #f0eafb;
  --radius: 14px;
  --gap: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font);
  font-size: 16px; line-height: 1.45; overflow-x: hidden;
}
a { color: var(--brand); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
input, select, button { accent-color: var(--brand); }
button:focus-visible, input:focus-visible, select:focus-visible { box-shadow: 0 0 0 4px rgba(13,107,87,.18); }
[aria-invalid="true"] { border-color: var(--bad-ink); border-width: 2px; }
.boot { padding: 48px 16px; text-align: center; color: var(--muted); }

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 8px 16px 0; display: flex; flex-wrap: wrap;
  align-items: center; justify-content: space-between; gap: 4px 12px;
}
.brand { font-weight: 700; font-size: 1.15rem; color: var(--brand); text-decoration: none; letter-spacing: .2px; flex: none; }
.nav {
  display: flex; gap: 4px; order: 3; flex: 1 1 100%; min-width: 0; overflow-x: auto; padding: 2px 0 8px;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 8px 14px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 600;
  font-size: .95rem; white-space: nowrap; flex: none;
}
.nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); }
.who { display: flex; align-items: center; gap: 8px; font-size: .95rem; min-width: 0; flex: 0 1 auto; }
.who .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; max-width: 11ch; }
.who .handle { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; max-width: 12ch; }
.who button { min-height: 36px; padding: 4px 12px; flex: none; }
@media (min-width: 720px) {
  .topbar-inner { flex-wrap: nowrap; padding-bottom: 8px; }
  .nav { order: 1; flex: 1 1 auto; padding: 0; }
  .who { order: 2; }
  .who .name { max-width: 24ch; }
  .who .handle { max-width: 24ch; }
}

main { max-width: 1080px; margin: 0 auto; padding: 20px 16px 56px; }
h1 { font-size: 1.5rem; margin: 0 0 16px; }
h2 { font-size: 1.1rem; margin: 0 0 4px; }
.sub { color: var(--muted); margin: 0 0 12px; font-size: .92rem; }
.grid { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 880px) {
  .grid.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
}
.stack { display: grid; gap: var(--gap); min-width: 0; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; min-width: 0;
}

.wallet { display: grid; gap: 14px; }
.wallet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.eyebrow { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.headline { font-size: 2.6rem; line-height: 1.1; font-weight: 750; color: var(--avail); margin: 4px 0 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.secondary-row { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { border-radius: 10px; padding: 8px 12px; display: grid; gap: 2px; background: #eef2f0; min-width: 0; }
.chip .label { font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.chip .value { font-weight: 650; font-size: 1.05rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.chip.held { background: var(--held-bg); }
.chip.held .label, .chip.held .value { color: var(--held-ink); }
.updated { font-size: .82rem; color: var(--muted); }

form { display: grid; gap: 12px; }
.field { display: grid; gap: 4px; min-width: 0; }
label { font-weight: 600; font-size: .92rem; }
input, select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid #8a9a94; border-radius: 10px;
  padding: 10px 12px; width: 100%; min-width: 0; min-height: 44px;
}
input::placeholder { color: #66756f; }
.row2 { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 520px) { .row2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }

button, .btn {
  font: inherit; font-weight: 650; border-radius: 10px; min-height: 44px; padding: 10px 16px; cursor: pointer;
  border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink); text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button.secondary, .btn.secondary { background: #fff; color: var(--brand); }
button.danger { background: #fff; color: var(--bad-ink); border-color: var(--bad-ink); }
button[disabled] { opacity: .65; cursor: progress; }
button.busy::after {
  content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.msg { border-radius: 10px; padding: 10px 12px; font-size: .95rem; border: 1px solid transparent; overflow-wrap: anywhere; }
.msg.error { background: var(--bad-bg); color: var(--bad-ink); border-color: #efbcbc; }
.msg.success { background: var(--ok-bg); color: var(--ok-ink); border-color: #b6e2c6; }
.msg.uncertain { background: var(--held-bg); color: var(--held-ink); border: 1px solid #e3c274; border-left-width: 5px; }
.msg.info { background: var(--pending-bg); color: var(--pending-ink); }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.item {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 8px; min-width: 0; background: #fff;
}
.item-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.parties { font-weight: 650; overflow-wrap: anywhere; min-width: 0; }
.amount { font-weight: 750; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.amount.in { color: var(--ok-ink); }
.note { color: var(--ink); overflow-wrap: anywhere; white-space: pre-wrap; margin: 0; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: .85rem; color: var(--muted); }
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700;
  background: #eef2f0; color: var(--muted); white-space: nowrap;
}
.badge.pending, .badge.open { background: var(--pending-bg); color: var(--pending-ink); }
.badge.paid, .badge.captured, .badge.dir-received { background: var(--ok-bg); color: var(--ok-ink); }
.badge.declined { background: var(--bad-bg); color: var(--bad-ink); }
.badge.cancelled, .badge.voided, .badge.expired, .badge.dir-sent, .badge.dir-between { background: #eceff0; color: #46535b; }
.badge.vis { background: #fff; color: var(--muted); border: 1px solid #9aa9a3; font-weight: 600; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.actions .field { flex: 1 1 140px; }
.empty { text-align: center; color: var(--muted); padding: 22px 8px; border: 1px dashed var(--line); border-radius: 12px; }
.skeleton { color: var(--muted); padding: 12px 0; }
.loading { opacity: .6; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.preview { border: 1px dashed var(--line); border-radius: 12px; padding: 12px; background: #fafcfb; }
.preview ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.preview li { display: flex; justify-content: space-between; gap: 10px; overflow-wrap: anywhere; }
.auth-wrap { max-width: 440px; margin: 0 auto; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; min-height: 44px; }
.check input { width: 22px; height: 22px; min-height: 0; flex: none; }

.expiry { display: grid; gap: 2px; font-size: .88rem; color: var(--ink); }
.expiry-rfc { font-size: .72rem; color: var(--muted); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.jump { display: none; font-size: .9rem; }
@media (max-width: 879px) { .jump { display: inline-block; } }
button.secondary:hover { background: var(--brand-soft); }

.actions.req { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: stretch; }
.actions.req .field { grid-column: 1 / -1; }
.actions .cap-field { flex: 0 1 240px; }
.who .nav { order: 0; flex: none; padding: 0; overflow: visible; }
