:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --border: #e7e7ea;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --text-2: #52525b;
  --text-3: #a1a1aa;
  --accent: #ff7900;
  --accent-ink: #ffffff;
  --accent-soft: #fff4eb;
  --ok: #16a34a;
  --ok-soft: #ecfdf3;
  --warn: #c2410c;
  --warn-soft: #fff7ed;
  --err: #dc2626;
  --err-soft: #fef2f2;
  --shadow: 0 1px 2px rgba(16, 16, 20, .04), 0 1px 1px rgba(16, 16, 20, .03);
  --shadow-lg: 0 12px 32px -12px rgba(16, 16, 20, .14);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar: 248px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0d;
    --surface: #131316;
    --surface-2: #1b1b1f;
    --border: #232328;
    --border-strong: #2f2f36;
    --text: #f4f4f5;
    --text-2: #a1a1aa;
    --text-3: #63636d;
    --accent-ink: #111111;
    --accent-soft: rgba(255, 121, 0, .12);
    --ok: #4ade80;
    --ok-soft: rgba(74, 222, 128, .1);
    --warn: #fb923c;
    --warn-soft: rgba(251, 146, 60, .1);
    --err: #f87171;
    --err-soft: rgba(248, 113, 113, .1);
    --shadow: none;
    --shadow-lg: 0 16px 40px -16px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -.005em;
}
a { color: inherit; text-decoration: none; }
h1, h2 { margin: 0; letter-spacing: -.02em; }
h1 { font-size: 26px; font-weight: 650; line-height: 1.2; }
h2 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
.mono { font-family: "SF Mono", ui-monospace, Menlo, monospace; letter-spacing: 0; }
.sub { color: var(--text-2); margin-top: 4px; }
.hint { color: var(--text-3); font-size: 12.5px; }
.hint.spaced { margin: 10px 2px 24px; }
.strong { font-weight: 600; }
.small { font-size: 12px; }
.grow { flex: 1; }
.full { grid-column: 1 / -1; }

.icon {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- layout */
body.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex: none; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
  padding: 20px 12px; border-right: 1px solid var(--border); background: var(--surface);
}
.main { flex: 1; min-width: 0; }
.content { max-width: 920px; margin: 0 auto; padding: 40px 40px 64px; }

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 650; font-size: 15px; }
.logo {
  display: inline-block; flex: none;
  width: 22px; height: 22px; border-radius: 7px; background: var(--accent);
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .12);
}
.logo.lg { width: 40px; height: 40px; border-radius: 12px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-accounts { overflow-y: auto; min-height: 0; }
.nav-label {
  padding: 18px 10px 6px; color: var(--text-3);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px 10px; border-radius: 8px; border: 0; background: none;
  color: var(--text-2); font: inherit; text-align: left; cursor: pointer;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--surface-2); color: var(--text); font-weight: 550; }
.nav-item.muted-item { color: var(--text-3); }
.nav-item.muted-item:hover { color: var(--text); }
.nav-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }

@media (max-width: 820px) {
  body.app { flex-direction: column; }
  .sidebar {
    width: auto; height: auto; position: static; flex-direction: row; align-items: center;
    overflow-x: auto; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--border);
  }
  .brand { padding: 4px 10px; }
  .nav, .sidebar-foot { flex-direction: row; }
  .nav-label { display: none; }
  .sidebar-foot { margin: 0 0 0 auto; padding: 0; border: 0; }
  .nav-item { white-space: nowrap; }
  .content { padding: 24px 18px 48px; }
}

/* ---------- page head */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 28px; }
.identity { display: flex; align-items: center; gap: 16px; }
.back {
  display: inline-flex; align-items: center; gap: 4px; margin-bottom: 10px;
  color: var(--text-3); font-size: 13px;
}
.back::before { content: "←"; }
.back:hover { color: var(--text); }
.unit { font-size: 16px; color: var(--text-3); font-weight: 500; }

/* ---------- avatars, pills */
.avatar {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 650; font-size: 13px;
}
.avatar.xs { width: 22px; height: 22px; border-radius: 6px; font-size: 10px; }
.avatar.lg { width: 52px; height: 52px; border-radius: 14px; font-size: 18px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.neutral { background: var(--surface-2); color: var(--text-3); }
.pill.bad { background: var(--err-soft); color: var(--err); border-color: transparent; }
.pill .raw { opacity: .7; font-weight: 400; }
.list.flush { box-shadow: none; }
.list-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.amount { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pin-sm { width: 90px; flex: none !important; }

/* ---------- cards */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.card.narrow { max-width: 480px; }
.card.center { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; margin-left: auto; margin-right: auto; }
.card h2 + .form, .card h2 + .inline-form, .card h2 + .facts { margin-top: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.card-icon {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.empty-icon {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-2);
}
.empty-icon .icon { width: 20px; height: 20px; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* ---------- stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 36px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow);
}
.stat-label { color: var(--text-2); font-size: 12.5px; }
.stat-value { font-size: 28px; font-weight: 650; letter-spacing: -.03em; line-height: 1; }

.section { margin-bottom: 36px; }
.section-title { font-size: 13px; color: var(--text-2); font-weight: 600; margin-bottom: 12px; }

/* ---------- account cards */
.account-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.account-card {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.account-card:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.account-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.account-card-name { font-weight: 600; font-size: 15px; }
.account-card-number { color: var(--text-3); font-size: 12.5px; }
.account-card-balances {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border);
}
.mini-label { display: block; color: var(--text-3); font-size: 11.5px; }
.mini-value { display: block; font-weight: 600; font-variant-numeric: tabular-nums; }
.account-card.add {
  align-items: center; justify-content: center; gap: 8px; min-height: 180px;
  border-style: dashed; background: transparent; box-shadow: none; color: var(--text-3);
}
.account-card.add:hover { color: var(--text); transform: none; box-shadow: none; }
.add-icon {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  border: 1px dashed var(--border-strong); font-size: 20px; line-height: 1;
}

/* ---------- lists */
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.list-row { display: flex; align-items: center; gap: 16px; padding: 14px 18px; }
.list-row + .list-row { border-top: 1px solid var(--border); }
.list-main { flex: 1; min-width: 0; }
.list-main .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-main .sub { font-size: 12.5px; margin-top: 2px; }
.empty {
  padding: 28px; text-align: center; color: var(--text-3);
  border: 1px dashed var(--border); border-radius: var(--radius);
}

/* ---------- balances */
.balance-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.balance-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; display: flex; flex-direction: column; gap: 18px; box-shadow: var(--shadow);
}
.balance-card.accent { background: linear-gradient(180deg, var(--accent-soft), var(--surface) 70%); }
.balance-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.balance-label { font-weight: 600; }
.balance-time { color: var(--text-3); font-size: 12px; }
.balance-value { font-size: 34px; font-weight: 650; letter-spacing: -.035em; line-height: 1; font-variant-numeric: tabular-nums; }
.balance-value.empty { color: var(--text-3); letter-spacing: .1em; }
.currency { font-size: 14px; color: var(--text-3); font-weight: 500; margin-left: 6px; letter-spacing: 0; }
@media (max-width: 680px) { .balance-grid { grid-template-columns: 1fr; } }

/* ---------- forms */
.form { display: flex; flex-direction: column; gap: 16px; }
.form.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: end; }
@media (max-width: 680px) { .form.grid-2 { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 500; color: var(--text-2); }
.field em { font-style: normal; color: var(--text-3); font-weight: 400; }
input {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: var(--text-3); }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input:disabled { opacity: .5; }
.code-input { font-size: 18px; padding: 12px 14px; letter-spacing: .04em; }
.input-suffix { position: relative; display: block; }
.input-suffix input { padding-right: 56px; }
.input-suffix em {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font-style: normal; color: var(--text-3); font-size: 12.5px; pointer-events: none;
}
.inline-form { display: flex; gap: 8px; }
.saved-pin {
  flex: 1; display: inline-flex; align-items: center; gap: 8px; padding: 0 12px;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 13px;
}
.hint.centered { text-align: center; margin-top: 8px; }
.inline-form input { flex: 1; min-width: 0; }
.inline-form.wide { max-width: 460px; margin-top: 16px; }

/* ---------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--radius-sm); white-space: nowrap;
  font: inherit; font-weight: 550; cursor: pointer;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.primary:hover { opacity: .88; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); padding-left: 10px; padding-right: 10px; }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--err); }
.btn.danger:hover { background: var(--err-soft); color: var(--err); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.spaced-top { margin-top: 16px; }

/* ---------- flashes, banners */
.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }
.flash {
  padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13.5px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
}
.flash-success { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.flash-error { background: var(--err-soft); color: var(--err); border-color: transparent; }
.banner {
  display: flex; align-items: center; gap: 12px; margin-bottom: 20px;
  padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--accent);
  background: var(--accent-soft); font-weight: 500;
}

/* ---------- transfer */
.stepper { list-style: none; padding: 0; margin: 0 0 24px; display: flex; max-width: 480px; }
.stepper li { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; position: relative; color: var(--text-3); font-size: 12px; }
.stepper li::before {
  content: ""; position: absolute; top: 13px; left: -50%; width: 100%; height: 2px; background: var(--border);
}
.stepper li:first-child::before { display: none; }
.stepper li.done::before, .stepper li.current::before { background: var(--text); }
.step-dot {
  position: relative; z-index: 1; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 600; font-size: 12px;
  background: var(--surface); border: 2px solid var(--border);
}
.stepper li.done { color: var(--text-2); }
.stepper li.done .step-dot { background: var(--text); border-color: var(--text); color: var(--bg); }
.stepper li.current { color: var(--text); font-weight: 550; }
.stepper li.current .step-dot { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.stepper.failed li.current .step-dot { border-color: var(--err); color: var(--err); }

.facts { display: grid; grid-template-columns: 110px 1fr; gap: 10px 16px; margin: 16px 0 18px; }
.facts dt { color: var(--text-3); }
.facts dd { margin: 0; word-break: break-all; }
.actions { display: flex; gap: 10px; margin-top: 18px; }
.status { display: flex; align-items: center; gap: 12px; color: var(--text-2); }
.result { display: flex; flex-direction: column; gap: 8px; }
.result.ok h2 { color: var(--ok); }
.result.error h2 { color: var(--err); }
.result-icon {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ok-soft); color: var(--ok); margin-bottom: 4px;
}
.result-icon .icon { width: 20px; height: 20px; stroke-width: 2.4; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%; flex: none;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- loading feedback (static/app.js) */
.btn.is-loading { cursor: progress; opacity: 1 !important; }
.btn.is-loading .icon { display: none; }
.btn-spinner {
  width: 14px; height: 14px; border-radius: 50%; flex: none;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .6s linear infinite;
}
.progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 50;
  pointer-events: none; opacity: 0; overflow: hidden;
}
.progress::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: -40%; width: 40%;
  background: var(--accent);
}
body.is-busy .progress { opacity: 1; }
body.is-busy .progress::before { animation: progress 1.1s ease-in-out infinite; }
body.is-busy { cursor: progress; }
@keyframes progress { to { left: 100%; } }

/* ---------- auth */
body.auth { min-height: 100vh; display: grid; place-items: center; }
.auth-wrap { width: 100%; padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.auth-card {
  width: 100%; max-width: 380px; padding: 32px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg);
}
.auth-brand { margin-bottom: 20px; }
.auth-title { font-size: 22px; }
.auth-sub { color: var(--text-2); margin: 6px 0 24px; }
.auth-card .flashes { margin-bottom: 16px; }
.auth-foot { color: var(--text-3); font-size: 12px; }

/* team & security */
.muted { color: var(--text-3); }
.whoami { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.whoami small { display: block; color: var(--text-3); font-size: 11px; }
.otp-input { font-size: 20px; letter-spacing: .3em; text-align: center; }
.qr { display: flex; justify-content: center; margin: 4px 0 12px; }
.qr svg { border-radius: var(--radius-sm); background: #fff; }
.hint.center { text-align: center; }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; word-break: break-all; }
pre.code { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; overflow-x: auto; user-select: all; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 500; color: var(--text-3); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table.audit td { font-size: 13px; }
.table tr.bad td:nth-child(2) { color: var(--err); }
.card { overflow-x: auto; }
.user-actions summary { list-style: none; cursor: pointer; display: inline-flex; }
.user-actions summary::-webkit-details-marker { display: none; }
.user-actions[open] { min-width: 260px; }
.form.compact { margin-top: 10px; gap: 10px; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.card.issued { border-color: var(--warn); }
