:root {
  --bg: var(--tg-theme-bg-color, #fff);
  --bg2: var(--tg-theme-secondary-bg-color, #f2f3f5);
  --tx: var(--tg-theme-text-color, #111);
  --hint: var(--tg-theme-hint-color, #8a8f98);
  --link: var(--tg-theme-link-color, #2481cc);
  --btn: var(--tg-theme-button-color, #2481cc);
  --btn-tx: var(--tg-theme-button-text-color, #fff);
  --danger: var(--tg-theme-destructive-text-color, #e53935);
  --ok: #2e9d57;
  --warn: #d98a00;
  --line: rgba(127, 127, 127, .2);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--tx); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
.wrap {
  max-width: 560px; margin: 0 auto;
  padding: 12px 16px calc(24px + env(safe-area-inset-bottom));
}
h1 { font-size: 22px; margin: 8px 0 12px; }
h2 { font-size: 17px; margin: 22px 0 8px; }
p { margin: 8px 0; }
.hint { color: var(--hint); font-size: 14px; }
.top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 4px 0 8px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.top b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.banner { background: #fff4d6; color: #5c4300; border-radius: 10px; padding: 10px 12px; margin: 8px 0; font-size: 14px; }
.box { background: var(--bg2); border-radius: 14px; padding: 14px; margin: 10px 0; }
.bal { font-size: 34px; font-weight: 700; margin: 4px 0 10px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); min-height: 44px; }
.row:last-child { border-bottom: 0; }
.tap { cursor: pointer; }
.grow { flex: 1; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--line); white-space: nowrap; }
.chip.ok { background: rgba(46, 157, 87, .16); color: var(--ok); }
.chip.warn { background: rgba(217, 138, 0, .16); color: var(--warn); }
.chip.bad { background: rgba(229, 57, 53, .14); color: var(--danger); }
.chip.pr { background: var(--btn); color: var(--btn-tx); }
button, .btn {
  display: block; width: 100%; min-height: 48px; margin: 8px 0; padding: 10px 14px;
  border: 0; border-radius: 12px; font: inherit; font-weight: 600; cursor: pointer;
  background: var(--btn); color: var(--btn-tx); text-align: center;
}
button.sec { background: var(--bg2); color: var(--link); }
.box button.sec { background: var(--bg); }
button.danger { background: transparent; color: var(--danger); }
button.dangerf { background: var(--danger); color: #fff; }
button.mini { display: inline-block; width: auto; min-height: 44px; margin: 0; padding: 6px 12px; }
button:disabled { opacity: .55; cursor: default; }
button.ld::after { content: "…"; }
.btns { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }
label { display: block; margin: 12px 0 4px; font-size: 14px; color: var(--hint); }
input, select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; font: inherit; color: var(--tx);
  background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--btn); }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; margin: 0; color: var(--tx); font-size: 16px; }
.check input { width: 22px; min-height: 22px; height: 22px; flex: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.quote { min-height: 44px; font-size: 14px; color: var(--hint); margin: 6px 0; }
.empty { text-align: center; color: var(--hint); padding: 24px 8px; }
.card { background: linear-gradient(135deg, #1f2a44, #3a4a78); color: #fff; border-radius: 16px; padding: 16px; margin: 10px 0; }
.card.premium { background: linear-gradient(135deg, #2b2b2b, #6b5a2e); }
.card .num { font: 600 20px/1.3 ui-monospace, Menlo, Consolas, monospace; letter-spacing: 1px; margin: 14px 0 6px; word-break: break-all; }
.card .chip { background: rgba(255, 255, 255, .2); color: #fff; }
.card .sum { font-size: 22px; font-weight: 700; }
.secret { background: rgba(0, 0, 0, .25); border-radius: 12px; padding: 10px 12px; margin-top: 10px; }
.secret button { background: rgba(255, 255, 255, .2); color: #fff; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.sheetbg { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet { background: var(--bg); width: 100%; max-width: 560px; border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 90vh; overflow: auto; }
.warnbox { background: rgba(229, 57, 53, .1); color: var(--tx); border-radius: 10px; padding: 10px 12px; }
#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 20;
  max-width: 528px; margin: 0 auto; background: rgba(20, 20, 20, .92); color: #fff;
  padding: 12px 14px; border-radius: 12px; font-size: 15px; opacity: 0; transform: translateY(12px);
  transition: opacity .2s, transform .2s; pointer-events: none;
}
#toast.on { opacity: 1; transform: none; }
.sk { height: 64px; border-radius: 14px; margin: 12px 0; background: linear-gradient(90deg, var(--bg2) 25%, var(--line) 50%, var(--bg2) 75%); background-size: 200% 100%; animation: sk 1.2s infinite linear; }
@keyframes sk { to { background-position: -200% 0; } }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pager button { width: auto; flex: 1; }
.r { text-align: right; white-space: nowrap; }
.link { word-break: break-all; }
