.page {
    display: none !important; /* Прячем */
    width: 100%;
    position: relative;
}

/* Это вспомогательный класс, который мы будем вешать через JS */
.page.show {
    display: block !important; /* Показываем */
}
:root {
    --bg-color: #0d1b36;
    --card-bg: #112646;
    --border-color: #1a2b44;
    --accent-color: #4a90e2;
    --text-main: #e6edf3;
    --text-gray: #7d8590;
    --up-color: #00ff88;
    --down-color: #ff4d4d;
    --font-main: 'Inter', sans-serif;
    --input-height: 42px;
}

/* Глобальные правки для стабильности */
html {
    scrollbar-gutter: stable;
    overflow-y: scroll;
}

body { 
    background-color: var(--bg-color); 
    color: var(--text-main); 
    font-family: var(--font-main);
    margin: 0; 
    overflow-x: hidden; 
}
/* --- РИСОВАННЫЙ ПАТТЕРН НА ФОНЕ --- */
body::before {
    content: "";
    position: fixed; /* Приклеиваем к экрану, чтобы при скролле фон стоял на месте */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('bg-pattern.png'); /* Укажи точное имя своего файла */
    background-repeat: repeat; /* Если картинка небольшая, она размножится как узор */
    background-size: 500px; /* Размер элементов (можешь увеличить или уменьшить) */
    opacity: 0.1; /* ТА САМАЯ ПРОЗРАЧНОСТЬ 3% (меняй от 0.01 до 0.1) */
    pointer-events: none; /* ОЧЕНЬ ВАЖНО: чтобы фон пропускал сквозь себя клики мышки */
    z-index: 0; /* Кладем на самое дно */
}

/* --- ЛОАДЕР --- */
#loader-wrapper {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: #0d1b36; display: flex; justify-content: center; align-items: center;
    z-index: 999999; transition: opacity 0.6s ease;
}
.loader-content { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.growth-chart { display: flex; align-items: flex-end; justify-content: center; gap: 14px; height: 60px; position: relative; width: 120px; }
.bar { width: 12px; height: 0; border-radius: 2px; animation: growBar 0.4s ease-out forwards; animation-delay: var(--d); opacity: 0; }
.bar.green { background: var(--up-color); box-shadow: 0 0 15px rgba(0, 255, 136, 0.5); }
.bar.red { background: var(--down-color); box-shadow: 0 0 15px rgba(255, 77, 77, 0.5); }
@keyframes growBar { to { height: var(--h); opacity: 1; } }
.trend-svg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 20; pointer-events: none; }
.trend-path { fill: none; stroke: white; stroke-width: 2.5; stroke-dasharray: 300; stroke-dashoffset: 300; animation: drawTrendPath 1.6s linear forwards; }
@keyframes drawTrendPath { to { stroke-dashoffset: 0; } }
.loader-logo-animated { color: white; font-size: 2.5rem; font-weight: 800; display: flex; justify-content: center; }
.word-combined { display: flex; gap: 0; letter-spacing: -2px; }
.loader-logo-animated span { display: inline-block; opacity: 0; animation: lightUp 0.3s ease forwards; animation-delay: var(--d); }
.loader-logo-animated .accent, .header-logo .accent { color: var(--accent-color); }
@keyframes lightUp { from { transform: translateY(5px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* --- ИНТЕРФЕЙС (ХЕДЕР) --- */
.top-header { 
    padding: 15px 40px; 
    background: var(--card-bg); 
    border-bottom: 1px solid var(--border-color); 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    position: relative; 
    z-index: 10; 
}
.header-logo { 
    font-weight: 800; 
    text-transform: uppercase; 
    font-size: 1.1rem; 
    letter-spacing: -1.2px; 
    color: white; 
    display: flex; 
    align-items: center; 
    user-select: none; 
    cursor: pointer; 
}
.user-trigger { cursor: pointer; display: flex; align-items: center; gap: 10px; color: var(--text-main); }
/* --- КОНТЕЙНЕР И НАВИГАЦИЯ --- */
.container { width: 95%; max-width: 1200px; margin: 0 auto; padding-bottom: 50px; }
.pages-container { position: relative; min-height: 600px; width: 100%; }
.nav-bar { display: flex; justify-content: center; gap: 40px; margin: 30px 0; }
.nav-item { cursor: pointer; color: var(--text-gray); display: flex; flex-direction: column; align-items: center; transition: 0.3s; }
.nav-item.active .nav-icon { background: var(--accent-color); color: white; box-shadow: 0 0 15px rgba(74, 144, 226, 0.4); }
.nav-icon { width: 50px; height: 50px; background: var(--card-bg); border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 1px solid var(--border-color); margin-bottom: 8px; font-size: 1.2rem; }

.main-board { background: var(--card-bg); border-radius: 12px; border: 1px solid var(--border-color); overflow: hidden; margin-bottom: 20px; }
.board-title { padding: 15px; text-align: center; font-weight: 800; color: var(--accent-color); border-bottom: 1px solid var(--border-color); text-transform: uppercase; font-size: 0.8rem; }

/* --- ГЛАВНАЯ: СЕТКА МОНЕТ --- */
.market-grid { 
    display: grid !important; 
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important; 
    width: 100% !important; 
    gap: 0 !important; 
    border-top: 1px solid var(--border-color); 
    border-left: 1px solid var(--border-color); 
    box-sizing: border-box !important; 
}

.market-item { 
    padding: 20px !important; 
    border-right: 1px solid var(--border-color) !important; 
    border-bottom: 1px solid var(--border-color) !important; 
    height: 110px !important; 
    display: flex !important; 
    flex-direction: column !important; 
    justify-content: space-between !important; 
    cursor: pointer; 
    transition: 0.2s; 
    box-sizing: border-box !important; 
    background: transparent; 
    overflow: hidden !important;
}
.market-item:hover { background: rgba(255,255,255,0.03); }
.market-item span:first-child { color: var(--text-gray); font-size: 0.75rem; font-weight: 800; text-transform: uppercase; display: block; }
.market-item div { display: flex !important; justify-content: space-between !important; align-items: flex-end !important; width: 100% !important; }
.market-item div span[id^="p-"] { font-size: 1.3rem; font-weight: 700; color: var(--text-main); }

/* --- ПОЛЯ ВВОДА --- */
.field { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.field label { font-size: 0.7rem; color: var(--text-gray); font-weight: 800; text-transform: uppercase; }
.field input, .side-selector, .btn-add { height: var(--input-height) !important; border-radius: 6px; box-sizing: border-box; font-size: 0.9rem; }
.field input { background: #081225; border: 1px solid var(--border-color); padding: 0 12px; color: white; outline: none; }
.field input:focus { border-color: var(--accent-color); }
.btn-add { background: var(--accent-color); color: white; border: none; font-weight: 800; cursor: pointer; text-transform: uppercase; transition: 0.2s; }

/* --- ТАБЛИЦЫ --- */
table { 
    table-layout: fixed !important; 
    width: 100% !important; 
    border-collapse: collapse; 
}
th, td { 
    padding: 14px 10px; 
    border-bottom: 1px solid var(--border-color); 
    overflow: hidden; 
    text-overflow: ellipsis; 
    white-space: nowrap;
    box-sizing: border-box;
    vertical-align: middle;
    text-align: left;
}
th { color: var(--text-gray); font-size: 0.7rem; text-transform: uppercase; font-weight: 800; }
th:first-child, td:first-child { padding-left: 25px !important; }

#futures-history-list tr th:nth-child(1), #futures-history-list tr td:nth-child(1) { width: 18%; }
#futures-history-list tr th:nth-child(2), #futures-history-list tr td:nth-child(2) { width: 15%; }
#futures-history-list tr th:nth-child(3), #futures-history-list tr td:nth-child(3) { width: 12%; }
#futures-history-list tr th:nth-child(4), #futures-history-list tr td:nth-child(4) { width: 18%; }
#futures-history-list tr th:nth-child(5), #futures-history-list tr td:nth-child(5) { width: 17%; }
#futures-history-list tr th:nth-child(6), #futures-history-list tr td:nth-child(6) { width: 20%; padding-right: 25px !important; }

#active-futures-list tr th:nth-child(1), #active-futures-list tr td:nth-child(1) { width: 20%; }
#active-futures-list tr th:nth-child(2), #active-futures-list tr td:nth-child(2) { width: 15%; }
#active-futures-list tr th:nth-child(3), #active-futures-list tr td:nth-child(3) { width: 18%; }
#active-futures-list tr th:nth-child(4), #active-futures-list tr td:nth-child(4) { width: 15%; }
#active-futures-list tr th:nth-child(5), #active-futures-list tr td:nth-child(5) { width: 17%; }
#active-futures-list tr th:nth-child(6), #active-futures-list tr td:nth-child(6) { width: 15%; text-align: right; padding-right: 25px !important; }

/* --- ОСТАЛЬНЫЕ СТИЛИ --- */
.spot-top-info { display: flex; gap: 20px; margin-bottom: 20px; align-items: stretch; flex-wrap: wrap; }
.pnl-card { flex: 1; display: flex; flex-direction: column; padding: 20px; background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 12px; min-width: 200px; justify-content: center; align-items: center; text-align: center; }
.pnl-card .label { font-size: 0.85rem; color: var(--text-gray); font-weight: 800; text-transform: uppercase; margin-bottom: 8px; }
.pnl-value { font-size: 2.2rem; font-weight: 900; letter-spacing: -1px; }
.spot-inputs { flex: 3; display: grid; grid-template-columns: repeat(4, 1fr) !important; gap: 15px; background: var(--card-bg); padding: 20px; border-radius: 12px; border: 1px solid var(--border-color); align-items: flex-end; }

.futures-inputs-grid { display: grid !important; grid-template-columns: repeat(4, 1fr) !important; gap: 15px; padding: 20px; align-items: flex-end; }
.side-selector { display: flex; background: #081225; border: 1px solid var(--border-color); overflow: hidden; }
.side-btn { flex: 1; border: none; background: transparent; color: var(--text-gray); cursor: pointer; font-weight: 800; font-size: 0.7rem; height: 100%; }
.side-btn.long.active { background: var(--up-color); color: #0d1b36; }
.side-btn.short.active { background: var(--down-color); color: white; }

.up { color: var(--up-color); }
.down { color: var(--down-color); }
@keyframes flashGreenText { 0% { color: var(--up-color); text-shadow: 0 0 8px var(--up-color); } 100% { color: var(--text-main); } }
@keyframes flashRedText { 0% { color: var(--down-color); text-shadow: 0 0 8px var(--down-color); } 100% { color: var(--text-main); } }
.flash-up-text { animation: flashGreenText 0.8s ease-out; }
.flash-down-text { animation: flashRedText 0.8s ease-out; }

.active-page { display: block !important; animation: fadeIn 0.2s ease-in-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: translateY(0); } }

.dropdown-menu { position: absolute; top: 60px; right: 40px; background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 8px; width: 200px; display: none; flex-direction: column; padding: 8px 0; z-index: 1000; box-shadow: 0 10px 25px rgba(0,0,0,0.5); }
.dropdown-menu a { display: flex; align-items: center; gap: 12px; padding: 12px 20px; color: var(--text-main); text-decoration: none; font-size: 0.85rem; font-weight: 600; transition: 0.2s; }
.dropdown-menu a:hover { background: rgba(74, 144, 226, 0.1); color: var(--accent-color); }

.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(5px); z-index: 2000; justify-content: center; align-items: center; }
.modal-content { background: var(--card-bg); padding: 30px; border-radius: 15px; border: 1px solid var(--border-color); width: 90%; max-width: 400px; }

#chart-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(8, 18, 37, 0.98); z-index: 10000; display: none; flex-direction: column; }
#chart-container { flex: 1; width: 100%; height: 100%; background: transparent; }
.close-btn.t-btn-close { position: absolute; top: 20px; right: 20px; background: var(--down-color); color: white; border: none; padding: 10px 20px; border-radius: 6px; font-weight: 800; cursor: pointer; z-index: 10001; }

.dropdown-menu a.t-clear-opt { color: var(--down-color) !important; border-top: 1px solid var(--border-color); margin-top: 5px; }

#login-screen { background-color: #0d1b36 !important; color: white !important; }
#login-screen button.google-btn { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; border: none; cursor: pointer; transition: background 0.3s ease; }
#login-screen button.google-btn svg { display: block; width: 20px; height: 20px; filter: brightness(0) invert(1); }

.lang-btn { background: #1a2b44; color: white; border: 1px solid #2d4263; padding: 8px 16px; border-radius: 8px; cursor: pointer; font-family: 'Inter', sans-serif; font-weight: 600; transition: 0.3s; }
.lang-btn.active { background: #4a90e2; box-shadow: 0 0 15px rgba(74, 144, 226, 0.4); }

.spot-table { width: 100%; border-collapse: collapse; margin-top: 20px; background: #112646; border-radius: 12px; overflow: hidden; }
.spot-table th { background: #162d50; color: #7d8590; text-align: left; padding: 15px 12px; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1px; }

.time-btn-card.active { background: rgba(74, 144, 226, 0.15) !important; border-bottom: 2px solid #4a90e2 !important; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(8, 18, 37, 0.85); z-index: 100000; display: flex; justify-content: center; align-items: center; }
.modal-content { animation: slideInModal 0.2s ease; pointer-events: auto !important; }

@keyframes slideInModal { from { transform: translateY(-30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#futures .spot-table { table-layout: auto !important; }

@media (max-width: 1400px) { #futures > div { grid-template-columns: 1.2fr 1fr !important; gap: 15px !important; } }

/* --- СПИДОМЕТР --- */
.gauge-container { position: relative; width: 160px; height: 80px; overflow: hidden; }
.gauge-arc { position: absolute; top: 0; left: 0; width: 160px; height: 160px; border-radius: 50%; background: conic-gradient(from 270deg, #ff3b30 0deg, #ff9500 45deg, #ffcc00 90deg, #00c076 135deg, #00ff88 180deg, transparent 180deg); }
.gauge-cover { position: absolute; top: 15px; left: 15px; width: 130px; height: 130px; background: var(--card-bg, #112646); border-radius: 50%; display: flex; justify-content: center; padding-top: 25px; box-sizing: border-box; }
.gauge-value { font-size: 2rem; font-weight: 900; color: white; line-height: 1; }
.gauge-needle { position: absolute; bottom: 0; left: 50%; width: 4px; height: 60px; background: #ffffff; border-radius: 2px; transform-origin: bottom center; transform: translateX(-50%) rotate(-90deg); transition: transform 1.5s cubic-bezier(0.22, 1, 0.36, 1); z-index: 10; }
.gauge-needle::after { content: ''; position: absolute; bottom: -5px; left: -3px; width: 10px; height: 10px; background: #ffffff; border-radius: 50%; }

/* ========================================================= */
/* === ГЛОБАЛЬНЫЙ ФИКС АДАПТИВНОСТИ (MAC И МОБИЛКИ) ======== */
/* ========================================================= */

/* --- 1. ФИКС ДЛЯ MACBOOK --- */
#login-screen {
    overflow-y: auto !important;
    align-items: stretch !important; 
}
.login-left, .login-right {
    min-height: 100vh !important; 
    box-sizing: border-box !important;
}
@media (max-height: 1000px) and (min-width: 769px) {
    .login-left { padding: 20px 4% !important; justify-content: center !important; }
    .login-left h1 { font-size: 3.5rem !important; }
    .login-left p { margin-bottom: 20px !important; }
    .login-right { padding: 20px !important; }
    #login-form-box, #register-form-box { padding: 30px !important; margin: 0 auto !important; }
}

/* ========================================================= */
/* === АНИМАЦИЯ ПОЛЬЗОВАТЕЛЬСКОГО ПАТТЕРНА НА ВХОДЕ ======== */
/* ========================================================= */
.animated-user-pattern {
    position: absolute;
    inset: 0;
    background-image: url('bg-pattern.png');
    background-repeat: repeat;
    background-size: 350px; /* Делаем размер иконок аккуратным */
    opacity: 0.12; /* Легкая прозрачность, чтобы не мешало читать текст */
    z-index: 1; /* Кладем под основной текст */
    pointer-events: none; /* Чтобы картинка не перехватывала клики мышки */
    
    /* Магия оживления: запускаем бесконечный скролл */
    animation: scrollUserPattern 50s linear infinite;
}

@keyframes scrollUserPattern {
    0% {
        background-position: 0px 0px;
    }
    100% {
        /* Смещаем ровно на один размер паттерна (350px), 
           чтобы цикл был абсолютно бесшовным */
        background-position: 350px -350px; 
    }
}

/* --- 2. АВТОМАТИЧЕСКАЯ РЕЗИНОВАЯ АДАПТАЦИЯ ДЛЯ ТЕЛЕФОНОВ --- */
@media (max-width: 768px) {
    
    /* ИСПРАВЛЕНО: убрали display: block !important, чтобы скрипт мог скрыть окно */
    #login-screen {
        flex-direction: column !important;
        justify-content: flex-start !important; /* Начинаем сверху, чтобы не обрезало заголовок */
        position: fixed !important;
        inset: 0 !important;
        overflow-y: auto !important;
        background: var(--bg-color) !important;
        -webkit-overflow-scrolling: touch;
    }
    
    .login-left {
        justify-content: flex-start !important; /* Убиваем центрирование, которое ломало скролл */
        min-height: auto !important;
        padding: 50px 20px 20px 20px !important;
        text-align: center;
    }
    
    .login-right {
        justify-content: flex-start !important;
        min-height: auto !important;
        padding: 10px 20px 50px 20px !important;
        background: transparent !important;
    }
    
    #login-form-box, #register-form-box {
        width: 95% !important;
        max-width: 100% !important;
        padding: 25px 20px !important;
        margin: 0 auto !important;
    }

    /* Убиваем жесткие 3 колонки дашборда из HTML и ставим их в стопку */
    #market > div, 
    #futures > div > div:nth-child(2),
    .detail-grid,
    .spot-top-info > div {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
    }

    /* Инпуты ввода на фьючерсах (делаем по 2 в ряд вместо 4) */
    .futures-inputs-grid {
        grid-template-columns: 1fr 1fr !important;
    }
    
    /* Калькулятор риска (5 полей в ряд на телефоне не влезут, делаем сетку) */
    .f-side-col .main-board > div:nth-child(2) {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
    }

    /* Сетка монет */
    .market-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) !important;
        gap: 10px !important;
    }

    /* Таблицы */
    .main-board {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    table {
        min-width: 600px !important;
    }
}