/* ============================================
   MyFriends VPN — Telegram Mini App
   Dark glassmorphic dashboard
   ============================================ */

:root {
    --bg-primary: #0a0e17;
    --bg-card: rgba(18, 24, 38, 0.85);
    --bg-card-hover: rgba(24, 32, 52, 0.9);
    --border-card: rgba(255, 255, 255, 0.06);
    --border-glow: rgba(99, 179, 237, 0.15);

    --text-primary: #e8edf5;
    --text-secondary: rgba(200, 210, 230, 0.65);
    --text-muted: rgba(160, 175, 200, 0.4);

    --accent: #63b3ed;
    --accent-glow: rgba(99, 179, 237, 0.25);
    --accent-2: #9f7aea;
    --accent-3: #48bb78;
    --danger: #fc8181;

    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);

    --font: 'Outfit', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.app {
    position: relative;
    min-height: 100vh;
    max-width: 420px;
    margin: 0 auto;
    padding: 0 16px 32px;
}

/* ============ AMBIENT BACKGROUND ============ */

.ambient-bg {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    animation: float 20s ease-in-out infinite;
}

.orb-1 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
    top: -100px;
    right: -80px;
    animation-delay: 0s;
}

.orb-2 {
    width: 250px;
    height: 250px;
    background: radial-gradient(circle, var(--accent-2) 0%, transparent 70%);
    bottom: 20%;
    left: -100px;
    animation-delay: -7s;
}

.orb-3 {
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, var(--accent-3) 0%, transparent 70%);
    bottom: -80px;
    right: 20%;
    animation-delay: -14s;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    25% {
        transform: translate(30px, -40px) scale(1.1);
    }

    50% {
        transform: translate(-20px, 20px) scale(0.95);
    }

    75% {
        transform: translate(15px, 30px) scale(1.05);
    }
}

/* ============ SCREENS ============ */

.screen {
    position: relative;
    z-index: 1;
    display: none;
    animation: fadeIn 0.4s ease;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============ LOADING ============ */

.loading-screen {
    display: none;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.loading-screen.active {
    display: flex;
}

.loader-wrap {
    text-align: center;
}

.loader-ring {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-card);
    border-top-color: var(--accent);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loader-text {
    color: var(--text-secondary);
    font-size: 14px;
    letter-spacing: 0.5px;
}

/* ============ HEADER ============ */

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 0 20px;
}

.header-greeting {
    display: flex;
    align-items: center;
    gap: 12px;
}

.greeting-emoji {
    font-size: 28px;
    animation: wave 2s ease-in-out infinite;
}

@keyframes wave {

    0%,
    100% {
        transform: rotate(0deg);
    }

    25% {
        transform: rotate(20deg);
    }

    50% {
        transform: rotate(-5deg);
    }

    75% {
        transform: rotate(15deg);
    }
}

.greeting-hello {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 400;
}

.greeting-name {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-secondary);
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-badge.active .status-dot {
    background: var(--accent-3);
    box-shadow: 0 0 8px var(--accent-3);
    animation: pulse 2s ease-in-out infinite;
}

.status-badge.pending .status-dot {
    background: #ecc94b;
    animation: pulse 2s ease-in-out infinite;
}

.status-badge.blocked .status-dot {
    background: var(--danger);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ============ CARDS ============ */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius);
    padding: 20px;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: all 0.3s ease;
}

.card:hover {
    border-color: var(--border-glow);
}

/* ============ STATUS CARD ============ */

.status-card {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.card-glow {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 50%, var(--accent-glow) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

.status-card:hover .card-glow {
    opacity: 1;
}

.status-icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: rgba(99, 179, 237, 0.1);
    color: var(--accent);
    flex-shrink: 0;
}

.status-card.approved .status-icon {
    background: rgba(72, 187, 120, 0.1);
    color: var(--accent-3);
}

.status-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.status-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ============ USAGE CARD ============ */

.usage-card-wrap {
    margin-bottom: 16px;
}

.usage-card {
    padding: 18px 20px;
}

.usage-section {
    margin-bottom: 14px;
}

.usage-section:last-of-type {
    margin-bottom: 0;
}

.usage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.usage-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.usage-value {
    font-size: 13px;
    font-family: var(--font-mono);
    color: var(--text-primary);
    font-weight: 500;
}

.usage-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
}

.usage-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
    min-width: 2px;
}

.usage-bar-fill.warn {
    background: linear-gradient(90deg, #ecc94b, #ed8936);
}

.usage-bar-fill.danger {
    background: linear-gradient(90deg, #fc8181, #f56565);
}

.usage-bar-fill.expire-bar {
    background: linear-gradient(90deg, var(--accent-3), #38b2ac);
}

.usage-bar-fill.expire-bar.warn {
    background: linear-gradient(90deg, #ecc94b, #ed8936);
}

.usage-bar-fill.expire-bar.danger {
    background: linear-gradient(90deg, #fc8181, #f56565);
}

.usage-servers {
    display: flex;
    gap: 6px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border-card);
}

.usage-server-tag {
    padding: 4px 10px;
    background: rgba(72, 187, 120, 0.1);
    border: 1px solid rgba(72, 187, 120, 0.2);
    border-radius: 14px;
    font-size: 12px;
    color: var(--accent-3);
    font-weight: 500;
}

/* ============ ACTIONS GRID ============ */

.actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.action-card {
    cursor: pointer;
    padding: 20px 16px;
    transition: all 0.25s ease;
}

.action-card:active {
    transform: scale(0.97);
}

.action-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-glow);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.action-icon {
    color: var(--accent);
    margin-bottom: 12px;
}

.action-card:nth-child(2) .action-icon {
    color: var(--accent-2);
}

.action-card:nth-child(3) .action-icon {
    color: #ecc94b;
}

.action-card:nth-child(4) .action-icon {
    color: var(--accent-3);
}

.action-label {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
}

.action-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.action-arrow {
    position: absolute;
    top: 16px;
    right: 16px;
    color: var(--text-muted);
    font-size: 16px;
    transition: transform 0.25s ease;
}

.action-card:hover .action-arrow {
    transform: translateX(3px);
    color: var(--text-secondary);
}

/* ============ PENDING CARD ============ */

.pending-card {
    text-align: center;
    padding: 40px 24px;
}

.pending-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.pending-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.pending-text {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ============ DETAIL SCREENS ============ */

.detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 0 16px;
}

.detail-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.back-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    color: var(--text-primary);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.back-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-glow);
}

.detail-card {
    text-align: center;
    padding: 32px 20px;
}

.detail-icon-large {
    color: var(--accent);
    margin-bottom: 16px;
    font-size: 48px;
}

.detail-card h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.detail-desc {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 24px;
}

/* ============ BUTTONS ============ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    margin-top: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px var(--accent-glow);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    color: var(--text-primary);
}

.btn-secondary:hover {
    border-color: var(--border-glow);
}

.btn-copy {
    margin-top: 12px;
}

/* ============ LINK BOX ============ */

.link-box {
    margin-top: 20px;
    text-align: left;
}

.link-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.link-code {
    display: block;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-xs);
    padding: 12px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--accent);
    word-break: break-all;
    line-height: 1.5;
    max-height: 100px;
    overflow-y: auto;
}

/* ============ APPS ROW ============ */

.apps-row {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.app-badge {
    padding: 4px 12px;
    background: rgba(99, 179, 237, 0.1);
    border: 1px solid rgba(99, 179, 237, 0.2);
    border-radius: 20px;
    font-size: 12px;
    color: var(--accent);
}

/* ============ PAYMENT ============ */

.price-tag {
    margin: 20px 0;
}

.price-amount {
    font-size: 36px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.price-period {
    font-size: 16px;
    color: var(--text-secondary);
}

.payment-methods {
    margin: 20px 0;
}

.payment-method {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-card);
}

.pm-icon {
    font-size: 28px;
}

.pm-info {
    text-align: left;
}

.pm-name {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
}

.pm-detail {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--accent);
}

.payment-note {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 16px 0;
}

/* ============ INSTRUCTIONS ============ */

.instruction-card {
    margin-bottom: 12px;
}

.instruction-platform {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.instruction-platform h3 {
    font-size: 16px;
    font-weight: 600;
}

.platform-icon {
    font-size: 24px;
}

.steps {
    list-style: none;
    counter-reset: step;
}

.steps li {
    counter-increment: step;
    position: relative;
    padding-left: 32px;
    margin-bottom: 10px;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.steps li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 1px;
    width: 22px;
    height: 22px;
    background: rgba(99, 179, 237, 0.1);
    border: 1px solid rgba(99, 179, 237, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
}

.steps li strong {
    color: var(--text-primary);
    font-weight: 500;
}

/* ============ TOAST ============ */

.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--bg-card);
    border: 1px solid var(--border-glow);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-primary);
    z-index: 100;
    opacity: 0;
    transition: all 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: var(--shadow);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ============ ADMIN ============ */

.admin-entry {
    margin-top: 16px;
}

.btn-admin {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    background: rgba(159, 122, 234, 0.1);
    border: 1px solid rgba(159, 122, 234, 0.25);
    border-radius: var(--radius-sm);
    color: var(--accent-2);
    font-family: var(--font);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
}

.btn-admin:hover {
    background: rgba(159, 122, 234, 0.2);
    border-color: rgba(159, 122, 234, 0.4);
}

.admin-icon {
    font-size: 18px;
}

.btn-refresh {
    margin-left: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-refresh:hover {
    border-color: var(--border-glow);
    transform: rotate(90deg);
}

.admin-stat-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.admin-stat {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-sm);
    padding: 12px 8px;
    text-align: center;
}

.admin-stat .stat-num {
    display: block;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.admin-stat .stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.admin-stat.active .stat-num { color: var(--accent-3); }
.admin-stat.pending .stat-num { color: #ecc94b; }
.admin-stat.blocked .stat-num { color: var(--danger); }

.admin-user-card {
    margin-bottom: 8px;
    cursor: pointer;
    padding: 14px 16px;
}

.admin-user-card:active {
    transform: scale(0.98);
}

.au-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.au-status {
    font-size: 12px;
}

.au-name {
    font-size: 15px;
    font-weight: 500;
    flex: 1;
}

.au-arrow {
    color: var(--text-muted);
    font-size: 16px;
}

.au-meta {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Admin user detail */
.au-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 16px 0;
}

.au-detail-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.au-detail-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.au-detail-val {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
    word-break: break-all;
}

.au-servers-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-card);
}

.btn-server {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    margin: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-server.on {
    border-color: rgba(72, 187, 120, 0.4);
    background: rgba(72, 187, 120, 0.1);
}

.btn-server.off {
    opacity: 0.5;
}

.btn-server:hover {
    transform: translateY(-1px);
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 24px;
    border: 1px solid rgba(252, 129, 129, 0.3);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    background: rgba(252, 129, 129, 0.1);
    color: var(--danger);
    transition: all 0.25s ease;
}

.btn-danger:hover {
    background: rgba(252, 129, 129, 0.2);
}

.au-btns-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

/* MTProto list in admin */
.au-mtproto-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.au-mtproto-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-xs);
    font-size: 13px;
}

.au-mtproto-flag {
    font-size: 16px;
}

.au-mtproto-name {
    flex: 1;
    font-weight: 500;
}

.au-mtproto-port {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-secondary);
}

.au-mtproto-status {
    font-size: 14px;
}

.btn-mt-toggle {
    padding: 6px 12px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border-card);
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-mt-toggle.on {
    border-color: rgba(72, 187, 120, 0.4);
    background: rgba(72, 187, 120, 0.1);
}

.btn-mt-toggle.off {
    opacity: 0.6;
}

.btn-mt-toggle:hover {
    transform: translateY(-1px);
}

.mt-input {
    display: block;
    width: 100%;
    padding: 10px 14px;
    margin-bottom: 8px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.mt-input:focus {
    border-color: var(--accent);
}

.mt-input::placeholder {
    color: var(--text-muted);
}

/* ============ SCROLLBAR ============ */

::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-card);
    border-radius: 4px;
}