:root {
  --bg: #0f172a;
  --bg2: #1e293b;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --brand: #6366f1;
  --brand-ink: #ffffff;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --line: #e2e8f0;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f1f5f9;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; background: var(--bg); color: #fff;
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; letter-spacing: .2px; }
.brand span { color: #a5b4fc; font-weight: 600; }

#app { max-width: 520px; margin: 0 auto; padding: 20px 18px 48px; }
.view { animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.hidden { display: none !important; }

h1 { font-size: 1.5rem; margin: 8px 0 6px; }
h2 { font-size: 1.25rem; margin: 4px 0 10px; }
.muted { color: var(--muted); font-size: .95rem; line-height: 1.5; margin: 0 0 16px; }
.hint { color: var(--muted); font-size: .82rem; margin: 8px 0 0; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px;
}
label { display: block; font-weight: 600; font-size: .85rem; margin: 12px 0 6px; }
.card > label:first-child { margin-top: 0; }
input, select {
  width: 100%; padding: 12px 14px; font-size: 1rem;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--brand); border-color: transparent; }

.btn {
  width: 100%; padding: 14px; font-size: 1rem; font-weight: 600;
  border: none; border-radius: 10px; cursor: pointer; margin-top: 16px;
}
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.primary:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.link { background: none; border: none; color: var(--brand); font-size: .9rem; cursor: pointer; padding: 8px 0; }
.link.back { margin-bottom: 8px; }

/* Balance */
.balance-card {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff; border-radius: 18px; padding: 26px 22px; margin-bottom: 18px;
  box-shadow: 0 10px 30px rgba(79,70,229,.25);
}
.balance-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; opacity: .85; }
.balance-value { font-size: 3rem; font-weight: 800; line-height: 1.1; margin: 4px 0; }
.balance-meta { font-size: .85rem; opacity: .9; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 14px; font-size: .95rem; font-weight: 600; color: var(--ink);
  cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.tile:active { background: #f8fafc; }
.tile-emoji { font-size: 1.6rem; }

.preview { width: 100%; max-height: 260px; object-fit: contain; border-radius: 10px; margin-top: 12px; background: #f8fafc; }
.confirm { border-top: 1px dashed var(--line); margin-top: 16px; padding-top: 4px; }

.member-card { text-align: center; }
.member-phone { font-size: 1.8rem; font-weight: 800; letter-spacing: .04em; margin-bottom: 14px; }
.member-name { color: var(--muted); font-size: .95rem; }
.opt { color: var(--muted); font-weight: 400; font-size: .8rem; }
input:disabled { background: #f1f5f9; color: var(--muted); }
.member-code-label { font-size: .8rem; color: var(--muted); }
.member-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem;
  word-break: break-all; background: #f8fafc; border: 1px dashed var(--line);
  border-radius: 10px; padding: 12px; margin: 8px 0; color: var(--ink);
}

.list { display: flex; flex-direction: column; gap: 10px; }
.row {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.row-main { font-weight: 600; }
.row-sub { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.row-amt { font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.row-amt.plus { color: var(--ok); }
.row-amt.minus { color: var(--err); }
.pill { font-size: .72rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.pill.cost { background: #eef2ff; color: var(--brand); }

.btn.ghost { background: #eef2ff; color: var(--brand); }
.btn.danger { background: #fef2f2; color: var(--err); }
.toggle { display: flex; align-items: center; gap: 10px; font-weight: 500; font-size: .92rem; margin: 10px 0; }
.toggle input { width: auto; }
.email-status { font-size: .85rem; font-weight: 600; margin-top: 8px; }
.email-status.ok { color: var(--ok); }
.email-status.warn { color: var(--warn); }
.footer { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 24px; }
.footer a { color: var(--brand); }
.legal { line-height: 1.6; }
.legal h2 { margin-top: 22px; font-size: 1.1rem; }
.legal ul { padding-left: 20px; }
.legal li { margin: 6px 0; }
.topbar .link { color: #a5b4fc; text-decoration: none; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px;
  font-size: .9rem; max-width: 90%; z-index: 50; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.toast.ok { background: var(--ok); }
.toast.warn { background: var(--warn); }
.toast.err { background: var(--err); }
