/* --- Дизайн-система & Премиум палитра --- */
:root {
    --bg-color: #050a18;
    --card-bg: rgba(255, 255, 255, 0.07);
    --card-border: rgba(255, 255, 255, 0.12);
    --primary: #0066ff;
    --primary-light: #60a5fa;
    --primary-glow: rgba(0, 102, 255, 0.25);
    --accent: #00d2ff;
    --accent-glow: rgba(0, 210, 255, 0.25);
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --success: #00f576;
    --error: #ff3b70;
    
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 12px;
    
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --shadow-premium: 0 12px 40px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* --- Эффект жидкого стекла (Liquid Glass) --- */
.glass-card, .section-card, .modal-content, #login-container {
    background: var(--card-bg) !important;
    border: 1px solid var(--card-border) !important;
    box-shadow: var(--shadow-premium) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
}

@supports not (hanging-punctuation:first) {
    .glass-card, .section-card, .modal-content, #login-container {
        backdrop-filter: url(#displacementFilter) blur(2px) !important;
    }
}

/* --- Сброс стилей --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

html, body {
    width: 100%;
    height: 100%;
    min-height: 100%;
    background-color: var(--bg-color);
    overflow: hidden;
    position: relative;
}

body {
    color: var(--text);
    font-family: var(--font-sans);
    line-height: 1.4;
    display: flex;
    justify-content: center;
    align-items: center;
    background-attachment: fixed;
}

/* --- Фоновые светящиеся сферы --- */
.blob-glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    z-index: -1;
    opacity: 0.25;
    pointer-events: none;
}

.blob-1 {
    top: -50px;
    left: -50px;
    width: 250px;
    height: 250px;
    background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
}

.blob-2 {
    bottom: -50px;
    right: -50px;
    width: 250px;
    height: 250px;
    background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
}

.blob-3 {
    top: 45%;
    left: 20%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, #0a225c 0%, transparent 70%);
}

/* --- Главные мобильные контейнеры --- */
.page-container {
    width: 100%;
    max-width: 460px;
    height: 100%;
    display: none;
    flex-direction: column;
    box-sizing: border-box;
    position: relative;
}

.page-container.active {
    display: flex;
}

/* --- Авторизация --- */
#login-container {
    padding: 40px 24px;
    justify-content: center;
    text-align: center;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow-premium);
    overflow-y: auto;
}

.logo-wrapper {
    margin-bottom: 32px;
}

.brand-title {
    font-size: 2.8rem;
    font-weight: 800;
    letter-spacing: -1.5px;
    background: linear-gradient(135deg, #ffffff 50%, var(--primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-title span {
    -webkit-text-fill-color: initial;
    display: inline-block;
    filter: drop-shadow(0 0 10px var(--primary));
    margin-left: 2px;
}

.brand-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 6px;
    font-weight: 400;
}

.login-box {
    width: 100%;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-lg);
    padding: 24px 20px;
}

.login-box h3 {
    font-size: 1.2rem;
    margin-bottom: 16px;
    font-weight: 600;
    font-family: 'Montserrat', sans-serif;
}

.helper-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    line-height: 1.5;
}

.bot-link-tip {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 20px;
    line-height: 1.4;
}

.bot-link-tip a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.auth-step {
    display: none;
}

.auth-step.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

/* --- Главный интерфейс Кабинета (Native app feel) --- */
.app-layout {
    /* display: flex is inherited from .page-container.active */
    flex-direction: column;
    height: 100%;
    background: transparent;
    padding-bottom: calc(65px + env(safe-area-inset-bottom));
}

.dash-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: rgba(11, 7, 19, 0.7);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    z-index: 10;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(0, 102, 255, 0.3) 0%, rgba(0, 210, 255, 0.2) 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text);
    flex-shrink: 0;
}

.user-meta {
    min-width: 0;
}

.user-meta h2 {
    font-size: 1rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #fff;
    max-width: 170px;
}

#user-id-badge {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
    margin-top: 1px;
}

.btn-logout-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 59, 112, 0.08);
    border: 1px solid rgba(255, 59, 112, 0.15);
    color: var(--error);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout-icon:active {
    transform: scale(0.95);
    background: rgba(255, 59, 112, 0.15);
}

/* --- Вьюпорт для вкладок --- */
.tab-viewport {
    flex: 1;
    position: relative;
    width: 100%;
    overflow: hidden;
}

.tab-content {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}

.tab-content.active-tab {
    display: block;
    animation: tabSlide 0.25s cubic-bezier(0.1, 0.8, 0.25, 1) forwards;
}

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

.tab-scroll-area {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 16px 16px 100px 16px; /* 100px bottom padding to clear bottom menu & iOS home/Safari bars */
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
}

/* --- Красивые стеклянные карточки --- */
.section-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    box-shadow: var(--shadow-premium);
    padding: 20px 18px;
    width: 100%;
    position: relative;
    margin-bottom: 16px; /* Spacing between cards in block layout */
}

.section-card h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: #fff;
    font-family: 'Montserrat', sans-serif;
    letter-spacing: -0.3px;
}

.section-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 16px;
    line-height: 1.45;
}

/* --- Карточка Статуса --- */
.status-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, rgba(10, 20, 50, 0.7) 0%, rgba(5, 10, 30, 0.7) 100%);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
}

.indicator-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--text-muted);
    box-shadow: 0 0 10px rgba(142, 138, 159, 0.3);
    position: relative;
}

.indicator-dot.active {
    background-color: var(--success);
    box-shadow: 0 0 12px var(--success);
}

.indicator-dot.active::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 50%;
    border: 2px solid var(--success);
    animation: pulse 1.6s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.6); opacity: 0; }
}

.sub-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: right;
}

.sub-detail-item {
    display: flex;
    flex-direction: column;
}

.sub-detail-item .label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sub-detail-item .value {
    font-size: 0.85rem;
    font-weight: 700;
    color: #fff;
}

/* --- Ключи доступа VLESS --- */
.key-box-container {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 8px;
    width: 100%;
}

.key-box-display {
    width: 100%;
    padding: 14px;
    min-height: 48px;
    display: flex;
    align-items: center;
    position: relative;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.key-text-fallback {
    color: var(--text-muted);
    font-size: 0.75rem;
    width: 100%;
    word-break: break-all;
    line-height: 1.4;
}

.hidden-textarea {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.key-box-actions {
    display: flex;
    width: 100%;
}

.btn-key-action {
    flex: 1;
    border-radius: 0;
    border: none;
    padding: 12px;
    font-size: 0.85rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.btn-key-action:first-child {
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-key-action:active {
    background: rgba(255, 255, 255, 0.03);
}

#btn-copy-key {
    background: rgba(0, 102, 255, 0.12);
    color: var(--primary-light);
}

#btn-copy-key:active {
    background: rgba(138, 43, 226, 0.22);
}

.instruction-tip {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 8px;
    line-height: 1.4;
}

/* --- Сетка Регионов --- */
.regions-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    width: 100%;
}

.region-btn {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-md);
    color: var(--text);
    padding: 14px 16px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.region-btn:active {
    transform: scale(0.98);
    background: rgba(255, 255, 255, 0.06);
}

.region-btn.active {
    background: linear-gradient(135deg, rgba(0, 102, 255, 0.15) 0%, rgba(0, 210, 255, 0.05) 100%);
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(0, 102, 255, 0.15);
}

.region-btn::after {
    content: '';
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.15);
    transition: all 0.2s;
}

.region-btn.active::after {
    border-color: var(--accent);
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
}

/* --- Баланс --- */
.balance-card {
    background: linear-gradient(135deg, rgba(0, 102, 255, 0.1) 0%, rgba(0, 210, 255, 0.03) 100%);
    border-color: rgba(0, 102, 255, 0.18);
}

.balance-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.balance-info .label {
    font-size: 0.95rem;
    color: var(--text-muted);
}

.balance-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--accent);
    text-shadow: 0 0 15px var(--accent-glow);
    font-family: 'Montserrat', sans-serif;
}

/* --- Сегментированные переключатели --- */
.tariff-group {
    margin-bottom: 18px;
    width: 100%;
}

.tariff-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.segmented-control {
    display: flex;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    padding: 3px;
    gap: 3px;
    width: 100%;
}

.segment-btn {
    flex: 1;
    background: transparent;
    border: none;
    border-radius: 9px;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 10px 0;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.segment-btn.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(138, 43, 226, 0.35);
}

.checkout-box {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 16px;
    margin-top: 20px;
}

.price-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.price-summary span {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.price-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: #fff;
    font-family: 'Montserrat', sans-serif;
}

/* --- Вводы / Inputs --- */
.input-group {
    display: flex;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
    padding: 3px;
    transition: border-color 0.2s;
}

.input-group:focus-within {
    border-color: var(--primary-light);
}

.input-group input,
.input-group-vertical input {
    background: transparent;
    border: none;
    color: #fff;
    padding: 12px 14px;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    width: 100%;
}

.input-group input {
    flex: 1;
    min-width: 0;
}

.input-group-vertical {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.input-group-vertical input {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
    transition: border-color 0.2s;
}

.input-group-vertical input:focus {
    border-color: var(--primary-light);
}

/* --- Кнопки --- */
.btn {
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    text-decoration: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text);
}

.btn-accent {
    background: linear-gradient(135deg, #00d2ff 0%, var(--accent) 100%);
    color: #07050d;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-full-width {
    width: 100%;
}

.btn-large {
    padding: 14px;
    font-size: 1rem;
    border-radius: var(--radius-md);
}

/* --- Таб-панель (Bottom Nav) --- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 460px;
    height: calc(60px + env(safe-area-inset-bottom));
    background: rgba(5, 10, 30, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 4px 10px calc(4px + env(safe-area-inset-bottom)) 10px;
    z-index: 100;
}

.nav-item {
    flex: 1;
    background: transparent;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    gap: 4px;
    cursor: pointer;
    transition: all 0.2s;
    height: 100%;
}

.nav-item svg {
    transition: transform 0.2s, stroke 0.2s;
    stroke: var(--text-muted);
}

.nav-item.active {
    color: var(--accent);
}

.nav-item.active svg {
    stroke: var(--accent);
    transform: translateY(-2px);
    filter: drop-shadow(0 0 5px var(--accent-glow));
}

/* --- Вкладка помощи/инструкций --- */
.guide-steps {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 10px;
}

.step-item {
    display: flex;
    gap: 14px;
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid rgba(255, 255, 255, 0.03);
    padding: 14px;
    border-radius: var(--radius-md);
}

.step-num {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 800;
    flex-shrink: 0;
    box-shadow: 0 0 10px var(--primary-glow);
}

.step-info {
    flex: 1;
}

.step-info h4 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
}

.step-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.app-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.platform-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.platform-group span {
    font-weight: 600;
    margin-right: 2px;
}

.app-badge-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
}

.app-badge-btn:active {
    background: rgba(255, 255, 255, 0.12);
}

/* --- Модальное окно QR-кода --- */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(7, 5, 13, 0.88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 24px;
}

.modal-content {
    width: 100%;
    max-width: 330px;
    padding: 24px 20px;
    text-align: center;
}

.modal-content h3 {
    font-size: 1.15rem;
    margin-bottom: 8px;
    font-family: 'Montserrat', sans-serif;
}

.modal-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    line-height: 1.4;
}

.qr-container {
    background: #fff;
    padding: 14px;
    border-radius: var(--radius-md);
    width: 200px;
    height: 200px;
    margin: 0 auto 20px auto;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

.qr-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* --- Тосты (Уведомления) --- */
.toast {
    position: fixed;
    bottom: calc(75px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    background: rgba(5, 10, 30, 0.95);
    border: 1px solid var(--primary-light);
    color: #fff;
    padding: 12px 20px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 2000;
    transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), visibility 0.25s;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
    text-align: center;
}

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

/* --- Улучшенный кастомный скроллбар --- */
::-webkit-scrollbar {
    width: 4px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}
