/* Partner cabinet — layout & premium dashboard composition */

.ref-cabinet-html { color-scheme: dark; }

.ref-cabinet-body {
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  background-color: #040612;
}

.ref-cabinet-body svg:not(.ref-qr-wrap img) {
  width: 20px;
  height: 20px;
  max-width: 24px;
  max-height: 24px;
  flex-shrink: 0;
}

.ref-cabinet-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

/* Тематический базовый фон: партнёрская сеть + финтех-аналитика */
.ref-cabinet-bg-base {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 90% 55% at 50% -8%, rgba(103, 228, 255, 0.14), transparent 58%),
    radial-gradient(ellipse 50% 40% at 92% 18%, rgba(124, 58, 237, 0.18), transparent 52%),
    radial-gradient(ellipse 45% 38% at 4% 42%, rgba(37, 99, 235, 0.14), transparent 50%),
    radial-gradient(ellipse 70% 45% at 50% 100%, rgba(52, 211, 153, 0.06), transparent 55%),
    linear-gradient(180deg, #03050f 0%, #050815 38%, #06101f 72%, #040812 100%);
}

.ref-cabinet-bg-rings {
  position: absolute;
  inset: -20% -10%;
  background:
    radial-gradient(circle at 78% 22%, transparent 0 18%, rgba(103, 228, 255, 0.04) 18.2%, transparent 19%),
    radial-gradient(circle at 78% 22%, transparent 0 28%, rgba(141, 99, 255, 0.035) 28.2%, transparent 29%),
    radial-gradient(circle at 78% 22%, transparent 0 40%, rgba(79, 124, 255, 0.03) 40.2%, transparent 41%),
    radial-gradient(circle at 18% 68%, transparent 0 14%, rgba(52, 211, 153, 0.04) 14.2%, transparent 15%),
    radial-gradient(circle at 18% 68%, transparent 0 26%, rgba(103, 228, 255, 0.03) 26.2%, transparent 27%);
  animation: ref-rings-pulse 14s ease-in-out infinite alternate;
}

@keyframes ref-rings-pulse {
  from { opacity: 0.65; transform: scale(1); }
  to { opacity: 1; transform: scale(1.03); }
}

.ref-cabinet-bg-network {
  position: absolute;
  inset: 0;
  opacity: 0.55;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='800' height='600' viewBox='0 0 800 600'%3E%3Cg fill='none' stroke='%2367e4ff' stroke-opacity='0.12' stroke-width='1'%3E%3Cpath d='M80 120 L220 80 L380 140 L520 60 L680 100'/%3E%3Cpath d='M60 280 L200 240 L340 300 L500 220 L720 260'/%3E%3Cpath d='M100 420 L260 380 L420 440 L580 360 L740 400'/%3E%3Cpath d='M220 80 L200 240 L260 380'/%3E%3Cpath d='M380 140 L340 300 L420 440'/%3E%3Cpath d='M520 60 L500 220 L580 360'/%3E%3Cpath d='M680 100 L720 260 L740 400'/%3E%3C/g%3E%3Cg fill='%238d63ff' fill-opacity='0.35'%3E%3Ccircle cx='220' cy='80' r='5'/%3E%3Ccircle cx='380' cy='140' r='6'/%3E%3Ccircle cx='520' cy='60' r='4'/%3E%3Ccircle cx='200' cy='240' r='5'/%3E%3Ccircle cx='340' cy='300' r='7'/%3E%3Ccircle cx='500' cy='220' r='5'/%3E%3Ccircle cx='260' cy='380' r='6'/%3E%3Ccircle cx='580' cy='360' r='5'/%3E%3Ccircle cx='720' cy='260' r='4'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
  background-position: center top;
  mask-image: linear-gradient(180deg, #000 0%, #000 45%, transparent 88%);
}

.ref-cabinet-bg-chart-wave {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 42vh;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 200' preserveAspectRatio='none'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0%25' stop-color='%2367e4ff' stop-opacity='0.22'/%3E%3Cstop offset='100%25' stop-color='%2367e4ff' stop-opacity='0'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath fill='url(%23g)' d='M0 160 Q150 120 300 140 T600 100 T900 130 T1200 90 L1200 200 L0 200 Z'/%3E%3Cpath fill='none' stroke='%238d63ff' stroke-opacity='0.35' stroke-width='2' d='M0 150 Q200 90 400 120 T800 70 T1200 100'/%3E%3C/svg%3E");
  background-size: 100% 100%;
  animation: ref-wave-drift 18s ease-in-out infinite alternate;
}

@keyframes ref-wave-drift {
  from { transform: translateX(-1%) scaleY(1); }
  to { transform: translateX(1.5%) scaleY(1.04); }
}

.ref-cabinet-bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(103, 228, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(103, 228, 255, 0.045) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 85% 60% at 50% 0%, #000 20%, transparent 72%);
}

.ref-cabinet-bg-particles {
  position: absolute;
  inset: 0;
}

.ref-cabinet-bg-particles span {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(103, 228, 255, 0.55);
  box-shadow: 0 0 12px rgba(103, 228, 255, 0.45);
  animation: ref-particle-float 12s ease-in-out infinite;
}

.ref-cabinet-bg-particles span:nth-child(1) { left: 8%; top: 18%; animation-delay: 0s; }
.ref-cabinet-bg-particles span:nth-child(2) { left: 22%; top: 42%; animation-delay: -1.2s; opacity: 0.7; }
.ref-cabinet-bg-particles span:nth-child(3) { left: 35%; top: 12%; animation-delay: -2.4s; }
.ref-cabinet-bg-particles span:nth-child(4) { left: 48%; top: 58%; animation-delay: -3.1s; width: 3px; height: 3px; }
.ref-cabinet-bg-particles span:nth-child(5) { left: 61%; top: 28%; animation-delay: -4s; }
.ref-cabinet-bg-particles span:nth-child(6) { left: 74%; top: 48%; animation-delay: -5.2s; background: rgba(141, 99, 255, 0.6); }
.ref-cabinet-bg-particles span:nth-child(7) { left: 86%; top: 16%; animation-delay: -6s; }
.ref-cabinet-bg-particles span:nth-child(8) { left: 12%; top: 72%; animation-delay: -7.1s; width: 3px; height: 3px; }
.ref-cabinet-bg-particles span:nth-child(9) { left: 55%; top: 78%; animation-delay: -8s; opacity: 0.65; }
.ref-cabinet-bg-particles span:nth-child(10) { left: 92%; top: 62%; animation-delay: -9.3s; }

@keyframes ref-particle-float {
  0%, 100% { transform: translate(0, 0); opacity: 0.45; }
  50% { transform: translate(8px, -14px); opacity: 0.95; }
}

.ref-cabinet-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(88px);
  opacity: 0.85;
}

.ref-cabinet-blob-1 {
  width: 420px;
  height: 420px;
  top: -120px;
  left: 8%;
  background: rgba(124, 58, 237, 0.22);
}

.ref-cabinet-blob-2 {
  width: 340px;
  height: 340px;
  right: 6%;
  top: 28%;
  background: rgba(37, 99, 235, 0.16);
}

.ref-cabinet-blob-3 {
  width: 280px;
  height: 280px;
  left: 42%;
  bottom: -80px;
  background: rgba(103, 228, 255, 0.12);
}

.ref-cabinet-blob-4 {
  width: 220px;
  height: 220px;
  right: 28%;
  bottom: 12%;
  background: rgba(52, 211, 153, 0.1);
  filter: blur(72px);
}

.ref-portal-main.ref-cabinet-main {
  width: min(1560px, calc(100vw - 32px));
  max-width: 100%;
  padding-top: 8px;
}

.ref-cabinet-page {
  display: flex;
  flex-direction: column;
  gap: 22px;
  width: 100%;
}

/* Hero — full-width 2-column */
.ref-hub-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: 24px;
  align-items: stretch;
  width: 100%;
  padding: 28px 30px;
  border-radius: 28px;
  background:
    linear-gradient(145deg, rgba(14, 24, 48, 0.92), rgba(8, 14, 28, 0.78)),
    radial-gradient(circle at 100% 0%, rgba(103, 228, 255, 0.14), transparent 42%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='200'%3E%3Cpath fill='none' stroke='%2367e4ff' stroke-opacity='0.08' d='M0 120 Q100 40 200 100 T400 80'/%3E%3C/svg%3E") right -20px top 40% / 55% auto no-repeat;
  border: 1px solid rgba(132, 188, 255, 0.16);
  box-shadow:
    0 28px 80px rgba(2, 8, 22, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  position: relative;
  overflow: hidden;
}

.ref-hub-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 40%, rgba(103, 228, 255, 0.06) 50%, transparent 60%);
  animation: ref-hero-shine 8s ease-in-out infinite;
  pointer-events: none;
}

@keyframes ref-hero-shine {
  0%, 100% { opacity: 0.4; transform: translateX(-30%); }
  50% { opacity: 0.9; transform: translateX(30%); }
}

.ref-hero-title {
  font-size: clamp(1.85rem, 3.2vw, 2.65rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin: 8px 0 10px;
}

.ref-hero-subtitle {
  font-size: 1.02rem;
  line-height: 1.65;
  color: var(--ref-muted);
  max-width: 52ch;
}

.ref-hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-start;
}

.ref-tier-badge,
.ref-quality-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  border: 1px solid rgba(132, 188, 255, 0.2);
  background: rgba(8, 15, 29, 0.55);
  box-shadow: 0 0 20px rgba(79, 124, 255, 0.12);
}

/* Stat pills — streak / quality / level (not plain text) */
.ref-stat-pills {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0 20px;
}

.ref-stat-pill {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(8, 15, 29, 0.62);
  border: 1px solid rgba(131, 188, 255, 0.12);
  display: grid;
  gap: 8px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.ref-stat-pill:hover {
  transform: translateY(-2px);
  border-color: rgba(150, 203, 255, 0.28);
  box-shadow: 0 12px 32px rgba(79, 124, 255, 0.14);
}

.ref-stat-pill-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ref-stat-pill-icon {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.ref-stat-pill.is-streak .ref-stat-pill-icon {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.35), rgba(251, 113, 133, 0.2));
  box-shadow: 0 0 18px rgba(245, 158, 11, 0.25);
}

.ref-stat-pill.is-quality .ref-stat-pill-icon {
  background: linear-gradient(135deg, rgba(103, 228, 255, 0.35), rgba(79, 124, 255, 0.22));
  box-shadow: 0 0 18px rgba(103, 228, 255, 0.22);
}

.ref-stat-pill.is-level .ref-stat-pill-icon {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.35), rgba(79, 124, 255, 0.22));
  box-shadow: 0 0 18px rgba(124, 58, 237, 0.22);
}

.ref-stat-pill-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ref-muted);
  font-weight: 700;
}

.ref-stat-pill-value {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.ref-stat-pill .ref-progress-bar {
  height: 6px;
  margin-top: 4px;
}

.ref-gamification-bar { display: none; }

/* Hero visual panel */
.ref-hub-visual {
  min-height: 360px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Insight chips — fixed dock (no overlap), optional drag reorder */
.ref-insights-dock {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  position: relative;
  z-index: 3;
  margin-top: auto;
  padding-top: 4px;
}

.ref-insights-dock::before {
  content: "Перетащите для смены порядка";
  position: absolute;
  top: -18px;
  right: 0;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: var(--ref-muted);
  opacity: 0.75;
}

.ref-insight-chip {
  padding: 14px 14px 12px;
  border-radius: 18px;
  border: 1px solid rgba(132, 188, 255, 0.16);
  background:
    linear-gradient(155deg, rgba(12, 20, 38, 0.9), rgba(8, 14, 28, 0.82)),
    radial-gradient(circle at 0% 0%, rgba(103, 228, 255, 0.1), transparent 50%);
  box-shadow: 0 12px 28px rgba(3, 10, 24, 0.28);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  cursor: grab;
  user-select: none;
  touch-action: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.ref-insight-chip:hover {
  transform: translateY(-2px);
  border-color: rgba(150, 203, 255, 0.28);
  box-shadow: 0 16px 34px rgba(79, 124, 255, 0.16);
}

.ref-insight-chip.is-dragging {
  opacity: 0.55;
  cursor: grabbing;
  transform: scale(0.98);
}

.ref-insight-chip.is-drop-target {
  border-color: rgba(103, 228, 255, 0.45);
  box-shadow: 0 0 0 2px rgba(103, 228, 255, 0.2);
}

.ref-insight-chip strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.92rem;
}

.ref-insight-chip small {
  color: var(--ref-muted);
  font-size: 0.8rem;
}

.ref-insight-icon {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  margin-bottom: 10px;
  background: linear-gradient(135deg, rgba(80, 133, 255, 0.28), rgba(156, 87, 255, 0.22));
}

.ref-hub-visual .ref-floating-chip {
  display: none !important;
}

.ref-hub-visual .ref-dashboard-art {
  flex: 1;
  min-height: 0;
}

.ref-dashboard-art {
  height: 100%;
  min-height: 320px;
}

.ref-dashboard-widgets {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  grid-template-rows: auto auto;
  gap: 12px;
}

.ref-dashboard-widget.is-big {
  grid-column: 1 / -1;
}

/* KPI grid — card treatment */
.ref-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
}

.ref-kpi-card {
  position: relative;
  padding: 20px 18px 16px;
  border-radius: 22px;
  background:
    linear-gradient(160deg, rgba(12, 21, 40, 0.9), rgba(8, 14, 28, 0.75)),
    radial-gradient(ellipse 80% 60% at 100% 0%, rgba(103, 228, 255, 0.08), transparent 55%);
  border: 1px solid rgba(131, 188, 255, 0.14);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 18px 48px rgba(2, 8, 22, 0.35);
  overflow: hidden;
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.ref-kpi-card::after {
  content: "";
  position: absolute;
  right: -8px;
  bottom: -12px;
  width: 120px;
  height: 64px;
  opacity: 0.35;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 64'%3E%3Cpath fill='none' stroke='%2367e4ff' stroke-width='2' stroke-opacity='0.5' d='M0 50 L20 38 L40 42 L60 22 L80 28 L100 12 L120 18'/%3E%3C/svg%3E") center / contain no-repeat;
  pointer-events: none;
}

.ref-kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  opacity: 0.9;
  z-index: 1;
}

.ref-kpi-card.is-blue::before { background: linear-gradient(90deg, #67e4ff, #4f7cff); }
.ref-kpi-card.is-violet::before { background: linear-gradient(90deg, #a78bfa, #7c3aed); }
.ref-kpi-card.is-cyan::before { background: linear-gradient(90deg, #22d3ee, #3b82f6); }
.ref-kpi-card.is-green::before { background: linear-gradient(90deg, #34d399, #10b981); }
.ref-kpi-card.is-orange::before { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.ref-kpi-card.is-pink::before { background: linear-gradient(90deg, #f472b6, #ec4899); }
.ref-kpi-card.is-emerald::before { background: linear-gradient(90deg, #6ee7b7, #059669); }
.ref-kpi-card.is-royal::before { background: linear-gradient(90deg, #818cf8, #4f46e5); }
.ref-kpi-card.is-gold::before { background: linear-gradient(90deg, #fcd34d, #f59e0b); }

.ref-kpi-card:hover {
  transform: translateY(-3px);
  border-color: rgba(150, 203, 255, 0.28);
  box-shadow: 0 22px 56px rgba(79, 124, 255, 0.18);
}

.ref-kpi-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.ref-kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  background: rgba(79, 124, 255, 0.18);
  border: 1px solid rgba(131, 188, 255, 0.14);
}

.ref-kpi-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ref-muted);
  margin-bottom: 6px;
}

.ref-kpi-value {
  font-size: clamp(1.5rem, 2.4vw, 2rem);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.ref-kpi-trend {
  font-size: 0.8rem;
  color: #b8c9e8;
  margin-top: 6px;
}

/* Charts — 2×2 grid */
.ref-charts-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
}

.ref-chart-card {
  min-height: 280px;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(165deg, rgba(11, 19, 36, 0.92), rgba(7, 13, 26, 0.8)),
    radial-gradient(ellipse 70% 50% at 0% 100%, rgba(141, 99, 255, 0.08), transparent 60%) !important;
}

.ref-chart-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(103, 228, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(103, 228, 255, 0.03) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent);
  pointer-events: none;
  z-index: 0;
}

.ref-chart-card .ref-card-head,
.ref-chart-card canvas {
  position: relative;
  z-index: 1;
}

.ref-chart-card.ref-chart-live::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    105deg,
    transparent 42%,
    rgba(103, 228, 255, 0.07) 50%,
    transparent 58%
  );
  animation: ref-chart-sweep 4.5s ease-in-out infinite;
}

.ref-chart-card.ref-chart-live canvas {
  animation: ref-chart-fade-in 1.2s ease-out both;
}

@keyframes ref-chart-sweep {
  0%, 100% { transform: translateX(-35%); opacity: 0.35; }
  50% { transform: translateX(35%); opacity: 0.85; }
}

@keyframes ref-chart-fade-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.ref-chart-card .ref-card-head h3 {
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.ref-chart-card canvas {
  width: 100% !important;
  height: 200px !important;
  max-height: 220px;
}

/* Split rows */
.ref-split-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
}

.ref-funnel-layout {
  grid-template-columns: 1.1fr 0.9fr;
}

/* Leaderboard panel */
.ref-leaderboard-panel .ref-card-head h3 {
  font-size: 1.15rem;
}

.ref-leaderboard-list {
  display: grid;
  gap: 10px;
}

.ref-leaderboard-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(8, 15, 29, 0.55);
  border: 1px solid rgba(131, 188, 255, 0.1);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.ref-leaderboard-row:hover {
  transform: translateX(4px);
  border-color: rgba(150, 203, 255, 0.22);
  box-shadow: 0 8px 24px rgba(79, 124, 255, 0.12);
}

.ref-leaderboard-row.is-me {
  border-color: rgba(103, 228, 255, 0.35);
  background: linear-gradient(90deg, rgba(103, 228, 255, 0.1), rgba(8, 15, 29, 0.55));
}

.ref-leaderboard-row.is-top-1 { box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.25); }
.ref-leaderboard-row.is-top-2 { box-shadow: inset 0 0 0 1px rgba(203, 213, 225, 0.2); }
.ref-leaderboard-row.is-top-3 { box-shadow: inset 0 0 0 1px rgba(180, 83, 9, 0.2); }

.ref-lb-rank {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.9rem;
  background: rgba(79, 124, 255, 0.15);
}

.ref-lb-rank.is-gold {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.4), rgba(245, 158, 11, 0.2));
  box-shadow: 0 0 16px rgba(251, 191, 36, 0.3);
}

.ref-lb-rank.is-silver {
  background: linear-gradient(135deg, rgba(203, 213, 225, 0.35), rgba(148, 163, 184, 0.15));
}

.ref-lb-rank.is-bronze {
  background: linear-gradient(135deg, rgba(180, 83, 9, 0.35), rgba(245, 158, 11, 0.12));
}

.ref-lb-avatar {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.85rem;
  background: linear-gradient(135deg, rgba(76, 124, 255, 0.75), rgba(148, 93, 255, 0.65));
  flex-shrink: 0;
}

.ref-lb-copy strong {
  display: block;
  font-size: 0.95rem;
}

.ref-lb-copy span {
  font-size: 0.8rem;
  color: var(--ref-muted);
}

.ref-lb-earnings {
  text-align: right;
  font-weight: 800;
  font-size: 0.95rem;
  color: #dceaff;
}

.ref-lb-earnings small {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ref-muted);
  margin-top: 2px;
}

.ref-lb-progress {
  grid-column: 1 / -1;
  height: 4px;
  border-radius: 999px;
  background: rgba(131, 188, 255, 0.1);
  overflow: hidden;
}

.ref-lb-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #67e4ff, #8d63ff);
}

/* Referral tools strip */
.ref-tools-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.6fr);
  gap: 16px;
  width: 100%;
}

.ref-link-card .ref-link-box {
  font-size: 0.92rem;
  word-break: break-all;
}

/* Gamification side — widget cards */
.ref-score-stack {
  display: grid;
  gap: 12px;
}

.ref-score-box {
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(8, 15, 29, 0.55);
  border: 1px solid rgba(131, 188, 255, 0.1);
}

.ref-score-box > span:first-child {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ref-muted);
  font-weight: 700;
}

.ref-score-box strong {
  display: block;
  font-size: 1.4rem;
  font-weight: 800;
  margin-top: 6px;
}

/* Reveal animation */
.ref-reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}

.ref-reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* Mobile nav */
.ref-nav-toggle {
  display: none;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(131, 188, 255, 0.2);
  background: rgba(8, 15, 29, 0.6);
  color: var(--ref-text);
  font-weight: 700;
  cursor: pointer;
}

.ref-portal-nav.is-menu-open .ref-portal-links {
  display: flex;
}

@media (max-width: 1240px) {
  .ref-hub-hero {
    grid-template-columns: 1fr;
  }

  .ref-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ref-charts-row,
  .ref-split-row,
  .ref-tools-row {
    grid-template-columns: 1fr;
  }

  .ref-stat-pills {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .ref-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .ref-portal-nav .ref-portal-links {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    padding-top: 8px;
  }

  .ref-portal-nav.is-menu-open .ref-portal-links {
    display: flex;
  }

  .ref-portal-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .ref-hub-hero {
    padding: 22px 18px;
  }

  .ref-kpi-grid {
    grid-template-columns: 1fr;
  }

  .ref-insights-dock {
    grid-template-columns: 1fr;
  }

  .ref-insights-dock::before {
    display: none;
  }
}

/* Subpages — unified partner module layout */
.ref-subpage {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}

.ref-page-hero {
  padding: 24px 26px;
  border-radius: 24px;
  margin-bottom: 4px;
  background:
    linear-gradient(135deg, rgba(14, 24, 48, 0.9), rgba(8, 14, 28, 0.82)),
    radial-gradient(circle at 90% 20%, rgba(124, 58, 237, 0.12), transparent 45%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='120'%3E%3Ccircle cx='30' cy='30' r='4' fill='%2367e4ff' fill-opacity='0.25'/%3E%3Ccircle cx='90' cy='50' r='5' fill='%238d63ff' fill-opacity='0.3'/%3E%3Ccircle cx='160' cy='35' r='4' fill='%2367e4ff' fill-opacity='0.2'/%3E%3Cpath stroke='%2367e4ff' stroke-opacity='0.15' d='M30 30 L90 50 L160 35'/%3E%3C/svg%3E") right 24px center / 180px no-repeat !important;
}

.ref-page-hero .ref-hero-title {
  margin: 8px 0 0;
  font-size: clamp(1.6rem, 2.8vw, 2.2rem);
}

.ref-page-subtitle {
  margin: 10px 0 0;
  max-width: 62ch;
}

.ref-subpage .ref-card,
.ref-subpage .ref-table-wrap {
  border-radius: 22px;
}

.ref-subpage .ref-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.ref-subpage .ref-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.ref-subpage .ref-metric {
  padding: 18px 20px;
  border-radius: 20px;
  background: linear-gradient(160deg, rgba(12, 21, 40, 0.88), rgba(8, 14, 28, 0.72));
  border: 1px solid rgba(131, 188, 255, 0.14);
}

.ref-subpage .ref-metric span {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ref-muted);
  margin-bottom: 8px;
}

.ref-subpage .ref-metric strong {
  font-size: 1.5rem;
  font-weight: 800;
}

/* Текстуры в блоках — лёгкий тематический фон */
.ref-cabinet-page .glass-shell,
.ref-cabinet-page .ref-card.glass-shell {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(165deg, rgba(12, 20, 38, 0.88), rgba(7, 13, 26, 0.78)),
    radial-gradient(ellipse 55% 45% at 100% 0%, rgba(103, 228, 255, 0.07), transparent 58%) !important;
}

.ref-cabinet-page .glass-shell::after,
.ref-cabinet-page .ref-card.glass-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Ccircle cx='30' cy='30' r='1.2' fill='%2367e4ff' fill-opacity='0.12'/%3E%3C/svg%3E") 0 0 / 28px 28px;
  opacity: 0.6;
  pointer-events: none;
  mask-image: linear-gradient(135deg, transparent 50%, #000 100%);
}

.ref-cabinet-page .glass-shell > * {
  position: relative;
  z-index: 1;
}

.ref-portal-nav.glass-shell {
  background:
    linear-gradient(180deg, rgba(12, 20, 39, 0.9), rgba(7, 13, 24, 0.82)),
    radial-gradient(circle at 0% 50%, rgba(124, 58, 237, 0.1), transparent 42%) !important;
}

.ref-highlight-card.is-earnings {
  background:
    linear-gradient(145deg, rgba(14, 28, 52, 0.85), rgba(8, 16, 32, 0.75)),
    radial-gradient(circle at 100% 0%, rgba(52, 211, 153, 0.12), transparent 50%) !important;
}

.ref-highlight-card.is-growth {
  background:
    linear-gradient(145deg, rgba(18, 24, 48, 0.85), rgba(8, 14, 30, 0.75)),
    radial-gradient(circle at 0% 100%, rgba(141, 99, 255, 0.14), transparent 48%) !important;
}

.ref-stat-pill.is-streak {
  background:
    linear-gradient(155deg, rgba(14, 22, 40, 0.88), rgba(8, 14, 28, 0.8)),
    radial-gradient(circle at 100% 0%, rgba(245, 158, 11, 0.12), transparent 55%);
}

.ref-stat-pill.is-quality {
  background:
    linear-gradient(155deg, rgba(14, 22, 40, 0.88), rgba(8, 14, 28, 0.8)),
    radial-gradient(circle at 0% 0%, rgba(103, 228, 255, 0.12), transparent 55%);
}

.ref-stat-pill.is-level {
  background:
    linear-gradient(155deg, rgba(14, 22, 40, 0.88), rgba(8, 14, 28, 0.8)),
    radial-gradient(circle at 50% 100%, rgba(124, 58, 237, 0.14), transparent 55%);
}

.ref-dashboard-art.glass-shell {
  background:
    linear-gradient(160deg, rgba(10, 18, 36, 0.92), rgba(6, 12, 24, 0.85)),
    radial-gradient(ellipse 90% 70% at 80% 10%, rgba(103, 228, 255, 0.1), transparent 50%) !important;
}

.ref-dashboard-widget {
  background:
    linear-gradient(160deg, rgba(8, 15, 29, 0.75), rgba(5, 10, 20, 0.65)),
    radial-gradient(circle at 50% 0%, rgba(79, 124, 255, 0.08), transparent 70%);
}

.ref-leaderboard-row {
  background:
    linear-gradient(90deg, rgba(8, 15, 29, 0.7), rgba(10, 17, 32, 0.55)),
    radial-gradient(circle at 0% 50%, rgba(103, 228, 255, 0.06), transparent 40%);
}

.ref-funnel-stage {
  background:
    linear-gradient(90deg, rgba(8, 15, 29, 0.72), rgba(10, 18, 34, 0.58)),
    radial-gradient(circle at 100% 50%, rgba(141, 99, 255, 0.06), transparent 45%) !important;
}

.ref-score-box {
  background:
    linear-gradient(155deg, rgba(10, 17, 32, 0.75), rgba(7, 12, 24, 0.65)),
    radial-gradient(circle at 0% 0%, rgba(103, 228, 255, 0.06), transparent 50%) !important;
}

.ref-subpage .ref-metric {
  background:
    linear-gradient(160deg, rgba(12, 21, 40, 0.9), rgba(8, 14, 28, 0.75)),
    radial-gradient(circle at 100% 0%, rgba(103, 228, 255, 0.1), transparent 50%);
}

.ref-insight-chip.is-automation {
  background:
    linear-gradient(155deg, rgba(12, 20, 38, 0.92), rgba(8, 14, 28, 0.85)),
    radial-gradient(circle at 100% 0%, rgba(52, 211, 153, 0.1), transparent 50%) !important;
}

.ref-insight-chip.is-level {
  background:
    linear-gradient(155deg, rgba(12, 20, 38, 0.92), rgba(8, 14, 28, 0.85)),
    radial-gradient(circle at 0% 100%, rgba(251, 191, 36, 0.1), transparent 50%) !important;
}

.ref-insight-chip.is-source {
  background:
    linear-gradient(155deg, rgba(12, 20, 38, 0.92), rgba(8, 14, 28, 0.85)),
    radial-gradient(circle at 0% 0%, rgba(103, 228, 255, 0.12), transparent 50%) !important;
}

.ref-login-card {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(155deg, rgba(12, 21, 40, 0.94), rgba(7, 13, 26, 0.88)),
    radial-gradient(circle at 100% 0%, rgba(124, 58, 237, 0.14), transparent 48%) !important;
}

.ref-login-card::before {
  content: "";
  position: absolute;
  right: -20px;
  top: 50%;
  transform: translateY(-50%);
  width: 140px;
  height: 140px;
  opacity: 0.4;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='20' cy='50' r='6' fill='%2367e4ff' fill-opacity='0.4'/%3E%3Ccircle cx='50' cy='30' r='8' fill='%238d63ff' fill-opacity='0.45'/%3E%3Ccircle cx='80' cy='55' r='5' fill='%2367e4ff' fill-opacity='0.35'/%3E%3Cpath stroke='%2367e4ff' stroke-opacity='0.25' d='M20 50 L50 30 L80 55'/%3E%3C/svg%3E") center / contain no-repeat;
  pointer-events: none;
}

@media (max-width: 640px) {
  .ref-portal-main.ref-cabinet-main {
    width: calc(100vw - 20px);
    padding-bottom: 32px;
  }

  .ref-hero-highlights {
    grid-template-columns: 1fr;
  }

  .ref-chart-card canvas {
    height: 160px !important;
  }
}
