/* Pocketful — calm, trustworthy wallet UI. System fonts only; no external assets. */

:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #f8faf9;
  --ink: #16211f;
  --ink-2: #44524f;
  --ink-3: #5d6b68;
  --line: #dde4e2;
  --line-strong: #c3cecb;
  --brand: #0f5f55;
  --brand-ink: #ffffff;
  --brand-soft: #e3f1ed;
  --focus: #1a73e8;
  --ok: #17663a;
  --ok-soft: #e6f4ea;
  --err: #b3261e;
  --err-soft: #fcebea;
  --warn: #8a4b00;
  --warn-soft: #fff4e0;
  --held: #6a4b9c;
  --held-soft: #f1ecf8;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 33, 30, .06), 0 4px 16px rgba(16, 33, 30, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  overflow-x: hidden;
}

.app { min-height: 100vh; display: flex; flex-direction: column; }
.boot { margin: 3rem auto; color: var(--ink-2); }

a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

/* ---------- Header and navigation ---------- */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.topbar-inner {
  max-width: 1120px; margin: 0 auto; padding: .6rem 1rem;
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
}
.brand {
  display: flex; align-items: center; gap: .5rem;
  font-weight: 700; font-size: 1.1rem; color: var(--ink); text-decoration: none;
  margin-right: auto;
}
.brand img { width: 28px; height: 28px; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; order: 3; width: 100%; }
.nav a {
  padding: .4rem .75rem; border-radius: 999px; color: var(--ink-2);
  text-decoration: none; font-weight: 600; font-size: .95rem;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); }
.who { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.who-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; text-align: right; }
.who-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 12rem; }
.who-handle { color: var(--ink-3); font-size: .85rem; }

@media (min-width: 760px) {
  .nav { order: 0; width: auto; margin-right: auto; }
  .brand { margin-right: 1rem; }
}

/* ---------- Layout ---------- */

main { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 1rem; }
.page-title { font-size: 1.5rem; margin: .25rem 0 1rem; letter-spacing: -.01em; }
.grid { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 960px) {
  .grid-2 { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: start; }
}
.stack { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.1rem; min-width: 0;
}
.card h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
.card h2 .sub { font-weight: 500; color: var(--ink-3); font-size: .9rem; margin-left: .35rem; }
.muted { color: var(--ink-3); }
.small { font-size: .875rem; }

/* ---------- Wallet summary ---------- */

.wallet {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem 2rem;
  background: linear-gradient(135deg, #0f5f55, #134e48);
  color: #fff; border: 0;
}
.wallet .label { font-size: .85rem; opacity: .9; font-weight: 600; letter-spacing: .02em; }
.wallet-main { flex: 1 1 14rem; min-width: 0; }
.wallet-available { font-size: 2.4rem; font-weight: 750; line-height: 1.1; letter-spacing: -.02em; overflow-wrap: anywhere; }
.wallet-secondary { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.wallet-secondary .amt { font-size: 1.05rem; font-weight: 600; overflow-wrap: anywhere; }
.wallet-held .amt { color: #efe6ff; }
.wallet .btn-ghost { color: #fff; border-color: rgba(255,255,255,.55); }
.wallet .btn-ghost:hover { background: rgba(255,255,255,.12); }
.wallet :focus-visible { outline-color: #ffd54f; }

/* ---------- Forms ---------- */

.form { display: grid; gap: .8rem; }
.row { display: grid; gap: .8rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 520px) { .row-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.field { display: grid; gap: .3rem; min-width: 0; }
.field label { font-weight: 600; font-size: .9rem; color: var(--ink-2); }
.field .hint { font-size: .8rem; color: var(--ink-3); }
input, select {
  font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: .6rem .7rem; width: 100%; min-width: 0;
}
input:hover, select:hover { border-color: #9fb0ac; }
input[aria-invalid="true"] { border-color: var(--err); }
.check { display: flex; align-items: center; gap: .5rem; font-size: .9rem; color: var(--ink-2); }
.check input { width: auto; }

.btn {
  font: inherit; font-weight: 650; cursor: pointer;
  border-radius: var(--radius-sm); padding: .6rem 1rem;
  border: 1px solid transparent; background: var(--brand); color: var(--brand-ink);
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
}
.btn:hover { background: #0c5249; }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn-ghost { background: transparent; color: var(--brand); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: #fff; color: var(--err); border-color: #e3b4b0; }
.btn-danger:hover { background: var(--err-soft); }
.btn-sm { padding: .35rem .7rem; font-size: .9rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* ---------- Feedback ---------- */

.notice {
  border-radius: var(--radius-sm); padding: .6rem .75rem; font-size: .92rem;
  display: flex; gap: .5rem; align-items: flex-start; overflow-wrap: anywhere;
}
.notice::before { font-weight: 800; flex: none; }
.notice-error { background: var(--err-soft); color: var(--err); border: 1px solid #f1c5c1; }
.notice-error::before { content: "✕"; }
.notice-uncertain { background: var(--warn-soft); color: var(--warn); border: 1px solid #f3d7a6; }
.notice-uncertain::before { content: "?"; }
.notice-ok { background: var(--ok-soft); color: var(--ok); border: 1px solid #bfe0c9; }
.notice-ok::before { content: "✓"; }
.loading { color: var(--ink-3); font-style: italic; padding: .5rem 0; }
.empty {
  text-align: center; color: var(--ink-2); padding: 1.5rem 1rem;
  border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-2);
}
.empty strong { display: block; color: var(--ink); margin-bottom: .2rem; }

/* ---------- Lists ---------- */

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .25rem .75rem;
  padding: .75rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff;
}
.item-main { min-width: 0; }
.item-title { font-weight: 600; overflow-wrap: anywhere; }
.item-note { color: var(--ink-2); overflow-wrap: anywhere; white-space: pre-wrap; }
.item-note:empty { display: none; }
.item-meta { color: var(--ink-3); font-size: .82rem; display: flex; flex-wrap: wrap; gap: .25rem .6rem; align-items: center; }
.item-side { text-align: right; display: grid; gap: .3rem; justify-items: end; align-content: start; }
.item-amount { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.dir-in .item-amount { color: var(--ok); }
.dir-out .item-amount { color: var(--ink); }
.item-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; margin-top: .25rem; }
.item-actions .field { flex: 1 1 8rem; max-width: 12rem; }

.badge {
  display: inline-block; font-size: .75rem; font-weight: 700; letter-spacing: .03em;
  text-transform: uppercase; padding: .1rem .45rem; border-radius: 999px;
  border: 1px solid transparent;
}
.badge-public { background: #eef2f1; color: var(--ink-2); }
.badge-private { background: #fff1e6; color: #8a3f00; }
.badge-pending, .badge-open { background: var(--warn-soft); color: var(--warn); border-color: #f3d7a6; }
.badge-paid, .badge-captured { background: var(--ok-soft); color: var(--ok); border-color: #bfe0c9; }
.badge-declined { background: var(--err-soft); color: var(--err); border-color: #f1c5c1; }
.badge-cancelled, .badge-voided { background: #eef0f0; color: #4d5957; border-color: #d4dad9; }
.badge-expired { background: var(--held-soft); color: var(--held); border-color: #dccff0; }

.mono { font-family: var(--mono); font-size: .8rem; overflow-wrap: anywhere; }

/* ---------- Split preview ---------- */

.preview { display: grid; gap: .4rem; }
.share { display: flex; justify-content: space-between; gap: .75rem; padding: .45rem .6rem; background: var(--surface-2); border-radius: 8px; }
.share .who { font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.share-amt { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

/* ---------- Auth screens ---------- */

.auth-wrap { max-width: 440px; margin: 1.5rem auto; }
.welcome { max-width: 560px; margin: 2rem auto; text-align: center; }
.welcome p { color: var(--ink-2); }

.footer { text-align: center; color: var(--ink-3); font-size: .8rem; padding: 1rem; }
