/* ==========================================================================
   Банк любви — Mini App
   Тёмная сливово-розовая палитра: приложение открывается внутри Telegram,
   поэтому цвета заданы жёстко, чтобы выглядеть одинаково на любой теме.
   ========================================================================== */

:root {
  --bg: #140a17;
  --bg-soft: #1c0f22;
  --surface: #241430;
  --surface-2: #2e1a3c;
  --line: rgba(255, 255, 255, 0.08);

  --rose: #ff7eb6;
  --rose-deep: #e5457f;
  --violet: #8e5bd6;
  --gold: #f5c77e;
  --green: #6ee7a8;
  --red: #ff7a7a;

  --text: #f9eef5;
  --muted: #b49bb4;

  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  --tabbar-h: 68px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(120% 60% at 50% 0%, #34163f 0%, transparent 60%),
    radial-gradient(90% 50% at 100% 100%, #2a1030 0%, transparent 55%),
    var(--bg);
}

.hidden { display: none !important; }

/* ---------------------------------- Заставка -------------------------- */

.splash {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  background: var(--bg);
  z-index: 100;
  transition: opacity .4s ease;
}
.splash.is-gone { opacity: 0; pointer-events: none; }
.splash__heart { font-size: 56px; animation: beat 1.1s ease-in-out infinite; }
.splash__title { font-size: 24px; font-weight: 700; letter-spacing: .02em; }
.splash__sub { color: var(--muted); font-size: 14px; }

@keyframes beat {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.18); }
  30% { transform: scale(1); }
  45% { transform: scale(1.1); }
}

/* ---------------------------------- Каркас ---------------------------- */

.app {
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 16px);
  /* Только opacity: анимация transform с fill-mode оставляет элемент containing
     block'ом для position:fixed, и таб-бар уезжает вместе со страницей. */
  animation: fade-only .45s ease both;
}

@keyframes fade-only { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 18px 10px;
}
.topbar__brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar__mark { font-size: 26px; }
.topbar__name { font-weight: 700; font-size: 17px; letter-spacing: .01em; }
.topbar__motto { font-size: 12px; color: var(--muted); }
.topbar__avatar {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  font-size: 20px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.screens { padding: 0 16px; }
.screen { display: none; animation: fade-in .3s ease both; }
.screen.is-active { display: block; }
.screen__head { margin: 6px 2px 14px; }
.screen__title { font-size: 24px; font-weight: 700; margin: 0; }
.screen__sub { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

/* ---------------------------------- Карты счетов ---------------------- */

.cards { display: grid; gap: 14px; margin-top: 6px; }

.bank-card {
  position: relative;
  border-radius: 24px;
  padding: 20px;
  min-height: 190px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  box-shadow: var(--shadow);
  color: #fff;
  isolation: isolate;
}
.bank-card--current {
  background: linear-gradient(135deg, #e5457f 0%, #a02b8c 55%, #6d2ca8 100%);
}
.bank-card--savings {
  background: linear-gradient(135deg, #2e1a4d 0%, #4b2a6e 50%, #7a4a9e 100%);
}
.bank-card.is-frozen { filter: saturate(.45) brightness(.8); }

/* Блик, который медленно проезжает по карте */
.bank-card::after {
  content: "";
  position: absolute;
  top: -60%; left: -40%;
  width: 45%; height: 220%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.28), transparent);
  transform: rotate(18deg);
  animation: sweep 5.5s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
}
@keyframes sweep {
  0%, 65% { left: -45%; }
  100% { left: 130%; }
}

.bank-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(60% 80% at 85% 15%, rgba(255,255,255,.22), transparent 60%),
    radial-gradient(50% 60% at 10% 90%, rgba(0,0,0,.25), transparent 60%);
  pointer-events: none;
}

.bank-card > * { position: relative; z-index: 2; }

.bank-card__top { display: flex; align-items: flex-start; justify-content: space-between; }
.bank-card__label {
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  opacity: .85;
}
.bank-card__chip {
  width: 40px; height: 30px;
  border-radius: 7px;
  background: linear-gradient(140deg, #f7dfa5, #d4ac6a 45%, #f0d79f);
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.15);
}
.bank-card__chip::before,
.bank-card__chip::after {
  content: "";
  position: absolute;
  left: 6px; right: 6px;
  height: 1px;
  background: rgba(0,0,0,.22);
}
.bank-card__chip::before { top: 10px; }
.bank-card__chip::after {
  top: 19px;
  box-shadow: 0 -4.5px 0 rgba(0,0,0,.22), 0 4.5px 0 rgba(0,0,0,.14);
}

.bank-card__balance {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 12px rgba(0,0,0,.25);
}
.bank-card__currency { font-size: 14px; font-weight: 600; opacity: .9; margin-top: 2px; }

.bank-card__number {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 15px;
  letter-spacing: .12em;
  opacity: .92;
}
.bank-card__bottom { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.bank-card__holder { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.bank-card__rate {
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.18);
  backdrop-filter: blur(6px);
  white-space: nowrap;
}
.bank-card__frozen {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}

/* ---------------------------------- Быстрые действия ------------------- */

.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0; }
.quick__btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 6px;
  display: grid;
  justify-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .15s ease, background .2s ease;
}
.quick__btn span:first-child { font-size: 20px; }
.quick__btn:active { transform: scale(.95); background: var(--surface-2); }

/* ---------------------------------- Панели ---------------------------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.panel__title { font-size: 15px; font-weight: 700; margin: 0; }
.panel__hint { font-size: 12px; color: var(--gold); font-weight: 700; }

/* ---------------------------------- График ---------------------------- */

.chart { width: 100%; height: 140px; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart__line { fill: none; stroke: url(#lineGrad); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart__area { fill: url(#areaGrad); opacity: .55; }
.chart__dot { fill: #fff; stroke: var(--rose-deep); stroke-width: 2.5; }
.chart__empty { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: 13px; text-align: center; }

.chart__dash { stroke: var(--gold); stroke-width: 2; stroke-dasharray: 4 5; fill: none; opacity: .8; }

/* ---------------------------------- Прогноз --------------------------- */

.forecast { display: grid; gap: 8px; }
.forecast__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
}
.forecast__month { color: var(--muted); }
.forecast__bar {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,.07);
  overflow: hidden;
}
.forecast__fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--rose-deep), var(--gold));
  transform-origin: left;
  animation: grow .8s cubic-bezier(.2,.8,.3,1) both;
}
@keyframes grow { from { transform: scaleX(0); } }
.forecast__value { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 74px; text-align: right; }

/* ---------------------------------- Витрина --------------------------- */

.balance-chip {
  display: inline-block;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 13px;
  margin-bottom: 14px;
}
.balance-chip b { color: var(--rose); font-variant-numeric: tabular-nums; }

.services { display: grid; gap: 12px; }
.service {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform .15s ease, border-color .2s ease;
}
.service:active { transform: scale(.98); }
.service.is-locked { opacity: .5; }
.service__emoji {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  font-size: 26px;
  border-radius: 14px;
  background: linear-gradient(140deg, rgba(229,69,127,.28), rgba(142,91,214,.28));
  flex-shrink: 0;
}
.service__body { min-width: 0; flex: 1; }
.service__title { font-weight: 700; font-size: 15px; }
.service__desc {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.service__price {
  font-weight: 800;
  color: var(--rose);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
}
.service__price small { display: block; font-size: 10px; color: var(--muted); font-weight: 600; }

/* ---------------------------------- Заказы ---------------------------- */

.orders { display: grid; gap: 12px; }
.order {
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}
.order__top { display: flex; align-items: center; gap: 10px; }
.order__emoji { font-size: 22px; }
.order__title { font-weight: 700; flex: 1; }
.order__price { font-weight: 700; color: var(--rose); font-variant-numeric: tabular-nums; }
.order__meta { font-size: 12px; color: var(--muted); margin-top: 6px; }
.order__wish {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,.05);
  font-size: 13px;
  font-style: italic;
}
.order__actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.badge--new { background: rgba(245,199,126,.18); color: var(--gold); }
.badge--accepted { background: rgba(142,91,214,.22); color: #c9a6f0; }
.badge--done { background: rgba(110,231,168,.16); color: var(--green); }
.badge--cancelled { background: rgba(255,122,122,.16); color: var(--red); }

/* ---------------------------------- История --------------------------- */

.timeline { display: grid; gap: 2px; }
.tx {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
}
.tx:last-child { border-bottom: none; }
.tx__icon {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--surface);
  font-size: 18px;
  flex-shrink: 0;
}
.tx__body { flex: 1; min-width: 0; }
.tx__title { font-size: 14px; font-weight: 600; }
.tx__meta { font-size: 12px; color: var(--muted); }
.tx__comment { font-size: 12px; color: var(--muted); font-style: italic; margin-top: 2px; }
.tx__amount { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx__amount.is-in { color: var(--green); }
.tx__amount.is-out { color: var(--rose); }
.tx__amount.is-internal { color: var(--muted); }

/* ---------------------------------- Обмен ----------------------------- */

.rate-card {
  background: linear-gradient(140deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  display: grid;
  gap: 10px;
}
.rate-card__row { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; color: var(--muted); }
.rate-card__row b { color: var(--text); font-size: 16px; font-variant-numeric: tabular-nums; }
.rate-card__row--accent b { color: var(--gold); font-size: 22px; font-weight: 800; }

.methods { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 18px; }
.method {
  padding: 16px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  display: grid;
  justify-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .15s ease, border-color .2s ease;
}
.method span { font-size: 24px; }
.method:active { transform: scale(.96); }
.method.is-disabled { opacity: .4; pointer-events: none; }

.payouts { display: grid; gap: 10px; }
.payout {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 14px;
}
.payout__sum { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------------------------------- Банкир ---------------------------- */

.admin-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.stat__label { font-size: 12px; color: var(--muted); }
.stat__value { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; }

.rate-editor { display: flex; align-items: center; gap: 8px; }
.rate-editor__pct { font-size: 13px; color: var(--muted); white-space: nowrap; }

.clients { display: grid; gap: 12px; margin-top: 14px; }
.client {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.client__top { display: flex; align-items: center; gap: 10px; }
.client__avatar { font-size: 22px; }
.client__name { font-weight: 700; flex: 1; }
.client__total { font-weight: 800; color: var(--rose); font-variant-numeric: tabular-nums; }
.client__accounts { margin-top: 8px; display: grid; gap: 4px; }
.client__account { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.client__actions { display: flex; gap: 8px; margin-top: 12px; }

/* ---------------------------------- Кнопки ---------------------------- */

.btn {
  appearance: none;
  border: none;
  border-radius: 14px;
  padding: 13px 18px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  color: #fff;
  background: linear-gradient(135deg, var(--rose-deep), var(--violet));
  cursor: pointer;
  transition: transform .15s ease, opacity .2s ease;
  width: 100%;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn--ghost { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.btn--gold { background: linear-gradient(135deg, #d99b3f, var(--gold)); color: #33210a; }
.btn--small { width: auto; padding: 10px 14px; font-size: 13px; border-radius: 12px; }
.btn--danger { background: rgba(255,122,122,.18); color: var(--red); }
.btn--row { width: auto; flex: 1; }

.input {
  width: 100%;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s ease;
}
.input:focus { border-color: var(--rose-deep); }
.input + .input { margin-top: 10px; }

/* ---------------------------------- Табы ------------------------------ */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  align-items: stretch;
  background: rgba(20, 10, 23, .88);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
  z-index: 20;
}
.tab {
  position: relative;
  flex: 1;
  appearance: none;
  border: none;
  background: none;
  color: var(--muted);
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 2px;
  font-family: inherit;
  cursor: pointer;
  transition: color .2s ease;
  padding: 0;
}
.tab span { font-size: 19px; filter: grayscale(.6); transition: filter .2s ease, transform .2s ease; }
.tab i { font-size: 10px; font-style: normal; font-weight: 600; }
.tab.is-active { color: var(--rose); }
.tab.is-active span { filter: none; transform: translateY(-1px) scale(1.1); }
.tab__dot {
  position: absolute;
  top: 8px; right: 22%;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--rose-deep);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  font-style: normal;
  display: grid;
  place-items: center;
}

/* ---------------------------------- Модалка --------------------------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(3px);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  animation: fade-in .2s ease both;
}
.sheet {
  width: 100%;
  background: var(--bg-soft);
  border-radius: 26px 26px 0 0;
  padding: 10px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  animation: slide-up .3s cubic-bezier(.2,.8,.3,1) both;
  max-height: 88vh;
  overflow-y: auto;
}
@keyframes slide-up { from { transform: translateY(100%); } }
.sheet__grip { width: 38px; height: 4px; border-radius: 999px; background: rgba(255,255,255,.2); margin: 4px auto 14px; }
.sheet__title { margin: 0 0 6px; font-size: 19px; font-weight: 700; }
.sheet__text { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.sheet__actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet__actions .btn { flex: 1; }

.picker { display: grid; gap: 8px; }
.picker__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
}
.picker__item.is-selected { border-color: var(--rose-deep); background: var(--surface-2); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.chip {
  padding: 8px 13px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
}
.chip:active { background: var(--surface-2); }

/* ---------------------------------- Тост и ошибки --------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 18px);
  transform: translateX(-50%);
  max-width: calc(100% - 40px);
  padding: 12px 18px;
  border-radius: 14px;
  background: rgba(46, 26, 60, .96);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 600;
  z-index: 80;
  animation: toast-in .28s cubic-bezier(.2,.8,.3,1) both;
  text-align: center;
}
.toast.is-error { border-color: rgba(255,122,122,.5); color: #ffd7d7; }
.toast.is-success { border-color: rgba(110,231,168,.5); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 14px); } }

.error-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: 30px;
  text-align: center;
  background: var(--bg);
  z-index: 90;
  font-size: 15px;
  color: var(--muted);
}

.empty { text-align: center; color: var(--muted); padding: 36px 20px; font-size: 14px; }
.empty__emoji { font-size: 40px; display: block; margin-bottom: 8px; }

/* Празднование покупки */
.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 70;
  overflow: hidden;
}
.confetti__piece {
  position: absolute;
  font-size: 22px;
  animation: fall linear forwards;
}
@keyframes fall {
  from { transform: translateY(-12vh) rotate(0deg); opacity: 1; }
  to { transform: translateY(110vh) rotate(540deg); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
