* { box-sizing: border-box; }
:root {
  color-scheme: light dark;
  --page: var(--tg-theme-bg-color, #f3f5f2);
  --panel: var(--tg-theme-secondary-bg-color, #ffffff);
  --ink: var(--tg-theme-text-color, #19241d);
  --muted: var(--tg-theme-hint-color, #6b776e);
  --line: color-mix(in srgb, var(--ink) 12%, transparent);
  --green: #176b49;
  --green-soft: color-mix(in srgb, var(--green) 11%, var(--panel));
  --red: #b1433d;
  --shadow: 0 10px 26px color-mix(in srgb, var(--ink) 7%, transparent);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
html, body { margin: 0; min-height: 100%; background: var(--page); color: var(--ink); }
body { padding: env(safe-area-inset-top) 0 calc(82px + env(safe-area-inset-bottom)); }
button, input, select { font: inherit; }
button { color: inherit; }
.app-shell { width: min(100%, 620px); min-height: 100vh; margin: 0 auto; padding: 20px 18px 28px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 2px 0 20px; }
.brand { min-width: 0; }
.eyebrow { margin: 0 0 5px; color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .12em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 25px; line-height: 1.12; letter-spacing: -.035em; }
h2 { margin-bottom: 12px; font-size: 17px; letter-spacing: -.02em; }
h3 { margin-bottom: 5px; font-size: 15px; }
.icon-button, .quiet-button, .tab-button, .action-button, .primary-button, .secondary-button { border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.icon-button { width: 44px; height: 44px; flex: 0 0 44px; border: 1px solid var(--line); border-radius: 15px; background: var(--panel); font-size: 18px; }
.balance-hero { position: relative; overflow: hidden; padding: 20px; border-radius: 23px; background: #14583e; color: #f5fff8; box-shadow: var(--shadow); }
.balance-hero::after { content: ""; position: absolute; right: -45px; top: -65px; width: 170px; height: 170px; border: 1px solid rgb(255 255 255 / 13%); border-radius: 50%; box-shadow: 0 0 0 22px rgb(255 255 255 / 4%), 0 0 0 45px rgb(255 255 255 / 3%); pointer-events: none; }
.hero-label { margin: 0 0 10px; color: rgb(245 255 248 / 72%); font-size: 13px; }
.hero-value-row { display: flex; align-items: center; gap: 10px; }
.hero-value { margin: 0; font-size: clamp(31px, 9vw, 43px); line-height: 1; font-weight: 720; letter-spacing: -.045em; font-variant-numeric: tabular-nums; }
.hero-unit { align-self: flex-end; padding-bottom: 3px; color: rgb(245 255 248 / 78%); font-size: 13px; }
.hero-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 17px; color: rgb(245 255 248 / 76%); font-size: 12px; }
.reveal-button { position: relative; z-index: 1; padding: 8px; border: 0; border-radius: 11px; background: rgb(255 255 255 / 12%); color: white; cursor: pointer; }
.section { margin-top: 24px; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 11px; }
.section-heading h2 { margin: 0; }
.text-button { padding: 6px 0; border: 0; background: transparent; color: var(--green); font-size: 13px; font-weight: 650; cursor: pointer; }
.asset-list { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); }
.asset-row { display: flex; align-items: center; justify-content: space-between; min-height: 62px; padding: 10px 15px; }
.asset-row + .asset-row { border-top: 1px solid var(--line); }
.asset-name { display: flex; align-items: center; gap: 11px; font-size: 14px; font-weight: 620; }
.asset-mark { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 12px; background: var(--green-soft); color: var(--green); font-size: 12px; font-weight: 760; }
.breakdown-list { display: grid; gap: 3px; font-size: 12px; line-height: 1.35; }
.breakdown-empty { color: var(--muted); font-size: 12px; font-weight: 500; }
.asset-amount, .stat-value { font-variant-numeric: tabular-nums; font-weight: 680; }
.asset-amount { font-size: 15px; text-align: right; }
.asset-unit { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; font-weight: 500; }
.action-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.action-button { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 15px; background: var(--panel); font-size: 13px; font-weight: 640; text-align: left; }
.action-icon { display: grid; width: 29px; height: 29px; flex: 0 0 29px; place-items: center; border-radius: 10px; background: var(--green-soft); color: var(--green); font-size: 16px; }
.summary-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 10px; }
.summary-item { min-height: 82px; padding: 13px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
.summary-label { margin-bottom: 9px; color: var(--muted); font-size: 12px; }
.stat-value { font-size: 17px; }
.wallet-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--ink); font-size: 14px; font-weight: 650; }
.wallet-summary span { color: var(--muted); font-size: 11px; font-weight: 500; }
.wallet-list { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); }
.wallet-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 13px 14px; }
.wallet-row + .wallet-row { border-top: 1px solid var(--line); }
.transaction-list { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); }
.transaction { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 13px 14px; }
.transaction + .transaction { border-top: 1px solid var(--line); }
.transaction-title { margin: 0 0 4px; font-size: 13px; font-weight: 650; }
.transaction-meta { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.4; }
.transaction-amount { flex: 0 0 auto; font-size: 13px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.transaction-amount.positive { color: var(--green); }
.transaction-amount.negative { color: var(--red); }
.empty-state { padding: 24px 16px; color: var(--muted); font-size: 13px; text-align: center; }
.page-title { margin: 3px 0 19px; }
.form-section { display: grid; gap: 15px; }
.field { display: grid; gap: 7px; }
.field label { color: var(--muted); font-size: 12px; font-weight: 650; }
.field input, .field select { width: 100%; min-height: 48px; padding: 0 13px; border: 1px solid var(--line); border-radius: 13px; outline: none; background: var(--panel); color: var(--ink); }
.field input:focus, .field select:focus { border-color: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 16%, transparent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.primary-button, .secondary-button { width: 100%; min-height: 50px; padding: 12px 16px; border-radius: 15px; font-weight: 700; }
.primary-button { background: var(--green); color: #fff; }
.secondary-button { border: 1px solid var(--line); background: var(--panel); }
.button-row { display: grid; grid-template-columns: 1fr 1.3fr; gap: 9px; margin-top: 3px; }
.confirm-box { padding: 16px; border: 1px solid color-mix(in srgb, var(--green) 28%, var(--line)); border-radius: 17px; background: var(--green-soft); }
.confirm-box p { margin: 0 0 9px; font-size: 14px; line-height: 1.45; }
.confirm-box p:last-child { margin-bottom: 0; }
.confirm-caption { color: var(--muted); font-size: 12px !important; }
.notice { padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--red) 10%, var(--panel)); color: var(--red); font-size: 13px; line-height: 1.45; }
.bottom-nav { position: fixed; z-index: 5; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(4, 1fr); width: min(100%, 620px); margin: auto; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: color-mix(in srgb, var(--page) 94%, transparent); backdrop-filter: blur(14px); }
.tab-button { display: grid; min-height: 51px; place-content: center; gap: 3px; border-radius: 13px; background: transparent; color: var(--muted); font-size: 10px; font-weight: 650; }
.tab-button[aria-current="page"] { background: var(--green-soft); color: var(--green); }
.tab-icon { font-size: 17px; line-height: 1; }
.loading-state, .access-state { padding: 46px 14px; }
.access-state { display: grid; min-height: 75vh; align-content: center; }
.access-mark { margin-bottom: 15px; color: var(--green); font-size: 27px; }
.access-state p:last-child { max-width: 33ch; color: var(--muted); line-height: 1.5; }
.toast { position: fixed; z-index: 10; right: 18px; bottom: calc(83px + env(safe-area-inset-bottom)); left: 18px; width: min(100% - 36px, 500px); margin: auto; padding: 12px 15px; border-radius: 14px; background: #17251c; color: #fff; font-size: 13px; line-height: 1.4; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity .18s ease, transform .18s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; } }
.management-list { display: grid; gap: 9px; }
.management-card { display: grid; grid-template-columns: 38px 1fr 18px; align-items: center; gap: 12px; width: 100%; min-height: 72px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 17px; background: var(--panel); text-align: left; cursor: pointer; }
.management-card > span:nth-child(2) { display: grid; gap: 4px; }
.management-card strong { font-size: 14px; }
.management-card small { color: var(--muted); font-size: 11px; }
.management-icon { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 12px; background: var(--green-soft); }
.event-actions { display: flex; flex-wrap: wrap; gap: 3px 12px; margin-top: 8px; }
.event-actions .text-button { font-size: 11px; }
.danger-text { color: var(--red); }
button:disabled { cursor: not-allowed; opacity: .55; }

.status-badge { display: inline-block; margin-left: 8px; padding: 3px 7px; border-radius: 7px; background: var(--green-soft); color: var(--muted); font-size: 10px; }
.transaction-reversed .transaction-amount { text-decoration: line-through; color: var(--muted); }
.transaction-reversed { opacity: .75; }
#history-filter-form { padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
[data-more-history] { margin-top: 12px; }
