/* ============================================================
   FunPay · панель — «стекло».
   Полупрозрачные слои над размытыми цветными пятнами; свет/тьма
   берутся из темы Telegram, а не из догадок.
   ============================================================ */

:root {
  --bg: #0a120d;
  --glass: rgba(255, 255, 255, .055);
  --glass-strong: rgba(255, 255, 255, .10);
  --hair: rgba(255, 255, 255, .13);
  --hair-strong: rgba(255, 255, 255, .22);
  --text: #eef1f7;
  --muted: rgba(238, 241, 247, .58);
  --faint: rgba(238, 241, 247, .34);
  --accent: #7f5cff;
  --accent-2: #22d3a6;
  --warn: #ffb547;
  --bad: #ff6b6b;
  --ok: #3ddc97;
  --r-lg: 24px;
  --r-md: 18px;
  --r-sm: 12px;
  --shadow: 0 18px 50px -22px rgba(0, 0, 0, .85);
  --inset: inset 0 1px 0 rgba(255, 255, 255, .10);
  --blur: saturate(160%) blur(22px);
  --tab-h: 62px;
}

:root[data-theme="light"] {
  --bg: #e8f2ea;
  --glass: rgba(255, 255, 255, .58);
  --glass-strong: rgba(255, 255, 255, .78);
  --hair: rgba(20, 24, 40, .10);
  --hair-strong: rgba(20, 24, 40, .18);
  --text: #10131c;
  --muted: rgba(16, 19, 28, .60);
  --faint: rgba(16, 19, 28, .36);
  --shadow: 0 18px 40px -24px rgba(20, 30, 60, .45);
  --inset: inset 0 1px 0 rgba(255, 255, 255, .85);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Атрибут hidden перестает работать, если у элемента в CSS задан display:
   шит с затемнением на весь экран висел открытым и размывал панель. */
[hidden] { display: none !important; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Ubuntu, sans-serif;
  overscroll-behavior-y: none;
  padding: 0 14px calc(var(--tab-h) + 26px + env(safe-area-inset-bottom));
  transition: color .25s ease, background .25s ease;
}

/* ---------- фоновые пятна: без них «стекло» не читается ---------- */
.ambient { position: fixed; inset: -20% -20% -20% -20%; z-index: -1; overflow: hidden; filter: blur(70px); }
.ambient i { position: absolute; display: block; border-radius: 50%; opacity: .55; animation: drift 26s ease-in-out infinite alternate; }
.ambient i:nth-child(1) { width: 55vw; height: 55vw; left: -8vw; top: -6vw; background: radial-gradient(circle, #37d67a, transparent 65%); }
.ambient i:nth-child(2) { width: 62vw; height: 62vw; right: -14vw; top: 18vh; background: radial-gradient(circle, #12b6a0, transparent 65%); animation-delay: -8s; }
.ambient i:nth-child(3) { width: 48vw; height: 48vw; left: 12vw; bottom: -12vw; background: radial-gradient(circle, #9be15d, transparent 68%); animation-delay: -16s; opacity: .38; }
:root[data-theme="light"] .ambient { filter: blur(72px) saturate(135%); }
/* В светлой теме пятна были почти невидимы — карточки сливались в белое пятно
   и «стекло» не читалось стеклом. */
:root[data-theme="light"] .ambient i { opacity: .82; }
@keyframes drift { to { transform: translate3d(6vw, -4vh, 0) scale(1.12); } }

/* ---------- сам материал ---------- */
.glass {
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--hair);
  box-shadow: var(--shadow), var(--inset);
}

/* ---------- шапка ---------- */
.topbar {
  position: sticky; top: 10px; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  margin: 10px -4px 14px; padding: 9px 10px 9px 14px;
  border-radius: var(--r-lg);
}
.acct { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; background: none; border: 0; color: inherit; font: inherit; cursor: pointer; padding: 6px 2px; }
.acct-name { font-weight: 650; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { width: 15px; height: 15px; color: var(--faint); transition: transform .2s ease; }
.acct:active .chev { transform: translateY(1px); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex: none; box-shadow: 0 0 0 3px rgba(255,255,255,.06); }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(61, 220, 151, .18); }
.dot.off { background: var(--bad); box-shadow: 0 0 0 3px rgba(255, 107, 107, .16); }
.wallet { font-variant-numeric: tabular-nums; font-weight: 650; color: var(--muted); font-size: 13.5px; white-space: nowrap; }

/* ---------- экран ---------- */
.view { display: grid; gap: 12px; animation: rise .28s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.card { border-radius: var(--r-lg); padding: 16px; }
.card h2 { margin: 0 0 4px; font-size: 16px; letter-spacing: -.015em; }
.card p.sub { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.section-title { margin: 20px 4px 8px; font-size: 11.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--faint); font-weight: 600; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 10px; }
.metric { padding: 12px 13px; border-radius: var(--r-md); background: var(--glass); border: 1px solid var(--hair); box-shadow: var(--inset); }
.metric b { display: block; font-size: 19px; font-weight: 680; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.metric span { font-size: 11.5px; color: var(--muted); }

/* ---------- списки ---------- */
.list { display: grid; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 13px; border-radius: var(--r-md); text-align: left;
  background: var(--glass); border: 1px solid var(--hair); box-shadow: var(--inset);
  color: inherit; font: inherit; cursor: pointer; transition: transform .12s ease, background .18s ease;
}
.row:hover { background: var(--glass-strong); }
.row:active { transform: scale(.987); }
.row .grow { flex: 1; min-width: 0; display: grid; gap: 2px; }
.row .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .s { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.row .r { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.thumb { width: 38px; height: 38px; border-radius: 12px; flex: none; object-fit: cover; border: 1px solid var(--hair); background: var(--glass-strong); }
.avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; font-size: 15px;
  background: linear-gradient(140deg, rgba(127, 92, 255, .55), rgba(34, 211, 166, .45)); border: 1px solid var(--hair); }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: var(--glass-strong); border: 1px solid var(--hair); color: var(--muted); }
.chip.ok { color: var(--ok); border-color: rgba(61, 220, 151, .35); background: rgba(61, 220, 151, .10); }
.chip.warn { color: var(--warn); border-color: rgba(255, 181, 71, .35); background: rgba(255, 181, 71, .10); }
.chip.bad { color: var(--bad); border-color: rgba(255, 107, 107, .35); background: rgba(255, 107, 107, .10); }
.badge { position: absolute; top: 4px; right: 14px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
  background: var(--bad); color: #fff; font: 700 10px/16px sans-serif; text-align: center; font-style: normal; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 15px; font: inherit; font-weight: 620;
  color: inherit; background: var(--glass-strong); border: 1px solid var(--hair); box-shadow: var(--inset);
  cursor: pointer; transition: transform .12s ease, opacity .18s ease, filter .18s ease;
}
.btn:active { transform: scale(.975); }
.btn.primary { background: linear-gradient(150deg, var(--accent), #5b3df0); border-color: transparent; color: #fff; box-shadow: 0 12px 28px -14px rgba(127, 92, 255, .9), var(--inset); }
.btn.good { background: linear-gradient(150deg, #17c79a, #0e9e7c); border-color: transparent; color: #04140f; }
.btn.danger { color: var(--bad); border-color: rgba(255, 107, 107, .30); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.icon-btn { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: var(--glass); border: 1px solid var(--hair); color: var(--muted); cursor: pointer; font-size: 14px; }

/* ---------- поля ---------- */
label.f { display: block; margin: 0 0 13px; }
label.f > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 550; }
.input, textarea.input, select.input {
  width: 100%; min-height: 46px; padding: 12px 13px; border-radius: 14px; font: inherit; color: var(--text);
  background: rgba(0, 0, 0, .18); border: 1px solid var(--hair); box-shadow: var(--inset); outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}
:root[data-theme="light"] .input { background: rgba(255, 255, 255, .62); }
.input:focus { border-color: rgba(127, 92, 255, .65); box-shadow: 0 0 0 3px rgba(127, 92, 255, .16); }
textarea.input { min-height: 88px; resize: vertical; line-height: 1.4; }
.hint { font-size: 12px; color: var(--faint); margin: -8px 0 13px; line-height: 1.4; }
.hint code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 13px; border-radius: var(--r-md);
  background: var(--glass); border: 1px solid var(--hair); box-shadow: var(--inset); margin-bottom: 8px; }
.switch .t { font-weight: 570; }
.switch .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.track { position: relative; width: 46px; height: 28px; border-radius: 999px; flex: none; cursor: pointer;
  background: rgba(255, 255, 255, .12); border: 1px solid var(--hair); transition: background .22s ease; }
.track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); transition: transform .22s cubic-bezier(.4, 1.4, .5, 1); }
.track.on { background: linear-gradient(140deg, var(--accent), #4a2fd8); border-color: transparent; }
.track.on::after { transform: translateX(18px); }

.seg { display: flex; padding: 3px; gap: 3px; border-radius: 14px; background: var(--glass); border: 1px solid var(--hair); margin-bottom: 12px; }
.seg button { flex: 1; min-height: 38px; border-radius: 11px; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; transition: all .18s ease; }
.seg button.on { background: var(--glass-strong); color: var(--text); box-shadow: var(--inset); }

/* ---------- чат ---------- */
.thread { display: grid; gap: 9px; padding: 4px 0 90px; }
.msg { max-width: 82%; padding: 10px 13px; border-radius: 17px; background: var(--glass); border: 1px solid var(--hair);
  box-shadow: var(--inset); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); word-wrap: break-word; }
.msg b { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 3px; font-weight: 600; }
.msg.own { justify-self: end; background: linear-gradient(150deg, rgba(127, 92, 255, .30), rgba(91, 61, 240, .18)); border-color: rgba(127, 92, 255, .35); }
.composer { position: fixed; left: 14px; right: 14px; bottom: calc(var(--tab-h) + 18px + env(safe-area-inset-bottom)); z-index: 25;
  display: flex; gap: 9px; padding: 8px 8px 8px 15px; border-radius: 22px; }
.composer input { flex: 1; min-height: 42px; padding: 0; background: transparent; border: 0; outline: none; color: var(--text); font: inherit; }
.composer .send { width: 42px; height: 42px; border-radius: 15px; display: grid; place-items: center; border: 0; cursor: pointer;
  background: linear-gradient(150deg, var(--accent), #5b3df0); color: #fff; box-shadow: 0 8px 20px -10px rgba(127, 92, 255, .95); }

/* ---------- вкладки ---------- */
.tabbar {
  position: fixed; left: 14px; right: 14px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 40;
  display: grid; grid-auto-flow: column; height: var(--tab-h); border-radius: 22px; padding: 5px;
}
.tab { position: relative; border: 0; background: transparent; color: var(--faint); display: grid; justify-items: center; align-content: center; gap: 2px;
  border-radius: 17px; cursor: pointer; font-size: 9.6px; font-weight: 600; transition: color .2s ease, background .2s ease; }
.tab svg { width: 21px; height: 21px; }
.tab.is-active { color: var(--text); background: var(--glass-strong); box-shadow: var(--inset); }

/* ---------- шит ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(4, 6, 12, .55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fade .22s ease; }
.sheet { position: relative; width: 100%; max-height: 88vh; border-radius: 28px 28px 0 0; padding: 8px 16px calc(18px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; animation: slide .3s cubic-bezier(.22, 1, .36, 1); }
.sheet-grab { width: 38px; height: 4px; border-radius: 2px; background: var(--hair-strong); margin: 4px auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; font-size: 17px; letter-spacing: -.015em; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-foot { display: grid; gap: 9px; padding-top: 12px; }
@keyframes slide { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

/* ---------- состояния ---------- */
.empty { padding: 34px 18px; text-align: center; color: var(--muted); }
.empty svg { width: 42px; height: 42px; opacity: .3; margin-bottom: 10px; }
.sk { height: 62px; border-radius: var(--r-md); background: linear-gradient(100deg, var(--glass) 30%, var(--glass-strong) 48%, var(--glass) 62%);
  background-size: 220% 100%; animation: shine 1.35s linear infinite; }
@keyframes shine { to { background-position: -120% 0; } }
.boot { position: fixed; inset: 0; z-index: 90; display: grid; place-content: center; justify-items: center; gap: 18px; background: var(--bg); transition: opacity .35s ease; }
.boot.hide { opacity: 0; pointer-events: none; }
.boot-glass { width: 58px; height: 58px; border-radius: 19px; background: var(--glass); border: 1px solid var(--hair); box-shadow: var(--inset);
  animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.88) rotate(8deg); opacity: .6; } }
.boot p { margin: 0; color: var(--muted); font-size: 13px; }
.boot-why { display: grid; gap: 10px; justify-items: center; max-width: 82%; color: var(--muted);
  font-size: 11.5px; line-height: 1.5; text-align: center; word-break: break-word; }
.boot-why .btn { padding: 8px 16px; font-size: 13px; }

.toasts { position: fixed; left: 14px; right: 14px; top: calc(76px + env(safe-area-inset-top)); z-index: 80; display: grid; gap: 8px; pointer-events: none; }
.toast { padding: 11px 14px; border-radius: 15px; font-size: 13.5px; animation: rise .25s ease; }
.toast.bad { border-color: rgba(255, 107, 107, .4); }
.toast.ok { border-color: rgba(61, 220, 151, .4); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
@media (min-width: 620px) { body { max-width: 560px; margin: 0 auto; } .tabbar, .composer { max-width: 532px; } }
