/* --- CSS DESIGN SYSTEM (PURPLE DARK MODE) --- */

:root {
    /* Color Palette */
    --color-background: #03000a;
    --color-surface-bg: #090615;
    --color-card-bg: rgba(20, 10, 35, 0.45);
    --color-card-border: rgba(168, 85, 247, 0.15);
    
    --color-primary: #a855f7;       /* Glowing Neon Purple */
    --color-primary-hover: #b55fe6;
    --color-primary-glow: rgba(168, 85, 247, 0.35);
    
    --color-secondary: #6366f1;     /* Violet Blue */
    --color-secondary-hover: #4f46e5;
    
    --color-success: #10b981;       /* Active Badge (Green) */
    --color-warning: #f59e0b;       /* Expiring Soon Badge (Yellow) */
    --color-danger: #ef4444;        /* Expired Badge (Red) */
    
    --color-text-primary: #f3f4f6;
    --color-text-secondary: #9ca3af;
    --color-text-muted: #6b7280;
    
    --color-scrollbar: #1f1b2e;
    
    /* Layout Tokens */
    --border-radius-sm: 8px;
    --border-radius-md: 14px;
    --border-radius-lg: 20px;
    --transition-speed: 0.25s;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    /* Safe Area for iPhone Notch / Home Indicator */
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* --- RESET & BASIC STYLES --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--color-background);
    color: var(--color-text-primary);
    font-family: var(--font-family);
    font-size: 16px;
    line-height: 1.5;
    overflow: hidden; /* Handled by scrollable view wrappers */
    /* 100vh на мобильных браузерах — это высота БЕЗ учёта панели с адресной
       строкой, поэтому нижняя навигация уезжала под неё и была не видна.
       dvh считает реально видимую область; vh оставлен запасным вариантом
       для старых браузеров. */
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    width: 100dvw;
    display: flex;
    justify-content: center;
}

/* SPA App Container */
.app-container {
    width: 100%;
    max-width: 480px; /* Centered mobile container on desktop */
    height: 100%;
    background-color: var(--color-surface-bg);
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
    border-left: 1px solid rgba(255, 255, 255, 0.02);
    border-right: 1px solid rgba(255, 255, 255, 0.02);
    overflow: hidden;
}

/* Glassmorphism Panel Helper */
.glass-panel {
    background: var(--color-card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--color-card-border);
    border-radius: var(--border-radius-md);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* Scrollable main view */
.content-scrollable {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px calc(76px + var(--safe-area-bottom)) 16px;
    scrollbar-width: none; /* Hide scrollbar for clean app feel */
}
.content-scrollable::-webkit-scrollbar {
    display: none;
}

/* --- BUTTONS --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    font-family: var(--font-family);
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--border-radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--color-primary);
    color: #ffffff;
    box-shadow: 0 4px 15px var(--color-primary-glow);
}
.btn-primary:hover {
    background-color: var(--color-primary-hover);
    transform: translateY(-1px);
}
.btn-primary:active {
    transform: translateY(0);
}

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

.btn-destructive {
    background-color: rgba(239, 68, 68, 0.15);
    color: var(--color-danger);
    border: 1px solid rgba(239, 68, 68, 0.25);
}
.btn-destructive:hover {
    background-color: rgba(239, 68, 68, 0.25);
}

.btn-disabled, .btn:disabled {
    background-color: rgba(255, 255, 255, 0.03) !important;
    color: var(--color-text-muted) !important;
    border: 1px solid rgba(255, 255, 255, 0.03) !important;
    cursor: not-allowed;
    box-shadow: none !important;
    transform: none !important;
}

/* Badges */
.badge-soon {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    background-color: var(--color-primary);
    color: #ffffff;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
    letter-spacing: 0.5px;
}

/* Loader */
.loader-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(168, 85, 247, 0.1);
    border-top: 3px solid var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 40px auto;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- VIEW MANAGER --- */
.view-screen {
    display: none;
    flex-direction: column;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background-color: var(--color-surface-bg);
}
.view-screen.active {
    display: flex;
}

.tab-view {
    display: none;
    animation: fadeIn 0.3s ease;
}
.tab-view.active {
    display: block;
}

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

/* --- 1. AUTH SCREEN --- */
#auth-screen {
    justify-content: center;
    align-items: center;
    padding: 20px;
    background-color: var(--color-background);
}

.auth-card {
    width: 100%;
    padding: 32px 24px;
    text-align: center;
    animation: cardEntrance 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes cardEntrance {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.brand-header {
    margin-bottom: 32px;
}

.logo-placeholder {
    width: 68px;
    height: 68px;
    margin: 0 auto 16px auto;
    background: rgba(168, 85, 247, 0.1);
    border: 1.5px solid var(--color-card-border);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.logo-icon {
    width: 36px;
    height: 36px;
}

.brand-title {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}
.brand-subtitle {
    font-size: 13px;
    color: var(--color-primary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.auth-options {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.auth-option-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: 12px;
}

.tg-login-container {
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius-md);
    padding: 16px;
}

#telegram-widget-wrapper {
    display: flex;
    justify-content: center;
    min-height: 40px;
}

.divider {
    display: flex;
    align-items: center;
    color: var(--color-text-muted);
    font-size: 12px;
    margin: 4px 0;
}
.divider::before, .divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background-color: rgba(255, 255, 255, 0.08);
}
.divider span {
    padding: 0 10px;
}

.soon-option-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    opacity: 0.65;
}

.input-field {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}
.input-field.disabled label {
    color: var(--color-text-muted);
}
.input-field label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
}
.input-field input {
    width: 100%;
    padding: 12px;
    border-radius: var(--border-radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.08);
    background-color: rgba(0, 0, 0, 0.2);
    color: var(--color-text-primary);
    font-size: 14px;
}
.input-field input:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* --- MAIN SCREEN HEADER --- */
.app-header {
    height: 60px;
    padding: 0 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background-color: rgba(9, 6, 21, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 10;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}
.header-logo-placeholder {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    box-shadow: 0 0 10px var(--color-primary-glow);
}
.header-brand-name {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.3px;
}

.header-profile {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    background-color: rgba(255, 255, 255, 0.03);
    padding: 4px 8px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}
#user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid var(--color-primary);
    object-fit: cover;
}

/* --- BOTTOM NAVIGATION BAR --- */
.bottom-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: calc(64px + var(--safe-area-bottom));
    padding-bottom: var(--safe-area-bottom);
    background-color: rgba(9, 6, 21, 0.9);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: grid;
    /* Колонки подстраиваются под число кнопок: раньше стояло жёсткое
       repeat(4, 1fr), и пятая кнопка уезжала на второй ряд */
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    z-index: 10;
}

.nav-item {
    position: relative;
    background: none;
    border: none;
    color: var(--color-text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    transition: color var(--transition-speed) ease;
}

.nav-item.locked-item {
    opacity: 0.5;
}
.nav-item.locked-item:hover {
    color: var(--color-text-secondary);
}

.nav-lock-badge {
    position: absolute;
    top: 4px;
    right: 50%;
    transform: translateX(14px);
    width: 14px;
    height: 14px;
    background: #090615;
    border: 1px solid var(--color-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 8px var(--color-primary-glow);
    z-index: 2;
    pointer-events: none;
}

.nav-lock-badge svg {
    width: 8px;
    height: 8px;
    stroke: var(--color-primary);
}

.nav-icon {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

.nav-label {
    font-size: 11px;
    font-weight: 600;
    /* На узких экранах пять подписей должны помещаться в один ряд */
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 380px) {
    .nav-label { font-size: 10px; }
    .nav-icon { width: 19px; height: 19px; }
}

.nav-item:hover {
    color: var(--color-text-primary);
}

.nav-item.active {
    color: var(--color-primary);
}
.nav-item.active .nav-icon {
    filter: drop-shadow(0 0 6px var(--color-primary-glow));
}

/* --- HOME: BALANCE & MULTI-SUB TABS --- */
.balance-card {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.balance-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.balance-amount {
    font-size: 28px;
    font-weight: 800;
    margin-top: 4px;
}

.sub-tabs-container {
    margin-bottom: 16px;
}
.section-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--color-text-secondary);
    margin-bottom: 12px;
}

.tabs-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
    cursor: grab;
    user-select: none;
}
.tabs-row.active-drag {
    cursor: grabbing;
}
.tabs-row::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--color-text-secondary);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-speed) ease;
}
.tab-btn:hover {
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--color-text-primary);
}
.tab-btn.active {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
    color: #ffffff;
    box-shadow: 0 4px 10px var(--color-primary-glow);
}

/* Sub Details Card */
.sub-details-card {
    padding: 20px;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

/* Status Headers */
.sub-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.sub-title {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.3px;
}

.status-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.status-active {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--color-success);
    border: 1.5px solid rgba(16, 185, 129, 0.25);
}
.status-warning {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--color-warning);
    border: 1.5px solid rgba(245, 158, 11, 0.25);
}
.status-expired {
    background-color: rgba(239, 108, 108, 0.1);
    color: var(--color-danger);
    border: 1.5px solid rgba(239, 108, 108, 0.25);
}

/* Traffic Metric */
.traffic-metrics {
    margin-bottom: 20px;
}
.traffic-text-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
}
.traffic-used {
    font-weight: 700;
    color: var(--color-text-primary);
}

.progress-bar-container {
    height: 8px;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width var(--transition-speed) ease;
}
/* Dynamic progress bar color classes */
.progress-success { background: linear-gradient(90deg, var(--color-primary), #8b5cf6); }
.progress-warning { background-color: var(--color-warning); }
.progress-danger { background-color: var(--color-danger); }

/* Copy Link Block */
.copy-link-section {
    margin-bottom: 24px;
}
.copy-desc {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
}
.copy-btn-wrapper {
    display: flex;
    width: 100%;
}
.btn-copy-key {
    width: 100%;
    display: flex;
    gap: 8px;
}
.copy-icon {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Devices Section */
.devices-section {
    margin-top: 16px;
}
.devices-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text-secondary);
    margin-bottom: 12px;
}

.device-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.device-card {
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius-sm);
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.device-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.device-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background-color: rgba(168, 85, 247, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}
.device-icon-svg {
    width: 18px;
    height: 18px;
    stroke: var(--color-primary);
}

.device-details {
    display: flex;
    flex-direction: column;
}
.device-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-primary);
}
.device-platform {
    font-weight: 400;
    color: var(--color-text-secondary);
}

/* --- ПРЯМЫЕ КОНТАКТЫ И ЗЕРКАЛО --- */

.contacts-card {
    margin-top: 14px;
    padding: 16px 18px;
}

.contacts-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 12px;
}

.contact-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--color-card-border);
    border-radius: var(--border-radius-md);
    text-decoration: none;
    color: inherit;
    transition: all var(--transition-speed) ease;
}
.contact-row:hover {
    background: rgba(168, 85, 247, 0.1);
    border-color: rgba(168, 85, 247, 0.4);
}

.contact-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: var(--border-radius-sm);
    background: rgba(168, 85, 247, 0.12);
    color: var(--color-primary);
}
.contact-icon svg { width: 18px; height: 18px; }

.contact-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.contact-name { font-size: 13.5px; font-weight: 600; }

.contact-value {
    font-size: 12px;
    color: var(--color-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.contact-arrow {
    flex-shrink: 0;
    color: var(--color-text-muted);
    font-size: 15px;
}

.contacts-hint {
    margin-top: 8px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--color-text-secondary);
}

/* --- ЛЕНТА НОВОСТЕЙ --- */

.news-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.news-card {
    padding: 16px 18px;
}
.news-card.pinned {
    border-color: rgba(168, 85, 247, 0.4);
    background: rgba(168, 85, 247, 0.07);
}

.news-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.news-title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.35;
}

.news-pin { flex-shrink: 0; font-size: 13px; }

.news-date {
    display: block;
    margin-top: 4px;
    font-size: 11.5px;
    color: var(--color-text-muted);
}

.news-body {
    margin-top: 10px;
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--color-text-secondary);
    word-break: break-word;
}

/* Значок непрочитанного на кнопке навигации */
.nav-item { position: relative; }

.nav-badge {
    position: absolute;
    top: 2px;
    right: 50%;
    transform: translateX(20px);
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--color-primary);
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    color: #fff;
    box-shadow: 0 0 8px var(--color-primary-glow);
}
.nav-badge[hidden] { display: none; }

/* --- СТОИМОСТЬ ПОДПИСКИ --- */

.price-breakdown {
    display: block;
    margin-top: 3px;
    font-size: 11.5px;
    line-height: 1.45;
    color: var(--color-text-secondary);
}

.price-extra { color: var(--color-primary); font-weight: 600; }

/* --- ИЛЛЮСТРАЦИИ В ГАЙДАХ --- */

.guide-figure {
    margin: 14px 0 4px;
}

.happ-mock {
    display: block;
    width: 100%;
    height: auto;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--color-card-border);
}

.guide-figure figcaption {
    margin-top: 8px;
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--color-text-secondary);
}

/* --- ДОБАВЛЕНИЕ / УДАЛЕНИЕ УСТРОЙСТВ --- */

.device-card.pending-removal {
    border-color: rgba(245, 158, 11, 0.4);
    background: rgba(245, 158, 11, 0.06);
}

.btn-cancel-removal { color: var(--color-warning) !important; }

.add-device-panel {
    margin-top: 12px;
    padding: 16px;
    background: rgba(168, 85, 247, 0.06);
    border: 1px dashed rgba(168, 85, 247, 0.35);
    border-radius: var(--border-radius-md);
}
.add-device-panel.pending {
    background: rgba(245, 158, 11, 0.07);
    border-color: rgba(245, 158, 11, 0.4);
    border-style: solid;
}

.add-device-head {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 7px;
}

.add-device-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    border-radius: 50%;
    background: rgba(168, 85, 247, 0.18);
    font-size: 14px;
    line-height: 1;
}

.add-device-title { font-size: 14px; font-weight: 600; }

.add-device-text {
    font-size: 12.5px;
    line-height: 1.55;
    color: var(--color-text-secondary);
}
.add-device-text code {
    font-size: 11px;
    word-break: break-all;
    color: var(--color-text-muted);
}

.accent-price { color: var(--color-primary); }

.add-device-btn {
    width: 100%;
    margin-top: 12px;
    padding: 11px 18px;
}

.removal-error-panel {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 12px;
    padding: 14px 16px;
    background: rgba(239, 68, 68, 0.07);
    border: 1px solid rgba(239, 68, 68, 0.32);
    border-radius: var(--border-radius-md);
}
.removal-error-panel .add-device-icon { background: rgba(239, 68, 68, 0.18); }

.device-ip {
    font-size: 11px;
    color: var(--color-text-secondary);
    margin-top: 2px;
}

.btn-delete-device {
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    transition: all var(--transition-speed) ease;
}
.btn-delete-device:hover {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--color-danger);
}

.device-card.empty-slot {
    border-style: dashed;
    border-color: rgba(255, 255, 255, 0.06);
    background-color: transparent;
    opacity: 0.5;
}
.device-card.empty-slot .device-avatar {
    background-color: rgba(255, 255, 255, 0.02);
}
.device-card.empty-slot .device-icon-svg {
    stroke: var(--color-text-muted);
}
.device-card.empty-slot .device-name {
    color: var(--color-text-secondary);
    font-weight: 500;
}

/* Referral Banner bottom */
.referral-banner {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, rgba(20, 10, 35, 0.45) 0%, rgba(99, 102, 241, 0.08) 100%);
}
.ref-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 2px;
}
.ref-text {
    font-size: 11px;
    color: var(--color-text-secondary);
    max-width: 220px;
}

/* --- 2. INSTRUCTIONS VIEW --- */
.page-title {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.4px;
    margin-bottom: 16px;
}

.alert-box {
    display: flex;
    gap: 12px;
    padding: 16px;
    border-radius: var(--border-radius-md);
    margin-bottom: 20px;
}
.warning-alert {
    background-color: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.15);
}
.alert-icon {
    font-size: 18px;
}
.alert-text {
    font-size: 12px;
    line-height: 1.6;
    color: var(--color-warning);
}

.accordion-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
}

.accordion-item {
    border-radius: var(--border-radius-sm);
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    overflow: hidden;
    transition: border-color var(--transition-speed) ease;
}
.accordion-item.active {
    border-color: rgba(168, 85, 247, 0.25);
}

.accordion-trigger {
    width: 100%;
    padding: 14px 16px;
    background: none;
    border: none;
    color: var(--color-text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    text-align: left;
}

.step-num {
    display: flex;
    width: 22px;
    height: 22px;
    background-color: var(--color-primary);
    color: #ffffff;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    flex-shrink: 0;
}
.step-icon {
    font-size: 16px;
    margin-right: 12px;
    flex-shrink: 0;
}

.trigger-text {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
}

.arrow-icon {
    font-size: 9px;
    color: var(--color-text-muted);
    transition: transform var(--transition-speed) ease;
}
.accordion-item.active .arrow-icon {
    transform: rotate(180deg);
    color: var(--color-primary);
}

.accordion-content {
    display: none;
    padding: 0 16px 16px 50px;
    font-size: 13px;
    color: var(--color-text-secondary);
    line-height: 1.6;
    border-top: 1px solid rgba(255, 255, 255, 0.02);
}
.accordion-item.active .accordion-content {
    display: block;
}

.step-list {
    list-style-position: inside;
}
.step-list li {
    margin-top: 6px;
}
.step-list li strong {
    color: var(--color-text-primary);
}

.info-block {
    margin-top: 10px;
    padding: 10px 12px;
    background-color: rgba(255, 255, 255, 0.02);
    border-left: 3px solid var(--color-primary);
    font-size: 11px;
}

.warning-text {
    color: var(--color-danger);
    font-weight: 600;
}

.final-acknowledgement {
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-primary);
    padding: 16px 0;
}

/* --- 3. SUPPORT VIEW --- */
.support-subtitle {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin-bottom: 20px;
}

.faq-links {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
}

.faq-item {
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
}
.faq-item:hover {
    border-color: rgba(168, 85, 247, 0.3);
    transform: translateX(2px);
}

.faq-number {
    display: flex;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background-color: rgba(168, 85, 247, 0.1);
    color: var(--color-primary);
    font-size: 12px;
    font-weight: 700;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
}

.faq-title {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
}
.faq-arrow {
    color: var(--color-text-muted);
}

.support-action-card {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    background: linear-gradient(135deg, rgba(20, 10, 35, 0.45) 0%, rgba(168, 85, 247, 0.05) 100%);
}

.support-banner-pic {
    width: 60px;
    height: 60px;
    background-color: rgba(168, 85, 247, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.agent-icon {
    width: 32px;
    height: 32px;
}

.support-banner-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.banner-title {
    font-size: 16px;
    font-weight: 700;
}
.banner-text {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
}

/* --- 4. SETTINGS VIEW --- */
.settings-group {
    padding: 16px;
    margin-bottom: 20px;
}
.group-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--color-text-muted);
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    cursor: pointer;
}
.settings-row:not(:last-child) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.row-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.row-icon {
    font-size: 18px;
}
.row-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-primary);
}
.row-details {
    display: flex;
    flex-direction: column;
}
.row-status {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 2px;
}
.row-arrow {
    color: var(--color-text-muted);
}

.settings-row.disabled, .settings-row.locked-item {
    opacity: 0.55;
    cursor: not-allowed;
}

.row-lock-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(168, 85, 247, 0.1);
    border: 1px solid rgba(168, 85, 247, 0.3);
    box-shadow: 0 0 8px var(--color-primary-glow);
}

.row-action-link {
    font-size: 12px;
    font-weight: 700;
    color: var(--color-primary);
}
.mini-badge {
    font-size: 8px;
    font-weight: 700;
    background-color: var(--color-primary);
    color: #ffffff;
    padding: 1px 4px;
    border-radius: 3px;
    margin-left: 2px;
}

.row-verified-badge {
    display: flex;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--color-success);
    border: 1px solid rgba(16, 185, 129, 0.3);
    font-size: 10px;
    font-weight: 700;
    align-items: center;
    justify-content: center;
}

.settings-actions {
    margin-top: 32px;
}
.settings-actions button {
    width: 100%;
}

/* --- OVERLAY: SUPPORT CHAT --- */
.chat-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 100;
    display: none; /* Controlled by JS */
    justify-content: flex-end;
    flex-direction: column;
}

.chat-window {
    width: 100%;
    height: 80%;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: var(--border-radius-lg);
    border-top-right-radius: var(--border-radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.chat-header {
    height: 60px;
    padding: 0 16px;
    background-color: rgba(20, 10, 35, 0.7);
    border-bottom: 1px solid var(--color-card-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.active-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--color-success);
    box-shadow: 0 0 8px var(--color-success);
}
.chat-title {
    font-size: 14px;
    font-weight: 700;
}
.chat-status {
    font-size: 11px;
    color: var(--color-text-secondary);
}

.close-chat-btn {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    font-size: 28px;
    cursor: pointer;
    padding: 0 10px;
}
.close-chat-btn:hover {
    color: var(--color-text-primary);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background-color: rgba(0, 0, 0, 0.2);
}

.chat-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: var(--border-radius-md);
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
    animation: bubblePop 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes bubblePop {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.bubble-user {
    align-self: flex-end;
    background-color: var(--color-primary);
    color: #ffffff;
    border-bottom-right-radius: 2px;
}

.bubble-admin {
    align-self: flex-start;
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--color-text-primary);
    border-bottom-left-radius: 2px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-input-area {
    height: 60px;
    padding: 10px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    gap: 10px;
    align-items: center;
}
.chat-input-area input {
    flex: 1;
    height: 100%;
    border-radius: 20px;
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--color-text-primary);
    padding: 0 16px;
    font-size: 13px;
}
.chat-input-area input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.send-message-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--color-primary);
    border: none;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.send-message-btn:hover {
    background-color: var(--color-primary-hover);
}
.send-message-btn svg {
    width: 16px;
    height: 16px;
    transform: translate(1px, -1px);
}

/* --- OVERLAY: CONFIRMATION DIALOG --- */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Без этого правила JS вешал класс .active, а окно оставалось display:none —
   кнопки «Удалить» и «Запросить слот» отрабатывали вхолостую и выглядели
   мёртвыми. flex здесь обязателен: align-items/justify-content выше
   рассчитаны на flex-контейнер. */
.modal-overlay.active {
    display: flex;
}

.modal-window {
    width: 100%;
    max-width: 320px;
    padding: 24px;
    animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modalPop {
    from { transform: scale(0.9) translateY(10px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
}
.modal-body {
    font-size: 12px;
    color: var(--color-text-secondary);
    line-height: 1.6;
    margin-bottom: 20px;
}

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

/* --- TOAST NOTIFICATIONS --- */
.toast-container {
    position: absolute;
    bottom: 84px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background-color: rgba(168, 85, 247, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff;
    padding: 10px 18px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 300;
    white-space: nowrap;
}
.toast-container.active {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
