/* ===== Cosmic Dashboard — космо-эффекты только для вкладки "Дашборд" ===== */

/* --- Туманности и комета (живут внутри #dashboard, скрываются вместе с вкладкой) --- */
#dashboard .cosmic-fx { position: fixed; inset: 0; pointer-events: none; z-index: -1; overflow: hidden; }
#dashboard .cosmic-fx .nebula { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .32; }
#dashboard .cosmic-fx .nebula.n1 { width: 520px; height: 520px; left: -140px; top: -120px;
  background: radial-gradient(circle, rgba(225,29,72,.32), transparent 65%);
  animation: cosmicFloatA 26s ease-in-out infinite; }
#dashboard .cosmic-fx .nebula.n2 { width: 460px; height: 460px; right: -120px; top: 220px;
  background: radial-gradient(circle, rgba(59,130,246,.26), transparent 65%);
  animation: cosmicFloatB 32s ease-in-out infinite; }
#dashboard .cosmic-fx .nebula.n3 { width: 380px; height: 380px; left: 38%; bottom: -160px;
  background: radial-gradient(circle, rgba(139,92,246,.22), transparent 65%);
  animation: cosmicFloatA 22s ease-in-out infinite reverse; }
@keyframes cosmicFloatA { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(30px,20px) scale(1.06); } }
@keyframes cosmicFloatB { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-24px,26px) scale(1.04); } }

#dashboard .cosmic-fx .comet { position: absolute; top: 8%; left: -6%; width: 2px; height: 2px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 6px 1px rgba(255,255,255,.9); opacity: 0;
  animation: cosmicStreak 14s cubic-bezier(.3,.6,.2,1) infinite; animation-delay: 3s; }
#dashboard .cosmic-fx .comet::before { content: ""; position: absolute; top: 0; left: 0; width: 110px; height: 1px;
  transform-origin: left center; transform: translateY(-.5px) rotate(180deg);
  background: linear-gradient(90deg, rgba(255,255,255,.85), transparent); }
@keyframes cosmicStreak {
  0% { opacity: 0; transform: translate(0,0); }
  1.5% { opacity: 1; }
  11% { opacity: 0; transform: translate(46vw,22vh); }
  100% { opacity: 0; transform: translate(46vw,22vh); }
}

/* --- Появление карточек при открытии вкладки --- */
#dashboard.active .stat-card {
  animation: cosmicRise .55s cubic-bezier(.2,.8,.2,1) backwards;
}
#dashboard.active .stats-grid .stat-card:nth-child(1) { animation-delay: .05s; }
#dashboard.active .stats-grid .stat-card:nth-child(2) { animation-delay: .12s; }
#dashboard.active .stats-grid .stat-card:nth-child(3) { animation-delay: .19s; }
#dashboard.active .stats-grid .stat-card:nth-child(4) { animation-delay: .26s; }
#dashboard.active > .card,
#dashboard.active > div > .card { animation: cosmicRise .55s cubic-bezier(.2,.8,.2,1) .3s backwards; }
@keyframes cosmicRise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* --- Свечение KPI-карточек при наведении --- */
#dashboard .stat-card { transition: transform .25s, box-shadow .25s; }
#dashboard .stat-card:hover { transform: translateY(-2px); }
#dashboard .stat-card::after { content: ""; position: absolute; inset: 0; opacity: 0; transition: opacity .35s; pointer-events: none;
  background: radial-gradient(220px 140px at 85% -10%, var(--cosmic-glow, rgba(225,29,72,.22)), transparent 70%); }
#dashboard .stat-card:hover::after { opacity: 1; }
#dashboard .stat-card.income { --cosmic-glow: rgba(225,29,72,.26); }
#dashboard .stat-card.margin { --cosmic-glow: rgba(16,185,129,.26); }
#dashboard .stat-card.expenses { --cosmic-glow: rgba(245,158,11,.26); }
#dashboard .stat-card.forecast { --cosmic-glow: rgba(139,92,246,.26); }

/* --- Ракета на счётчиках --- */
#dashboard .rocket-wrap { position: absolute; width: 20px; height: 34px; opacity: 0; z-index: 2; pointer-events: none; }
#dashboard .rocket-boost { width: 100%; height: 100%; transition: transform .25s cubic-bezier(.2,.8,.2,1); }
#dashboard .rocket { width: 100%; height: 100%; display: block; overflow: visible; }
#dashboard .rocket .fin { fill: var(--cosmic-rk, var(--accent)); }
#dashboard .rocket .body { fill: #e9e9f2; }
#dashboard .rocket .porthole { fill: #0d0d14; stroke: var(--cosmic-rk, var(--accent)); stroke-width: 1.2; }
#dashboard .rocket .nozzle { fill: #3a3a46; }
#dashboard .rocket .flame { transform-origin: 12px 28.5px; opacity: 0; }
#dashboard .rocket-wrap.firing .flame { opacity: 1; animation: cosmicFlick .14s ease-in-out infinite; }
#dashboard .rocket-wrap.docked .flame { opacity: .25; animation: cosmicFlick .6s ease-in-out infinite; }
@keyframes cosmicFlick { 0%,100% { transform: scaleY(1); } 50% { transform: scaleY(1.45); } }
#dashboard .rocket-trail { position: absolute; left: 50%; top: 96%; width: 2px; margin-left: -1px; height: 0; border-radius: 2px;
  background: linear-gradient(180deg, rgba(251,191,36,.85), rgba(244,63,94,.35) 55%, transparent); filter: blur(.4px); }
#dashboard .stat-card.income { --cosmic-rk: var(--accent); }
#dashboard .stat-card.margin { --cosmic-rk: var(--good); }
#dashboard .stat-card.expenses { --cosmic-rk: var(--warn); }
#dashboard .stat-card.forecast { --cosmic-rk: #8b5cf6; }
/* Форсаж при наведении */
#dashboard .stat-card:hover .rocket-wrap.docked .rocket-boost { transform: translateY(-4px); }
#dashboard .stat-card:hover .rocket-wrap.docked .flame { opacity: 1; animation-duration: .1s; }

@media (prefers-reduced-motion: reduce) {
  #dashboard .cosmic-fx .nebula, #dashboard .cosmic-fx .comet { animation: none !important; }
  #dashboard.active .stat-card, #dashboard.active > .card, #dashboard.active > div > .card { animation: none !important; }
  #dashboard .rocket .flame { animation: none !important; opacity: .3 !important; }
  #dashboard .rocket-boost { transition: none; }
  #dashboard .stat-card { transition: none; }
}

/* ===== v2: карточки графиков, "Повторные покупки", "Ср. цена токена" ===== */

/* --- Карточки графиков --- */
#dashboard .card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%) !important;
  border: 1px solid var(--border) !important;
  border-radius: 16px !important;
  transition: border-color .25s;
}
#dashboard .card:hover { border-color: var(--border-2) !important; }
#dashboard .card h3 {
  font-size: 14.5px !important; font-weight: 600 !important;
  border-bottom: 0 !important; text-decoration: none !important;
  color: var(--text) !important;
}
#dashboard .card h3::after { display: none !important; }

/* --- Кнопки "Обновить" --- */
#dashboard .cosmic-refresh {
  background: transparent !important; border: 1px solid var(--border) !important;
  color: var(--text-3) !important; border-radius: 8px !important;
  width: 28px; height: 28px; padding: 0 !important;
  display: inline-grid !important; place-items: center; cursor: pointer;
  transition: color .15s, border-color .15s;
}
#dashboard .cosmic-refresh:hover { color: var(--text) !important; border-color: var(--border-2) !important; }
#dashboard .cosmic-refresh svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; }

/* --- SVG-иконки вместо emoji в заголовках --- */
#dashboard .cosmic-ico { display: inline-flex; vertical-align: -2px; margin-right: 7px; opacity: .9; }
#dashboard .cosmic-ico svg { width: 14px; height: 14px; stroke: currentColor; fill: none;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* --- Повторные покупки --- */
#dashboard #recurringPurchasesCard > div {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%) !important;
  border: 1px solid var(--border) !important;
  border-radius: 16px !important;
  padding: 16px 20px !important;
}
#dashboard #recurringPurchasesCard > div > div:last-child > div {
  background: rgba(255,255,255,.02);
  border-radius: 10px !important;
  transition: background .2s, transform .2s !important;
}
#dashboard #recurringPurchasesCard > div > div:last-child > div:hover { transform: translateY(-1px); }

/* --- Ср. цена токена --- */
#dashboard #dashRefTokenBlock > div > div {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%) !important;
  border-radius: 14px !important;
  position: relative; overflow: hidden;
  transition: transform .25s, border-color .25s;
}
#dashboard #dashRefTokenBlock > div > div:hover { transform: translateY(-2px); }
#dashboard #dashRefTokenBlock > div > div::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .55;
  background: radial-gradient(160px 90px at 85% -20%, var(--cosmic-token-glow, transparent), transparent 70%);
}
#dashboard #dashRefTokenBlock > div > div:nth-child(1) { --cosmic-token-glow: rgba(167,139,250,.25); }
#dashboard #dashRefTokenBlock > div > div:nth-child(2) { --cosmic-token-glow: rgba(99,102,241,.22); }
#dashboard #dashRefTokenBlock > div > div:nth-child(3) { --cosmic-token-glow: rgba(16,185,129,.22); }

@media (prefers-reduced-motion: reduce) {
  #dashboard #dashRefTokenBlock > div > div,
  #dashboard #recurringPurchasesCard > div > div:last-child > div { transition: none !important; }
}
