/* ============================================================
   BENDICIONES - WebApp de Telegram
   Sistema: Geist + regla 4px + radios 8-40px + iconos 18px
   Estetica: violeta (#6557FF) sobre light mode suave.
   Texto primario #181818 / secundario #6A6A6A.
   ============================================================ */

:root {
    --font-heading: 'Geist', 'Inter', system-ui, sans-serif;
    --font-body: 'Geist', 'Inter', system-ui, sans-serif;

    --ink: #181818;          /* texto primario */
    --ink-soft: #6A6A6A;     /* texto secundario */
    --ink-faint: #9A9AA6;    /* labels / hints */

    --brand: #6557FF;        /* violeta principal */
    --brand-dark: #201650;   /* navy profundo */
    --brand-600: #4F40E6;
    --brand-300: #9CA4FF;
    --brand-100: #DDE1FF;
    --brand-50:  #EEF0FF;

    --gold: #FFC83D;         /* monedas / gamificacion */
    --gold-dark: #F0A500;
    --green: #16B364;
    --green-50: #E7F8EF;
    --red: #E5484D;
    --red-50: #FDECEC;
    --orange: #F97316;
    --purple: #8B5CF6;

    --bg: #F4F4FB;           /* fondo app */
    --card: #FFFFFF;
    --border: #ECECF3;
    --shadow: 0 6px 24px rgba(32, 22, 80, .08);
    --shadow-lg: 0 16px 48px rgba(32, 22, 80, .14);

    --app-max: 540px;
    --nav-h: 76px;
}

* { -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body {
    font-family: var(--font-body);
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: none;
}
h1, h2, h3, h4, .font-heading { font-family: var(--font-heading); font-weight: 700; letter-spacing: -.01em; }

/* App container centrado (se ve bien tambien en Telegram Desktop/Web) */
.app-shell {
    max-width: var(--app-max);
    margin: 0 auto;
    min-height: 100dvh;
    position: relative;
}

/* ------------------------------------------------------------
   Scrollbar (oculto/sutil para feel nativo)
   ------------------------------------------------------------ */
::-webkit-scrollbar { width: 0; height: 0; }

/* ------------------------------------------------------------
   Animaciones
   ------------------------------------------------------------ */
@keyframes fadeUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.anim-fade-up { opacity: 0; animation: fadeUp .55s cubic-bezier(.22,1,.36,1) forwards; }
.anim-delay-1 { animation-delay: .08s; }
.anim-delay-2 { animation-delay: .16s; }
.anim-delay-3 { animation-delay: .24s; }
.anim-delay-4 { animation-delay: .32s; }
.anim-delay-5 { animation-delay: .40s; }

@keyframes popIn { 0% { opacity: 0; transform: scale(.88); } 100% { opacity: 1; transform: scale(1); } }
.anim-pop { animation: popIn .35s cubic-bezier(.22,1,.36,1) both; }

@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* Monedas flotantes (gamificacion) */
@keyframes coinFloat { 0%,100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-10px) rotate(6deg); } }
@keyframes coinSpin { 0% { transform: rotateY(0); } 100% { transform: rotateY(360deg); } }
.coin-float { animation: coinFloat 3.2s ease-in-out infinite; }
.coin-float.d1 { animation-delay: .4s; }
.coin-float.d2 { animation-delay: .9s; }
.coin-float.d3 { animation-delay: 1.4s; }

@keyframes pulseGlow { 0%,100% { transform: scale(1); opacity: .55; } 50% { transform: scale(1.12); opacity: .9; } }
.pulse-glow { animation: pulseGlow 2.6s ease-in-out infinite; }

@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
.shimmer {
    background: linear-gradient(110deg, rgba(255,255,255,0) 30%, rgba(255,255,255,.5) 50%, rgba(255,255,255,0) 70%);
    background-size: 200% 100%;
    animation: shimmer 2.4s linear infinite;
}

@keyframes countUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.count-up { animation: countUp .5s ease both; }

/* Confetti / sparkle */
@keyframes sparkle { 0%,100% { opacity: .2; transform: scale(.7); } 50% { opacity: 1; transform: scale(1); } }
.sparkle { animation: sparkle 1.8s ease-in-out infinite; }

/* ------------------------------------------------------------
   Top app bar
   ------------------------------------------------------------ */
.app-bar {
    position: sticky; top: 0; z-index: 40;
    background: rgba(244,244,251,.86);
    -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
    padding-top: max(10px, env(safe-area-inset-top));
}

/* Avatar */
.avatar {
    border-radius: 9999px; object-fit: cover;
    background: var(--brand); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700;
}

/* ------------------------------------------------------------
   Bottom nav (capsula glass flotante)
   ------------------------------------------------------------ */
.bottom-nav {
    position: fixed; left: 50%; transform: translateX(-50%);
    bottom: max(14px, env(safe-area-inset-bottom));
    z-index: 60;
    width: min(calc(var(--app-max) - 24px), calc(100vw - 24px));
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
    padding: 8px 10px;
    border-radius: 30px;
    background: rgba(255,255,255,.72);
    -webkit-backdrop-filter: blur(22px) saturate(160%); backdrop-filter: blur(22px) saturate(160%);
    border: 1px solid rgba(255,255,255,.6);
    box-shadow: 0 10px 36px rgba(32,22,80,.18);
}
.bottom-nav-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; height: 52px; border-radius: 18px;
    color: var(--ink-faint); font-size: 10px; font-weight: 600;
    transition: color .15s ease, transform .12s ease;
}
.bottom-nav-item i { font-size: 22px; }
.bottom-nav-item.active { color: var(--brand); }
.bottom-nav-item:active { transform: scale(.9); }

/* Boton central elevado */
.bottom-nav-center { position: relative; }
.bottom-nav-center .fab {
    position: absolute; left: 50%; top: -26px; transform: translateX(-50%);
    width: 58px; height: 58px; border-radius: 22px;
    background: var(--brand); color: #fff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 10px 24px rgba(101,87,255,.45);
    border: 4px solid var(--bg);
    transition: transform .14s ease;
}
.bottom-nav-center .fab i { font-size: 26px; }
.bottom-nav-center .fab:active { transform: translateX(-50%) scale(.92); }
.bottom-nav-center .fab-label { margin-top: 34px; font-size: 10px; font-weight: 700; color: var(--brand); }

.has-bottom-nav { padding-bottom: calc(var(--nav-h) + 28px); }

/* ------------------------------------------------------------
   Cards / paneles
   ------------------------------------------------------------ */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow);
}
.card-flat { background: var(--card); border: 1px solid var(--border); border-radius: 20px; }
.card-hover { transition: transform .16s ease, box-shadow .16s ease; }
.card-hover:active { transform: scale(.985); }

/* Hero balance (violeta) */
.hero-card {
    border-radius: 28px; color: #fff; position: relative; overflow: hidden;
    background: var(--brand);
    background-image: radial-gradient(120% 120% at 0% 0%, #7B6BFF 0%, #6557FF 42%, #4A39C7 100%);
    box-shadow: 0 18px 40px rgba(101,87,255,.32);
}
.hero-card .hero-deco {
    position: absolute; inset: 0; opacity: .9; pointer-events: none;
}
.hero-card .ring {
    position: absolute; border-radius: 9999px; border: 1.5px solid rgba(255,255,255,.16);
}

/* ------------------------------------------------------------
   Botones
   ------------------------------------------------------------ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font-weight: 600; font-size: 15px; font-family: var(--font-body);
    border-radius: 16px; padding: 13px 20px;
    transition: transform .12s ease, background .15s ease, box-shadow .15s ease;
    cursor: pointer; white-space: nowrap; border: none; line-height: 1;
}
.btn i { font-size: 18px; }
.btn:active { transform: scale(.96); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 8px 20px rgba(101,87,255,.32); }
.btn-primary:hover { background: var(--brand-600); }
.btn-gold { background: var(--gold); color: #4A3000; box-shadow: 0 8px 20px rgba(255,200,61,.4); }
.btn-gold:hover { background: var(--gold-dark); color:#3a2600; }
.btn-green { background: var(--green); color: #fff; }
.btn-orange { background: var(--orange); color: #fff; }
.btn-orange:hover { background: #EA580C; }
.btn-dark { background: var(--ink); color: #fff; }
.btn-outline { background: #fff; color: var(--ink); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-ghost { background: var(--brand-50); color: var(--brand); }
.btn-danger { background: var(--red); color: #fff; }
.btn-block { width: 100%; }
.btn-lg { padding: 16px 22px; font-size: 16px; border-radius: 18px; }
.btn[disabled], .btn.disabled { opacity: .55; cursor: not-allowed; pointer-events: none; box-shadow: none; }

/* Estado de carga (anti misclick) */
.btn.is-loading { pointer-events: none; cursor: progress; position: relative; }
.btn.is-loading .btn-label { opacity: .35; }
.btn-spin { display: inline-block; width: 18px; height: 18px; animation: btnSpin .65s linear infinite; transform-origin: center; position: absolute; }
@keyframes btnSpin { to { transform: rotate(360deg); } }

/* Pildora de accion rapida (grid del dashboard) */
.quick-action {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 14px 6px; border-radius: 20px; background: var(--card);
    border: 1px solid var(--border); transition: transform .12s ease;
}
.quick-action:active { transform: scale(.94); }
.quick-action .qa-icon {
    width: 48px; height: 48px; border-radius: 16px;
    display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.quick-action .qa-label { font-size: 12px; font-weight: 600; color: var(--ink); }

/* ------------------------------------------------------------
   Badges / chips
   ------------------------------------------------------------ */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px; border-radius: 9999px;
    font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.badge-brand  { background: var(--brand-50); color: var(--brand); }
.badge-blue   { background: var(--brand-50); color: var(--brand); }
.badge-green  { background: var(--green-50); color: #07814A; }
.badge-purple { background: #F1ECFF; color: #6D28D9; }
.badge-orange { background: #FFF1E3; color: #C2410C; }
.badge-red    { background: var(--red-50); color: #C0282C; }
.badge-gold   { background: #FFF6DD; color: #9A6B00; }
.badge-gray   { background: #F1F1F6; color: var(--ink-soft); }

.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 12px; border-radius: 9999px; font-size: 13px; font-weight: 600;
    background: var(--brand-50); color: var(--brand);
}

/* ------------------------------------------------------------
   Formularios
   ------------------------------------------------------------ */
.form-input, select.form-input {
    width: 100%;
    border: 1.5px solid var(--border); border-radius: 16px;
    padding: 14px 16px; font-size: 15px; font-family: var(--font-body);
    background: #fff; color: var(--ink);
    transition: border-color .15s ease, box-shadow .15s ease; outline: none;
    -webkit-appearance: none; appearance: none;
}
.form-input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(101,87,255,.12); }
.form-input::placeholder { color: var(--ink-faint); }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 8px; }
select.form-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236A6A6A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 16px center; padding-right: 44px;
}

/* Toggle */
.switch { position: relative; display: inline-block; width: 46px; height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: #D6D6E0; border-radius: 9999px; transition: .25s; }
.switch .slider::before { content: ""; position: absolute; height: 22px; width: 22px; left: 3px; top: 3px; background: #fff; border-radius: 9999px; transition: .25s; box-shadow: 0 2px 4px rgba(0,0,0,.2); }
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* ------------------------------------------------------------
   Flash / toasts
   ------------------------------------------------------------ */
.flash {
    display: flex; align-items: flex-start; gap: 10px;
    border-radius: 16px; padding: 13px 15px; font-size: 14px; font-weight: 500;
}
.flash i { font-size: 19px; margin-top: 1px; }
.flash-success { background: var(--green-50); color: #07633A; }
.flash-error   { background: var(--red-50); color: #B0282C; }
.flash-warning { background: #FFF6DD; color: #8A5B00; }
.flash-info    { background: var(--brand-50); color: var(--brand-dark); }

/* ------------------------------------------------------------
   Modales / sheets
   ------------------------------------------------------------ */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 90;
    background: rgba(24,24,24,.45);
    -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
    display: flex; align-items: flex-end; justify-content: center;
}
.sheet-panel {
    background: #fff; border-radius: 28px 28px 0 0;
    width: 100%; max-width: var(--app-max);
    max-height: 92dvh; overflow-y: auto;
    padding-bottom: max(18px, env(safe-area-inset-bottom));
    animation: slideUp .32s cubic-bezier(.22,1,.36,1) both;
}
.sheet-handle { width: 42px; height: 5px; border-radius: 9999px; background: #E2E2EC; margin: 12px auto 4px; }
.modal-panel {
    background: #fff; border-radius: 24px; width: 100%; max-width: 440px;
    animation: popIn .3s cubic-bezier(.22,1,.36,1) both; margin: auto;
}

/* ------------------------------------------------------------
   Progreso circular (holding / niveles)
   ------------------------------------------------------------ */
.progress-ring { transform: rotate(-90deg); }
.progress-ring circle { transition: stroke-dashoffset 1s cubic-bezier(.22,1,.36,1); }

/* Barra de progreso */
.pbar { height: 9px; border-radius: 9999px; background: #ECECF3; overflow: hidden; }
.pbar > span { display: block; height: 100%; border-radius: 9999px; background: var(--brand); transition: width 1s cubic-bezier(.22,1,.36,1); }
.pbar.gold > span { background: var(--gold); }
.pbar.green > span { background: var(--green); }

/* ------------------------------------------------------------
   Niveles (tarjetas)
   ------------------------------------------------------------ */
.level-card {
    border: 2px solid var(--border); border-radius: 20px; background: #fff;
    cursor: pointer; transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}
.level-card:active { transform: scale(.97); }
.level-card.selected { border-color: var(--brand); box-shadow: 0 8px 24px rgba(101,87,255,.2); }
.level-card.level-active { border-color: var(--green); }
.level-card.level-locked { opacity: .6; }

/* Checklist gamificado */
.achievement-item { position: relative; }
.achievement-item .check-circle {
    width: 40px; height: 40px; min-width: 40px; border-radius: 9999px;
    display: flex; align-items: center; justify-content: center; font-size: 19px;
    border: 2px dashed #D6D6E0; color: var(--ink-faint); transition: all .25s ease;
}
.achievement-item.done .check-circle { border: 2px solid var(--green); background: var(--green); color: #fff; }
.achievement-item.done .achievement-title { color: var(--ink-faint); text-decoration: line-through; }
.achievement-connector { position: absolute; left: 19px; top: 44px; bottom: -12px; width: 2px; background: var(--border); }
.achievement-item.done .achievement-connector { background: var(--green); }
.achievement-item:last-child .achievement-connector { display: none; }

/* ------------------------------------------------------------
   Tablas (compactas, scroll horizontal)
   ------------------------------------------------------------ */
.table-base { width: 100%; font-size: 13.5px; }
.table-base thead th {
    text-align: left; padding: 9px 12px; font-size: 11px; font-weight: 700;
    letter-spacing: .04em; text-transform: uppercase; color: var(--ink-faint);
    border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table-base tbody td { padding: 12px; border-bottom: 1px solid #F4F4F8; vertical-align: middle; }
.table-base tbody tr:last-child td { border-bottom: none; }

.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; min-width: 560px; }
.data-table thead th { text-align: left; padding: 10px 12px; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-faint); background: #FAFAFD; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table tbody td { padding: 12px; border-bottom: 1px solid #F4F4F8; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ------------------------------------------------------------
   Tree (red / referidos)
   ------------------------------------------------------------ */
.tree-node { border: 1px solid var(--border); border-radius: 16px; background: #fff; }
.tree-children { margin-left: 16px; padding-left: 14px; border-left: 2px dashed var(--brand-100); }

/* ------------------------------------------------------------
   Overlay de carga
   ------------------------------------------------------------ */
.load-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(244,244,251,.82);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none; transition: opacity .25s ease;
}
.load-overlay.show { opacity: 1; pointer-events: auto; }
.lo-card { background: #fff; border: 1px solid var(--border); border-radius: 24px; padding: 26px 30px; display: flex; flex-direction: column; align-items: center; gap: 14px; box-shadow: var(--shadow-lg); }
.lo-ring { width: 46px; height: 46px; animation: btnSpin .8s linear infinite; transform-origin: center; }

/* ------------------------------------------------------------
   Utilidades
   ------------------------------------------------------------ */
.tabular { font-variant-numeric: tabular-nums; }
.text-ink { color: var(--ink); }
.text-soft { color: var(--ink-soft); }
.text-faint { color: var(--ink-faint); }
.text-brand { color: var(--brand); }
.text-gold { color: var(--gold-dark); }
.text-green { color: var(--green); }
.divider { height: 1px; background: var(--border); }

/* Sidebar links (reuso desde admin / vistas heredadas) */
.sidebar-link { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; font-size: 15px; font-weight: 500; color: var(--ink-soft); transition: background .15s ease, color .15s ease; }
.sidebar-link i { font-size: 20px; }
.sidebar-link:hover { background: var(--brand-50); color: var(--brand); }
.sidebar-link.active { background: var(--brand); color: #fff; }

/* Ocultar artefactos de Google Translate */
.goog-te-banner-frame, .goog-te-gadget, #google_translate_element, .skiptranslate { display: none !important; }
body { top: 0 !important; }
.goog-te-spinner-pos { display: none !important; }

/* ------------------------------------------------------------
   Toast (confirmaciones rapidas: "Copiado")
   ------------------------------------------------------------ */
.cb-toast {
    position: fixed; left: 50%; bottom: calc(var(--nav-h) + 18px);
    transform: translateX(-50%) translateY(16px);
    background: var(--ink); color: #fff; font-size: 13.5px; font-weight: 600;
    padding: 11px 18px; border-radius: 9999px; z-index: 300;
    display: inline-flex; align-items: center; gap: 8px;
    box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
    transition: opacity .2s ease, transform .2s ease; max-width: 88vw;
}
.cb-toast i { color: var(--gold); font-size: 16px; }
.cb-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ------------------------------------------------------------
   Caja de link de referido (copiar tactil)
   ------------------------------------------------------------ */
.ref-box {
    display: flex; align-items: center; gap: 10px;
    background: var(--brand-50); border: 1px solid var(--brand-100);
    border-radius: 16px; padding: 10px 12px;
}
.ref-box .ref-text {
    flex: 1; min-width: 0; font-size: 12.5px; font-weight: 600; color: var(--brand-dark);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ref-copy-btn {
    flex-shrink: 0; width: 40px; height: 40px; border-radius: 12px;
    background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 18px; transition: transform .12s ease, background .15s ease;
}
.ref-copy-btn:active { transform: scale(.9); }
.ref-copy-btn.copied { background: var(--green); }

/* Fila generica copiable (ej. wallet USDT) */
.copy-row {
    display: flex; align-items: center; gap: 10px;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: 14px; padding: 10px 12px;
}
.copy-row .copy-val { flex: 1; min-width: 0; font-size: 12.5px; font-family: ui-monospace, monospace; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ------------------------------------------------------------
   Lista de datos en movil (reemplazo de tablas anchas)
   ------------------------------------------------------------ */
.data-list { display: flex; flex-direction: column; gap: 10px; }
.data-row {
    display: flex; align-items: center; gap: 12px;
    background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 12px 14px;
}
.data-row .dr-avatar {
    width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px; color: #fff; background: var(--brand);
}
.data-row .dr-main { flex: 1; min-width: 0; }
.data-row .dr-title { font-weight: 700; font-size: 14px; color: var(--ink); }
.data-row .dr-sub { font-size: 11.5px; color: var(--ink-faint); }
.data-row .dr-right { text-align: right; flex-shrink: 0; }

/* Nodos anidados de la red (downline) */
.net-children { display: flex; flex-direction: column; gap: 10px; }
.net-children:empty { display: none; }
.net-children.hidden { display: none; }

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