:root {
  --bg: #f3f6f7;
  --surface: #ffffff;
  --ink: #12222b;
  --ink-soft: #46606c;
  --line: #d5dfe3;
  --brand: #0b5c63;
  --brand-ink: #ffffff;
  --brand-soft: #e1f1f2;
  --ok-bg: #e4f4e8;
  --ok-ink: #14532d;
  --warn-bg: #fff3d1;
  --warn-ink: #6b4200;
  --bad-bg: #fde8e8;
  --bad-ink: #8f1d1d;
  --info-bg: #e5eefb;
  --info-ink: #1d3f7a;
  --muted-bg: #e8edef;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(18, 34, 43, 0.06), 0 6px 18px rgba(18, 34, 43, 0.05);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-width: 0; background: var(--bg); }
h1, h2, h3, p, dl, dd, ul { margin: 0; padding: 0; }
ul { list-style: none; }
h1 { font-size: 1.6rem; line-height: 1.2; }
h2 { font-size: 1.1rem; line-height: 1.3; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid #0b5c63; outline-offset: 2px; border-radius: 6px; }

.skip-link {
  position: absolute; left: 8px; top: -60px; background: var(--ink); color: #fff;
  padding: 8px 12px; border-radius: 8px; z-index: 10;
}
.skip-link:focus { top: 8px; }
.boot { padding: 32px 16px; text-align: center; color: var(--ink-soft); }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.bar {
  max-width: 1080px; margin: 0 auto; padding: 10px 16px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
}
.brand {
  display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.15rem;
  color: var(--ink); text-decoration: none;
}
.brand-mark {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: var(--brand); color: var(--brand-ink); font-size: 0.95rem;
}
.nav { display: flex; flex-wrap: wrap; gap: 4px; order: 3; width: 100%; }
.nav a {
  padding: 8px 12px; border-radius: 999px; text-decoration: none; color: var(--ink-soft);
  font-weight: 600; min-height: 40px; display: inline-flex; align-items: center;
}
.nav a:hover { background: var(--muted-bg); color: var(--ink); }
.nav a[aria-current='page'] { background: var(--brand-soft); color: var(--brand); }
.user { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.who { display: inline-flex; gap: 6px; align-items: baseline; min-width: 0; overflow-wrap: anywhere; }
.who-name { font-weight: 700; }
.who-handle { color: var(--ink-soft); font-size: 0.9rem; }
.who-loading { color: var(--ink-soft); }
.link { font-weight: 600; padding: 8px 4px; }

/* Layout */
.content { max-width: 1080px; margin: 0 auto; padding: 20px 16px 48px; display: grid; gap: 16px; }
.content:focus { outline: none; }
.page-title { margin-bottom: 4px; }
.columns { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.stack { display: grid; gap: 16px; align-content: start; min-width: 0; }
@media (min-width: 900px) {
  .bar { flex-wrap: nowrap; }
  .nav { order: 0; width: auto; }
  .columns { grid-template-columns: minmax(0, 380px) minmax(0, 1fr); }
}

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; min-width: 0; display: grid; gap: 12px; align-content: start;
}
.card.narrow { max-width: 440px; width: 100%; margin: 16px auto 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.intro { color: var(--ink-soft); font-size: 0.95rem; }
.subhead { font-size: 0.95rem; color: var(--ink-soft); }
.switch { text-align: center; }

/* Wallet */
.wallet { background: linear-gradient(160deg, #0b5c63, #0e7480); color: #ffffff; border: none; }
.wallet a, .wallet .button { color: inherit; }
.wallet .eyebrow { font-size: 0.85rem; letter-spacing: 0.04em; text-transform: uppercase; color: #d6eeef; }
.wallet .headline { font-size: 2.4rem; font-weight: 750; line-height: 1.1; overflow-wrap: anywhere; }
.subtotals { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-top: 8px; }
.subtotals dt { font-size: 0.8rem; color: #d6eeef; }
.subtotals dd { font-size: 1.05rem; font-weight: 600; }
.subtotals .held dd { color: #ffe9a8; }
.wallet .button.small { background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.5); color: #fff; }
.wallet .button.small:hover { background: rgba(255, 255, 255, 0.28); }
.wallet :focus-visible { outline-color: #ffffff; }
.wallet .notice-error { background: #fde8e8; color: var(--bad-ink); }
.wallet .notice .button { color: var(--ink); background: #fff; }

/* Forms */
.form { display: grid; gap: 12px; }
.field { display: grid; gap: 4px; min-width: 0; }
label { font-weight: 600; font-size: 0.92rem; }
.inline-field { display: grid; gap: 4px; font-size: 0.85rem; }
input, select {
  font: inherit; font-size: 1rem; color: var(--ink); background: #fff; width: 100%; min-width: 0;
  min-height: 44px; padding: 8px 12px; border: 1px solid #8aa0aa; border-radius: 10px;
}
input:hover, select:hover { border-color: var(--brand); }
.hint { color: var(--ink-soft); font-size: 0.85rem; }
.button {
  font: inherit; font-weight: 650; min-height: 44px; padding: 8px 16px; border-radius: 10px;
  border: 1px solid #8aa0aa; background: #fff; color: var(--ink); cursor: pointer;
}
.button:hover { background: var(--muted-bg); }
.button.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.button.primary:hover { background: #094a50; }
.button.small { min-height: 38px; padding: 4px 12px; font-size: 0.9rem; }
.button.quiet { border-color: transparent; background: transparent; color: var(--ink-soft); }
.button:disabled { opacity: 0.6; cursor: progress; }

/* Notices */
.notice { padding: 10px 12px; border-radius: 10px; font-size: 0.92rem; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.notice-error { background: var(--bad-bg); color: var(--bad-ink); border: 1px solid #efb4b4; }
.notice-uncertain { background: var(--warn-bg); color: var(--warn-ink); border: 1px solid #e8c56a; }
.notice-success { background: var(--ok-bg); color: var(--ok-ink); border: 1px solid #9fd2ad; }
.notice-info { background: var(--info-bg); color: var(--info-ink); }
.loading { color: var(--ink-soft); }
.wallet .loading { color: #d6eeef; }

/* Lists */
.items { display: grid; gap: 10px; }
.item {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; padding: 12px;
  border: 1px solid var(--line); border-left-width: 4px; border-radius: 12px; min-width: 0;
}
.item-main { display: grid; gap: 2px; min-width: 0; flex: 1 1 200px; overflow-wrap: anywhere; }
.item-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.activity.sent { border-left-color: #b45309; }
.activity.received { border-left-color: #15803d; }
.activity.public { border-left-color: #94a3b8; }
.item.status-pending, .item.status-open { border-left-color: #1d4ed8; }
.item.status-paid, .item.status-captured { border-left-color: #15803d; }
.item.status-declined, .item.status-cancelled, .item.status-voided, .item.status-expired { border-left-color: #94a3b8; }
.parties { font-weight: 650; }
.note { color: var(--ink-soft); }
.note:empty { display: none; }
.amount, .amount-line { font-weight: 750; font-variant-numeric: tabular-nums; }
.amount { font-size: 1.05rem; align-self: center; text-align: right; }
.amount.received { color: #166534; }
.amount.sent { color: #92400e; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; font-size: 0.85rem; color: var(--ink-soft); }
.detail { font-size: 0.85rem; color: var(--ink-soft); }
.pill { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 650; background: var(--muted-bg); color: #33464f; }
.pill-pending, .pill-open { background: var(--info-bg); color: var(--info-ink); }
.pill-paid, .pill-captured, .pill-received { background: var(--ok-bg); color: var(--ok-ink); }
.pill-sent { background: #fdebd3; color: #7a3c00; }
.pill-private { background: #ece6fb; color: #43307a; }
.pill-expired, .pill-declined, .pill-cancelled, .pill-voided { background: var(--muted-bg); color: #3b4a52; }
.empty { text-align: center; padding: 20px 8px; color: var(--ink-soft); display: grid; gap: 4px; }
.empty-title { font-weight: 700; color: var(--ink); }
.quiet-empty { color: var(--ink-soft); font-size: 0.92rem; }

/* Split preview */
.preview { padding: 10px 12px; border: 1px dashed #8aa0aa; border-radius: 10px; background: #fafcfc; }
.shares { display: grid; gap: 6px; }
.shares li { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.share-handle { font-weight: 650; overflow-wrap: anywhere; }
.share-amount { font-variant-numeric: tabular-nums; font-weight: 700; }

@media (max-width: 480px) {
  .wallet .headline { font-size: 2rem; }
  .card { padding: 14px; }
  .amount { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
