/* ============================================================
   Moonveil VPN — WebApp theme v4 (deep design, live HTML)
   Глубина: многослойные тени + неоновые свечения + блики.
   Анимации: появление карточек, «проваливание» при нажатии,
   дыхание акцентной карточки.
   Контракты JS: #user, .tile[data-section], #section-title,
   #section-body, .back-button (внедряется JS), .key-card,
   .small-button, .badge, .info-grid, .profile-card, .qr-image...
   ============================================================ */

:root {
  color-scheme: dark;

  /* legacy (app.js может перезаписывать из Telegram-темы — дизайн не завязан) */
  --bg: #04060f;
  --card: #0b1430;
  --text: #eaf1ff;
  --muted: #93a6cf;
  --primary: #2f6bff;
  --primary-text: #ffffff;
  --border: rgba(74, 132, 240, 0.38);

  /* палитра Moonveil */
  --nv-bg-0: #02060f;
  --nv-bg-1: #04091a;
  --nv-card: rgba(9, 18, 44, 0.90);
  --nv-card-hi: rgba(17, 34, 78, 0.92);
  --nv-line: rgba(84, 142, 250, 0.46);
  --nv-line-strong: rgba(126, 178, 255, 0.92);
  --nv-accent: #2f6bff;
  --nv-accent-2: #69adff;
  --nv-glow: rgba(47, 107, 255, 0.45);
  --nv-text: #eaf1ff;
  --nv-muted: #93a6cf;

  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-dark: #7f1d1d;

  --press-ease: cubic-bezier(0.22, 0.8, 0.25, 1);

  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--nv-text);
  background:
    radial-gradient(680px 400px at 50% -8%, rgba(41, 98, 224, 0.20), transparent 62%),
    radial-gradient(800px 580px at 110% 94%, rgba(38, 102, 255, 0.20), transparent 68%),
    linear-gradient(180deg, var(--nv-bg-1) 0%, var(--nv-bg-0) 80%);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* ---------- Декор фона (как на макете) ---------- */

.bg-decor {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.decor-glow-top {
  position: absolute;
  left: 50%;
  top: -34vw;
  width: 92vw;
  height: 92vw;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(47, 107, 255, 0.20), transparent 65%);
  filter: blur(6px);
}

.decor-ring {
  position: absolute;
  right: -48vw;
  bottom: -54vw;
  width: 124vw;
  height: 124vw;
  border-radius: 50%;
  border: 1.5px solid rgba(130, 180, 255, 0.32);
  box-shadow:
    0 0 90px rgba(56, 116, 255, 0.24),
    inset 0 0 150px rgba(56, 116, 255, 0.10);
}

body.screen-mode .bg-decor,
body.admin-mode .bg-decor {
  display: none;
}

/* ---------- Каркас ---------- */

.app {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 16px clamp(14px, 6.5vw, 30px) 8px;
}

/* ---------- Шапка: логотип + аккаунт ---------- */

.brand-header {
  position: relative;
  display: grid;
  grid-template-columns: 47px 1fr 47px;
  align-items: center;
  min-height: 74px;
  margin: 2px 2px 16px;
  animation: riseIn 0.45s var(--press-ease) backwards;
}

.brand-lockup {
  grid-column: 2;
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.brand-mark {
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  overflow: visible;
  filter: drop-shadow(0 0 16px rgba(60, 133, 255, 0.55));
}

.brand-word {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.brand-name {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(27px, 7.4vw, 34px);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.5px;
  color: #f6f9ff;
  text-shadow: 0 0 22px rgba(124, 178, 255, 0.18);
}

.brand-vpn {
  margin-top: 6px;
  padding-left: 9px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 9px;
  color: #6da9ff;
  text-shadow: 0 0 10px rgba(77, 151, 255, 0.35);
}

.header-profile {
  position: static;
  grid-column: 3;
  justify-self: end;
  transform: none;
  width: 47px;
  min-height: 47px;
  height: 47px;
  padding: 0;
  justify-content: center;
  gap: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(125, 180, 255, 0.90);
  background:
    radial-gradient(circle at 34% 26%, rgba(95, 163, 255, 0.30), transparent 58%),
    rgba(7, 16, 44, 0.92);
  box-shadow:
    0 0 26px rgba(47, 107, 255, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  transition: transform 0.15s var(--press-ease), filter 0.15s ease;
}

.header-profile svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: #aad0ff;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 7px rgba(110, 175, 255, 0.75));
}

.header-profile:active {
  transform: scale(0.92);
  filter: brightness(1.2);
}

/* ---------- Карточки (общая глубина) ---------- */

.card,
.key-card,
.instruction-card,
.profile-card {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0) 42%),
    linear-gradient(160deg, rgba(14, 30, 70, 0.92), rgba(6, 12, 30, 0.96));
  border: 1px solid var(--nv-line);
  border-radius: 26px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow:
    0 26px 52px rgba(0, 0, 0, 0.58),
    0 0 28px rgba(48, 104, 235, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.card::before,
.key-card::before,
.instruction-card::before,
.profile-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(118deg, rgba(255, 255, 255, 0.06), transparent 30%, transparent 70%, rgba(61, 137, 255, 0.05));
}

/* ---------- Герой ---------- */

.hero-card {
  min-height: 176px;
  display: flex;
  align-items: center;
  padding-right: 26%;
  margin-bottom: 22px;
  border-color: rgba(112, 170, 255, 0.92);
  box-shadow:
    0 28px 58px rgba(0, 0, 0, 0.60),
    0 0 50px rgba(55, 118, 255, 0.36),
    inset 0 1px 0 rgba(255, 255, 255, 0.09);
  animation: riseIn 0.5s 0.06s var(--press-ease) backwards;
}

.hero-copy {
  position: relative;
  z-index: 2;
}

.hero-card h1 {
  margin: 0 0 9px;
  font-size: clamp(27px, 7.4vw, 33px);
  line-height: 1.05;
  letter-spacing: -0.6px;
  color: #f4f7ff;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.45);
}

.hero-sub {
  margin: 0;
  color: #9fb6e6;
  font-size: clamp(15.5px, 4.2vw, 18px);
  line-height: 1.25;
}

.hero-veil {
  position: absolute;
  z-index: 1;
  right: -46px;
  bottom: -16px;
  width: 78%;
  height: 94%;
  opacity: 0.85;
  pointer-events: none;
  filter: drop-shadow(0 0 18px rgba(52, 125, 255, 0.28));
}

/* ---------- Меню ---------- */

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 19px;
  margin-bottom: 16px;
}

.tile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 84px;
  padding: 15px 17px;
  text-align: left;
  cursor: pointer;
  color: var(--nv-text);
  font: inherit;
  border: 1px solid rgba(92, 148, 255, 0.52);
  border-radius: 26px;
  overflow: hidden;
  background:
    linear-gradient(160deg, rgba(11, 22, 52, 0.92), rgba(5, 11, 28, 0.95));
  box-shadow:
    0 20px 44px rgba(0, 0, 0, 0.55),
    0 0 20px rgba(47, 107, 255, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition:
    transform 0.16s var(--press-ease),
    box-shadow 0.16s ease,
    border-color 0.16s ease,
    filter 0.16s ease;
  -webkit-tap-highlight-color: transparent;
  will-change: transform;
}

/* диагональный блик, как на макете */
.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(150, 200, 255, 0.08) 47%, transparent 63%);
}

/* появление по очереди */
.menu .tile:nth-child(1) { animation: riseIn 0.5s 0.12s var(--press-ease) backwards; }
.menu .tile:nth-child(2) { animation: riseIn 0.5s 0.17s var(--press-ease) backwards; }
.menu .tile:nth-child(3) { animation: riseIn 0.5s 0.22s var(--press-ease) backwards; }
.menu .tile:nth-child(4) { animation: riseIn 0.5s 0.27s var(--press-ease) backwards; }
.menu .tile:nth-child(5) { animation: riseIn 0.5s 0.32s var(--press-ease) backwards; }

/* ===== АНИМАЦИЯ НАЖАТИЯ: карточка проваливается + вспышка свечения ===== */
.tile:hover {
  border-color: rgba(108, 165, 255, 0.62);
  box-shadow:
    0 24px 50px rgba(0, 0, 0, 0.58),
    0 0 34px rgba(47, 107, 255, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.09);
}

.tile:active {
  transform: translateY(2px) scale(0.978);
  filter: brightness(1.16) saturate(1.06);
  border-color: rgba(140, 190, 255, 0.95);
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.55),
    0 0 40px rgba(64, 124, 255, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.tile-icon {
  position: relative;
  z-index: 1;
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at 33% 27%, rgba(126, 191, 255, 0.20), rgba(24, 70, 180, 0.16) 45%, rgba(4, 11, 32, 0.60) 88%);
  border: 1.5px solid rgba(125, 180, 255, 0.88);
  box-shadow:
    0 0 24px rgba(47, 107, 255, 0.50),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.tile-icon svg {
  width: 27px;
  height: 27px;
  fill: none;
  stroke: #8cc6ff;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 6px rgba(90, 160, 255, 0.65));
}

.tile-text {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.tile-text b {
  font-size: clamp(17.5px, 4.8vw, 20px);
  font-weight: 800;
  letter-spacing: -0.2px;
  color: #eef4ff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

.tile-text small {
  font-size: clamp(13px, 3.6vw, 14.5px);
  color: #9db7ea;
}

.tile-chevron {
  position: relative;
  z-index: 1;
  margin-left: auto;
  padding-left: 10px;
  font-size: 36px;
  font-weight: 200;
  line-height: 0.8;
  color: #6fa8ff;
  text-shadow: 0 0 12px rgba(77, 151, 255, 0.55);
  transition: transform 0.16s var(--press-ease), color 0.16s ease;
}

.tile:active .tile-chevron {
  transform: translateX(4px);
  color: #b9d8ff;
}

/* Все пять карточек меню — одного цвета (по требованию заказчика):
   класс .featured намеренно без особого оформления */

/* широкая кнопка протокола внутри разделов (создаётся app.js) */
.tile.wide {
  justify-content: center;
  min-height: 66px;
  text-align: center;
  font-weight: 800;
  font-size: 17px;
}

/* ---------- Экран раздела ---------- */

.section-card {
  min-height: 0;
  animation: riseIn 0.35s var(--press-ease) backwards;
}

body:not(.screen-mode):not(.admin-mode) .section-card {
  display: none;
}

body.screen-mode .section-card,
body.admin-mode .section-card {
  display: block;
  min-height: calc(100vh - 40px);
  margin-bottom: 0;
}

body.screen-mode .brand-header,
body.screen-mode .hero-card,
body.screen-mode .menu,
body.screen-mode .brand-footer,
body.screen-mode .bg-decor,
body.admin-mode .brand-header,
body.admin-mode .hero-card,
body.admin-mode .menu,
body.admin-mode .brand-footer,
body.admin-mode .bg-decor {
  display: none;
}

body.screen-mode .app,
body.admin-mode .app {
  padding-top: 12px;
}

body.screen-mode,
body.admin-mode {
  background:
    radial-gradient(760px 520px at 110% -8%, rgba(38, 102, 255, 0.16), transparent 66%),
    linear-gradient(180deg, #070e22, #04060f);
  background-attachment: fixed;
}

.back-button {
  width: auto;
  margin-bottom: 14px;
}

/* ---------- Футер ---------- */

.brand-footer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  max-width: 560px;
  margin: 26px auto 18px;
  color: #7289b6;
  font-size: 12px;
  letter-spacing: 0.5px;
}

.footer-shield {
  opacity: 0.9;
  filter: drop-shadow(0 0 6px rgba(77, 151, 255, 0.4));
}

.footer-sep {
  width: 1px;
  height: 14px;
  background: linear-gradient(180deg, transparent, rgba(120, 170, 255, 0.65), transparent);
}

/* линии слева и справа от подписи — как на макете */
.brand-footer::before,
.brand-footer::after {
  content: "";
  flex: 0 0 clamp(18px, 8vw, 48px);
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(120, 170, 255, 0.55));
}

.brand-footer::after {
  background: linear-gradient(90deg, rgba(120, 170, 255, 0.55), transparent);
}

/* ---------- Контент разделов (компоненты app.js) ---------- */

.muted {
  color: var(--nv-muted);
  margin-top: 6px;
}

.key-card {
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0) 44%),
    linear-gradient(160deg, rgba(11, 23, 56, 0.94), rgba(6, 13, 32, 0.96));
}

.key-card b {
  display: block;
  margin-bottom: 8px;
  font-size: 17px;
}

.actions-row {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.small-button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 15px;
  padding: 12px 17px;
  background: linear-gradient(135deg, #3b78ff, #1e4fd8);
  color: #ffffff;
  font: inherit;
  font-size: 14.5px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(47, 107, 255, 0.34);
  transition:
    transform 0.15s var(--press-ease),
    box-shadow 0.15s ease,
    filter 0.15s ease,
    border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.small-button:hover {
  filter: brightness(1.08);
}

/* та же «проваливающаяся» анимация нажатия */
.small-button:active {
  transform: translateY(2px) scale(0.972);
  filter: brightness(1.18);
  box-shadow: 0 4px 12px rgba(47, 107, 255, 0.40), 0 0 26px rgba(64, 124, 255, 0.45);
}

.small-button.secondary {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--nv-line);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
  color: var(--nv-text);
}

.small-button.secondary:active {
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45), 0 0 22px rgba(64, 124, 255, 0.35);
}

.small-button.danger {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  box-shadow: 0 12px 26px rgba(239, 68, 68, 0.28);
}

.small-button.danger-outline {
  background: rgba(127, 29, 29, 0.55);
  border: 1px solid rgba(239, 68, 68, 0.45);
  box-shadow: none;
}

.small-button:disabled {
  background: #1b2440;
  border-color: transparent;
  color: var(--nv-muted);
  box-shadow: none;
  cursor: not-allowed;
}

.label {
  display: block;
  margin: 12px 0 6px;
  color: #cbd5e1;
  font-weight: 800;
}

.input {
  width: 100%;
  border: 1px solid var(--nv-line);
  border-radius: 15px;
  padding: 13px;
  background: rgba(3, 8, 24, 0.92);
  color: var(--nv-text);
  font: inherit;
  font-size: 16px;
  outline: none;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.35);
}

.input:focus {
  border-color: var(--nv-accent-2);
  box-shadow:
    inset 0 2px 8px rgba(0, 0, 0, 0.35),
    0 0 0 3px rgba(47, 107, 255, 0.28),
    0 0 20px rgba(47, 107, 255, 0.18);
}

.vpn-link,
.config-box,
.traffic-box {
  white-space: pre-wrap;
  word-break: break-all;
  background: rgba(3, 8, 24, 0.92);
  border: 1px solid var(--nv-line);
  border-radius: 16px;
  padding: 12px;
  margin: 10px 0;
  color: #bfd7ff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.35);
}

.traffic-box {
  color: #cbd5e1;
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
}

.profile-card h3 {
  margin: 0 0 4px;
}

.avatar {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--nv-accent), #7c5cff);
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 900;
  color: #ffffff;
  box-shadow: 0 0 24px var(--nv-glow), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}

.info-item {
  background: rgba(3, 8, 24, 0.92);
  border: 1px solid var(--nv-line);
  border-radius: 16px;
  padding: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.info-item span {
  display: block;
  color: var(--nv-muted);
  font-size: 13px;
  margin-bottom: 4px;
}

.info-item b {
  color: var(--nv-text);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.badge.active,
.badge.approved {
  background: rgba(34, 197, 94, 0.16);
  color: #86efac;
}

.badge.revoked,
.badge.inactive {
  background: rgba(245, 158, 11, 0.16);
  color: #fcd34d;
}

.badge.failed,
.badge.blocked,
.badge.deleted {
  background: rgba(239, 68, 68, 0.16);
  color: #fca5a5;
}

.badge.pending {
  background: rgba(59, 130, 246, 0.16);
  color: #93c5fd;
}

.instruction-card li {
  margin: 7px 0;
}

.instruction-card code {
  background: rgba(3, 8, 24, 0.92);
  border: 1px solid var(--nv-line);
  border-radius: 7px;
  padding: 2px 5px;
  color: #bfd7ff;
}

.audit-details summary {
  cursor: pointer;
  color: var(--nv-muted);
  margin-top: 8px;
  font-weight: 700;
}

.qr-image {
  display: block;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  background: #ffffff;
  padding: 12px;
  border-radius: 16px;
  box-shadow: 0 0 34px rgba(47, 107, 255, 0.30);
}

.qr-image svg {
  width: 100%;
  height: auto;
}

/* ---------- Ключевыеframes ---------- */

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Адаптив ---------- */

@media (max-width: 520px) {
  .app {
    padding: 12px clamp(14px, 6.2vw, 26px) 6px;
  }

  .tile {
    min-height: 80px;
    padding: 14px 15px;
    gap: 13px;
  }

  .tile-icon {
    flex-basis: 46px;
    width: 46px;
    height: 46px;
  }

  .actions-row .small-button {
    flex: 1 1 auto;
  }
}

@media (max-width: 400px) {
  .brand-mark {
    width: 56px;
    height: 56px;
    flex-basis: 56px;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .actions-row .small-button {
    flex: 1 1 100%;
    width: 100%;
  }
}

/* ---------- Уважение к настройке «меньше движения» ---------- */

@media (prefers-reduced-motion: reduce) {
  .brand-header,
  .hero-card,
  .menu .tile,
  .section-card,
  .tile.featured {
    animation: none;
  }

  .tile,
  .small-button,
  .tile-chevron {
    transition: none;
  }
}
