/* Mm Pay Admin — тёмная «консоль управления».
   Все классы из app.js сохранены; анимации CSS не меняют логику. */

:root {
  color-scheme: dark;

  --bg: #070b14;
  --bg-2: #0b1220;
  --panel: rgba(17, 26, 43, .74);
  --panel-solid: #111a2b;
  --line: rgba(148, 163, 184, .16);
  --fg: #e8f0fb;
  --muted: #8b9bb4;
  --cyan: #22d3ee;
  --blue: #4f8cff;
  --violet: #a78bfa;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #fb7185;

  /* Совместимость с темой Telegram (светлая тема переопределяется ниже). */
  --tg-bg: var(--tg-theme-bg-color, transparent);
  --tg-fg: var(--tg-theme-text-color, transparent);
  --tg-hint: var(--tg-theme-hint-color, transparent);
  --tg-link: var(--tg-theme-link-color, transparent);
  --tg-btn: var(--tg-theme-button-color, transparent);
  --tg-btn-fg: var(--tg-theme-button-text-color, transparent);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f1f5fb;
  --bg-2: #e8eef8;
  --panel: rgba(255, 255, 255, .82);
  --panel-solid: #ffffff;
  --line: rgba(15, 23, 42, .1);
  --fg: #142033;
  --muted: #62748e;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  position: relative;
  min-height: 100vh;
  padding-bottom: 40px;
  overflow-x: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--fg);
  background:
    radial-gradient(1100px 600px at 15% -10%, rgba(79, 140, 255, .16), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(167, 139, 250, .12), transparent 55%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
}

/* Живой фон: медленно дышащие пятна + техническая сетка. */
body::before {
  content: "";
  position: fixed;
  inset: -30%;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(circle at 30% 30%, rgba(34, 211, 238, .10), transparent 38%),
    radial-gradient(circle at 70% 65%, rgba(167, 139, 250, .10), transparent 40%);
  animation: drift 22s ease-in-out infinite alternate;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .35;
  background-image:
    linear-gradient(rgba(148, 163, 184, .055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, .055) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(180deg, #000, transparent 72%);
}

@keyframes drift {
  0%   { transform: translate3d(-3%, -2%, 0) scale(1); }
  100% { transform: translate3d(4%, 3%, 0) scale(1.12); }
}

/* ---------- Шапка ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 14px 16px 12px;
  background: linear-gradient(180deg, rgba(7, 11, 20, .94), rgba(7, 11, 20, .72));
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .28);
}

html[data-theme="light"] .topbar {
  background: linear-gradient(180deg, rgba(241, 245, 251, .95), rgba(241, 245, 251, .78));
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 12px;
  font-size: 19px;
  background: linear-gradient(145deg, rgba(34, 211, 238, .18), rgba(167, 139, 250, .22));
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, .35), 0 0 22px rgba(34, 211, 238, .18);
  animation: mark-pulse 3.2s ease-in-out infinite;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 15px;
  border: 1px solid transparent;
  background: conic-gradient(from 0deg, transparent, var(--cyan), transparent 45%) border-box;
  mask: linear-gradient(#000 0 0) padding-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  animation: orbit 5s linear infinite;
}

@keyframes orbit { to { transform: rotate(360deg); } }
@keyframes mark-pulse {
  0%, 100% { box-shadow: inset 0 0 0 1px rgba(34,211,238,.35), 0 0 18px rgba(34,211,238,.14); }
  50%      { box-shadow: inset 0 0 0 1px rgba(34,211,238,.6), 0 0 30px rgba(34,211,238,.32); }
}

.brand-text { flex: 1; min-width: 0; }

.topbar h1 {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: .06em;
  line-height: 1.15;
  white-space: nowrap;
}

.topbar .accent {
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-sub {
  margin-top: 2px;
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
}

.status {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(52, 211, 153, .08);
  border: 1px solid rgba(52, 211, 153, .22);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--ok);
  white-space: nowrap;
}

.status-dot {
  position: relative;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 10px var(--ok);
}

.status-dot::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid var(--ok);
  animation: ping 2s ease-out infinite;
}

@keyframes ping {
  0%   { transform: scale(.6); opacity: .9; }
  100% { transform: scale(1.8); opacity: 0; }
}

#clock {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.tabs {
  position: relative;
  display: flex;
  gap: 4px;
  margin-top: 13px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 4px;
  border-radius: 13px;
  background: rgba(148, 163, 184, .07);
  border: 1px solid var(--line);
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  flex: 1;
  min-width: max-content;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: color .25s, background .25s, transform .2s, box-shadow .25s;
}

.tab:hover { color: var(--fg); }

.tab.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(79, 140, 255, .95), rgba(139, 92, 246, .9));
  box-shadow: 0 6px 20px rgba(79, 140, 255, .32), inset 0 1px 0 rgba(255, 255, 255, .22);
  transform: translateY(-1px);
}

.tab.active::after {
  content: "";
  position: absolute;
  left: 22%; right: 22%; bottom: 4px;
  height: 1px;
  background: rgba(255, 255, 255, .75);
  border-radius: 2px;
  animation: tab-glow 2.4s ease-in-out infinite;
}

@keyframes tab-glow { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }

/* ---------- Контент ---------- */

.view {
  position: relative;
  z-index: 1;
  padding: 16px;
}

.card {
  position: relative;
  overflow: hidden;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
  transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease;
  animation: card-in .38s cubic-bezier(.2, .8, .2, 1) both;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(34, 211, 238, .65), rgba(167, 139, 250, .5), transparent);
  opacity: .55;
  transition: opacity .25s;
}

.card:hover {
  transform: translateY(-2px);
  border-color: rgba(34, 211, 238, .3);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .28), 0 0 0 1px rgba(34, 211, 238, .08);
}

.card:hover::before { opacity: 1; }

@keyframes card-in {
  from { opacity: 0; transform: translateY(10px) scale(.99); }
  to   { opacity: 1; transform: none; }
}

.card h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 9px;
  letter-spacing: .01em;
}

.card .meta { font-size: 13px; line-height: 1.6; }
.card .meta b { font-weight: 650; }

.card code, code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .92em;
  background: rgba(34, 211, 238, .09);
  color: var(--cyan);
  border: 1px solid rgba(34, 211, 238, .14);
  padding: 1px 6px;
  border-radius: 6px;
  word-break: break-all;
}

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.kv .k { color: var(--muted); }
.kv .v { text-align: right; word-break: break-all; }

/* Статусы */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 9px;
  color: var(--muted);
  background: rgba(148, 163, 184, .12);
  border: 1px solid rgba(148, 163, 184, .18);
}

.badge::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.badge.pending,
.badge.processing,
.badge.manual {
  color: var(--warn);
  background: rgba(251, 191, 36, .1);
  border-color: rgba(251, 191, 36, .28);
}

.badge.pending::before,
.badge.processing::before { animation: blink 1.4s ease-in-out infinite; }

.badge.manual { color: var(--cyan); background: rgba(34, 211, 238, .1); border-color: rgba(34, 211, 238, .28); }

.badge.approved,
.badge.settled {
  color: var(--ok);
  background: rgba(52, 211, 153, .1);
  border-color: rgba(52, 211, 153, .28);
}

.badge.declined,
.badge.failed {
  color: var(--danger);
  background: rgba(251, 113, 133, .1);
  border-color: rgba(251, 113, 133, .28);
}

.badge.failed::before { animation: blink 1s steps(2) infinite; }

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .2; } }

/* Кнопки */
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.btn {
  position: relative;
  overflow: hidden;
  flex: 1;
  min-width: 110px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 11px;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), #6d5efc);
  box-shadow: 0 6px 18px rgba(79, 140, 255, .22);
  transition: transform .15s, box-shadow .2s, filter .2s;
}

.btn::after {
  content: "";
  position: absolute;
  top: 0; left: -120%;
  width: 60%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .28), transparent);
  transform: skewX(-22deg);
  transition: left .55s ease;
}

.btn:hover::after { left: 140%; }
.btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
.btn:active { transform: translateY(1px) scale(.985); }

.btn.ok {
  background: linear-gradient(135deg, #10b981, #34d399);
  box-shadow: 0 6px 18px rgba(52, 211, 153, .22);
}

.btn.danger {
  background: linear-gradient(135deg, #e11d48, #fb7185);
  box-shadow: 0 6px 18px rgba(251, 113, 133, .2);
}

.btn.ghost {
  background: rgba(148, 163, 184, .06);
  color: var(--cyan);
  border-color: rgba(34, 211, 238, .3);
  box-shadow: none;
}

.btn:disabled { opacity: .45; cursor: default; transform: none; filter: grayscale(.4); }
.btn:disabled::after { display: none; }
.btn.small { padding: 7px 11px; font-size: 11px; flex: 0 0 auto; min-width: 0; }

/* Изображения */
.receipt, .qr-thumb {
  border: 1px solid var(--line);
  background: #050912;
}

.receipt {
  width: 100%;
  border-radius: 12px;
  margin-top: 12px;
  max-height: 260px;
  object-fit: contain;
}

.qr-thumb {
  position: relative;
  width: 92px; height: 92px;
  border-radius: 10px;
  object-fit: cover;
  margin-right: 12px;
}

.qr-slot { position: relative; flex: 0 0 auto; }
.qr-slot:empty { display: none; }

.qr-slot:not(:empty)::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: linear-gradient(180deg, transparent 46%, rgba(34, 211, 238, .55) 50%, transparent 54%);
  background-size: 100% 42px;
  animation: scan 2.6s linear infinite;
  pointer-events: none;
}

@keyframes scan { from { background-position: 0 -42px; } to { background-position: 0 130px; } }

/* Пустые состояния и загрузка */
.empty {
  position: relative;
  text-align: center;
  color: var(--muted);
  padding: 44px 12px;
  font-size: 13px;
  border-radius: 16px;
  border: 1px dashed var(--line);
  overflow: hidden;
}

.empty:not(:only-child)::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(34, 211, 238, .08) 50%, transparent 80%);
  background-size: 220% 100%;
  animation: shimmer 1.6s linear infinite;
}

@keyframes shimmer { from { background-position: 180% 0; } to { background-position: -80% 0; } }

/* Формы */
input, select {
  width: 100%;
  background: rgba(7, 11, 20, .6);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 13px;
  font-size: 14px;
  margin-bottom: 10px;
  transition: border-color .2s, box-shadow .2s;
}

html[data-theme="light"] input,
html[data-theme="light"] select { background: rgba(255, 255, 255, .75); }

input:focus, select:focus {
  outline: none;
  border-color: rgba(34, 211, 238, .55);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, .12);
}

input::placeholder { color: var(--muted); opacity: .8; }
input[type="file"] { padding: 9px; font-size: 12px; }

.form-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--cyan);
  margin: 2px 0 12px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.switch-row:last-child { border-bottom: none; }

.switch {
  position: relative;
  width: 48px; height: 27px;
  flex: 0 0 48px;
  border-radius: 999px;
  background: rgba(148, 163, 184, .22);
  cursor: pointer;
  transition: background .3s, box-shadow .3s;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 21px; height: 21px;
  border-radius: 50%;
  background: #f8fafc;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
  transition: transform .3s cubic-bezier(.2, .9, .2, 1.2);
}

.switch.on {
  background: linear-gradient(135deg, #10b981, #34d399);
  box-shadow: 0 0 18px rgba(52, 211, 153, .35);
}
.switch.on::after { transform: translateX(21px); }

/* Уведомления */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 100;
  max-width: 90%;
  transform: translateX(-50%);
  padding: 12px 18px;
  border-radius: 13px;
  font-size: 13px;
  font-weight: 650;
  color: var(--fg);
  background: rgba(17, 26, 43, .96);
  border: 1px solid rgba(34, 211, 238, .35);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .45), 0 0 24px rgba(34, 211, 238, .12);
  backdrop-filter: blur(14px);
  animation: toast-in .32s cubic-bezier(.2, .9, .2, 1.3);
}

html[data-theme="light"] .toast { background: rgba(255, 255, 255, .97); }

.toast.err {
  border-color: rgba(251, 113, 133, .45);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .45), 0 0 24px rgba(251, 113, 133, .18);
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 18px) scale(.94); }
  to   { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

.hidden { display: none !important; }

.row { display: flex; align-items: center; }
.row .meta { flex: 1; min-width: 0; }

.manual-banner {
  border-left: 3px solid var(--cyan);
  background: linear-gradient(90deg, rgba(34, 211, 238, .12), var(--panel) 60%);
}

.hint { color: var(--muted); font-size: 12px; line-height: 1.5; }

/* Глобальный индикатор запросов */
.busy {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  z-index: 200;
  overflow: hidden;
  background: rgba(34, 211, 238, .1);
}

.busy::after {
  content: "";
  display: block;
  width: 40%;
  height: 100%;
  background: linear-gradient(90deg, transparent, var(--cyan), var(--violet), transparent);
  animation: loading 1.1s ease-in-out infinite;
}

@keyframes loading { from { transform: translateX(-100%); } to { transform: translateX(350%); } }

/* Тонкий скроллбар */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, .25); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: rgba(34, 211, 238, .45); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
