:root {
  --brown: #562417;
  --brown-2: #ad5237;
  --accent: #9d4432;
  --accent-2: #b75237;
  --text: #2a1712;
  --muted: #7a645e;
  --card: #ffffff;
  --ok: #1f8a4c;
  --err: #c0392b;
  --radius: 20px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--brown);
  -webkit-font-smoothing: antialiased;
}
.bg {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(circle at 50% 0%, rgba(173, 82, 55, 0.9) 0%, rgba(86, 36, 23, 1) 70%),
    url("/pattern.jpg") top left / 260px repeat;
  background-blend-mode: multiply;
}
.app {
  max-width: 440px; margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
}
.top { display: flex; justify-content: center; padding: 12px 0 20px; }
.logo { width: 220px; height: auto; }
[hidden] { display: none !important; }
.screen { display: flex; flex-direction: column; gap: 14px; }

.card {
  background: var(--card); border-radius: var(--radius);
  padding: 20px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}
h1 { font-size: 22px; margin: 0 0 6px; }
h2 { font-size: 17px; margin: 0 0 12px; }
p { margin: 0; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.45; }
.small { font-size: 12.5px; }
.center { text-align: center; }
.label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }

.field { display: block; margin: 16px 0 0; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=tel], input[type=date] {
  width: 100%; font: inherit; font-size: 17px; padding: 13px 14px;
  border: 1.5px solid #e2d6d2; border-radius: 12px; background: #fff; color: var(--text);
  outline: none;
}
input:focus { border-color: var(--accent); }
.phone-input { display: flex; align-items: stretch; }
.phone-input .prefix {
  display: flex; align-items: center; padding: 0 12px; font-size: 17px;
  background: #f5eeec; border: 1.5px solid #e2d6d2; border-right: 0; border-radius: 12px 0 0 12px;
}
.phone-input input { border-radius: 0 12px 12px 0; }
.code-input { letter-spacing: .5em; text-align: center; font-size: 26px !important; font-weight: 600; }
.captcha { margin-top: 16px; min-height: 65px; display: flex; justify-content: center; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.field-static { margin-top: 16px; font-size: 15px; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 16px 0 0; font-size: 14px; line-height: 1.4; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); flex: none; }

.btn {
  display: block; width: 100%; margin-top: 18px; padding: 14px 16px;
  font: inherit; font-size: 16px; font-weight: 600; color: #fff;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  border: 0; border-radius: 14px; cursor: pointer;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn.secondary { background: var(--brown); }
.link {
  background: none; border: 0; padding: 8px 0; font: inherit; font-size: 14px;
  color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.link:disabled { color: #b9a9a4; cursor: default; text-decoration: none; }
.link.center { display: block; margin: 8px auto 0; }
.row-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.error { color: var(--err); font-size: 14px; margin-top: 10px; min-height: 1em; }
.error:empty, .ok:empty { display: none; }
.ok { color: var(--ok); font-size: 14px; margin-top: 10px; }

.balance-card {
  background: linear-gradient(145deg, #b75237 0%, #7a2f1d 100%); color: #fff;
}
.balance-card .label { color: rgba(255, 255, 255, .75); margin-top: 4px; }
.hello { font-size: 16px; font-weight: 500; }
.balance { font-size: 44px; font-weight: 700; line-height: 1.1; margin-top: 4px; }
.balance .cur { font-size: 28px; font-weight: 600; opacity: .85; }
.expiry {
  margin-top: 10px; display: inline-block; padding: 6px 10px; border-radius: 10px;
  background: rgba(255, 255, 255, .18); font-size: 13.5px;
}

.qr-card { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.qr { width: 230px; max-width: 100%; aspect-ratio: 1; }
.qr svg { width: 100%; height: 100%; display: block; }

.level-head { display: flex; justify-content: space-between; align-items: center; }
.level-name { font-size: 20px; font-weight: 700; margin-top: 2px; }
.level-pct {
  font-size: 22px; font-weight: 700; color: var(--accent);
  background: #f7ebe7; padding: 8px 12px; border-radius: 12px;
}
.progress { height: 8px; background: #f0e6e3; border-radius: 99px; margin: 14px 0 8px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-radius: 99px; }

.history { list-style: none; margin: 0; padding: 0; }
.history li { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-top: 1px solid #f0e6e3; }
.history li:first-child { border-top: 0; }
.h-title { font-size: 15px; font-weight: 500; }
.h-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.h-amount { font-weight: 600; white-space: nowrap; }
.h-amount.plus { color: var(--ok); }
.h-amount.minus { color: var(--err); }
.footer { color: rgba(255, 255, 255, .6); margin-top: 6px; }

.spinner {
  width: 40px; height: 40px; margin: 60px auto; border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, .25); border-top-color: #fff;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
