/* БАЗОВЫЕ ПЕРЕМЕННЫЕ */
:root {
    color-scheme: dark; /* Делает скроллбары и формы темными по умолчанию */
    --bg-main: #0b0e11;
    --bg-card: #181a20;
    --bg-hover: #2b3139;
    --border: #2b3139;
    --text-main: #eaecef;
    --text-muted: #848e9c;
    --text-highlight: #ffffff;

    --green: #0ecb81;
    --green-bg: rgba(14, 203, 129, 0.15);
    --red: #f6465d;
    --red-bg: rgba(246, 70, 93, 0.15);
    --blue: #2962ff;
    --blue-hover: #1e4bd8;
    --yellow: #fcd535;

    --radius: 8px;
    --shadow: 0 4px 12px rgba(0,0,0,0.2);
    --transition: 0.2s ease;
}

/* ИДЕАЛЬНАЯ СВЕТЛАЯ ТЕМА */
body.light-theme {
    color-scheme: light;
    --bg-main: #e2e8f0; /* Более глубокий серый фон, чтобы карточки выделялись */
    --bg-card: #ffffff; /* Чисто белые карточки */
    --bg-hover: #f1f5f9;
    --border: #cbd5e1; /* Четкие видимые границы */
    --text-main: #0f172a; /* Насыщенный темный текст */
    --text-muted: #64748b;
    --text-highlight: #0f172a;
    --shadow: 0 4px 15px rgba(0,0,0,0.08); /* Выразительная тень под блоками */
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', -apple-system, sans-serif; }
body { background-color: var(--bg-main); color: var(--text-main); font-size: 14px; line-height: 1.5; min-height: 100vh; display: flex; flex-direction: column; }

/* ЗАГОЛОВКИ И ОТСТУПЫ */
.page-title { margin-bottom: 25px; font-size: 24px; font-weight: 600; }
.section-title { margin-top: 40px; margin-bottom: 20px; font-size: 18px; font-weight: 600; }
.text-highlight { color: var(--text-highlight); font-weight: 600; }

.page { display: none; padding: 20px 0 40px 0; }
.page.active { display: block; animation: fadeIn 0.3s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* КОНТЕЙНЕРЫ */
.app-container { max-width: 1200px; margin: 0 auto; padding: 0 20px; flex: 1; width: 100%; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }

/* НАВИГАЦИЯ */
nav { background-color: var(--bg-card); border-bottom: 1px solid var(--border); padding: 0 20px; height: 64px; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 1000; box-shadow: var(--shadow); }
.nav-left, .nav-right { display: flex; align-items: center; gap: 20px; }
.logo { font-size: 20px; font-weight: 700; cursor: pointer; letter-spacing: -0.5px; }
.nav-links { display: flex; gap: 10px; }
.nav-btn { background: none; border: none; color: var(--text-muted); font-size: 15px; font-weight: 500; cursor: pointer; padding: 8px 12px; border-radius: var(--radius); transition: var(--transition); }
.nav-btn:hover { color: var(--text-main); background: var(--bg-hover); }
.nav-btn.active { color: var(--text-main); font-weight: 600; background: var(--bg-hover); }
.hamburger { display: none; font-size: 24px; cursor: pointer; color: var(--text-main); }

/* ФОРМЫ, ИНПУТЫ И СТАНДАРТНЫЙ SELECT (Для депозитов) */
.input-group { margin-bottom: 16px; }
.input-group label { display: block; margin-bottom: 8px; font-size: 13px; color: var(--text-muted); font-weight: 500; }
input { width: 100%; background: var(--bg-main); color: var(--text-main); border: 1px solid var(--border); padding: 12px; border-radius: var(--radius); font-size: 14px; outline: none; transition: var(--transition); }
input:focus { border-color: var(--blue); }

select.custom-select {
    width: 100%; background-color: var(--bg-main); color: var(--text-main); border: 1px solid var(--border);
    padding: 12px 35px 12px 12px; border-radius: var(--radius); font-size: 14px; outline: none;
    cursor: pointer; transition: var(--transition);
    -webkit-appearance: none; -moz-appearance: none; appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23848e9c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
select.custom-select:focus { border-color: var(--blue); }
.form-row { display: flex; gap: 10px; }
.search-input { width: 250px; padding: 10px 15px; border-radius: 20px; }

/* КНОПКИ */
button { font-family: 'Inter', sans-serif; cursor: pointer; border-radius: var(--radius); transition: var(--transition); border: none; font-weight: 600; }
.btn-primary { background: var(--blue); color: #fff; padding: 12px 20px; }
.btn-primary:hover { background: var(--blue-hover); }
.btn-secondary { background: var(--bg-hover); color: var(--text-main); padding: 12px 20px; }
.btn-secondary:hover { background: var(--border); }
.full-width { width: 100%; }
.small { padding: 6px 12px; font-size: 12px; }
.btn-logout { background: transparent; color: var(--red); border: 1px solid var(--red-bg); padding: 8px 16px; border-radius: var(--radius); }
.btn-logout:hover { background: var(--red-bg); }

.icon-btn {
    background: var(--bg-hover); color: var(--text-main);
    border-radius: 50%; width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; padding: 0; flex-shrink: 0; border: none;
}
.btn-back-icon { background: none; color: var(--text-muted); font-size: 24px; margin-right: 15px; padding: 0; }

/* === ИСТИННО ПРЕМИАЛЬНЫЕ ВЫПАДАЮЩИЕ МЕНЮ (Замена топорному Select) === */
.custom-dd { position: relative; user-select: none; }
.custom-dd .dd-btn {
    background: var(--bg-main); border: 1px solid var(--border);
    padding: 10px 15px; border-radius: var(--radius); color: var(--text-main);
    display: flex; justify-content: space-between; align-items: center;
    cursor: pointer; font-size: 14px; transition: var(--transition); font-weight: 500;
}
.custom-dd .dd-btn:hover { border-color: var(--blue); }
.custom-dd .dd-arrow { font-size: 10px; color: var(--text-muted); transition: transform 0.2s; margin-left: 10px; }
.custom-dd.active .dd-arrow { transform: rotate(180deg); }
.custom-dd .dd-menu {
    position: absolute; top: calc(100% + 5px); left: 0; right: 0;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    z-index: 1000; display: none; flex-direction: column; overflow: hidden;
}
.custom-dd .dd-menu.show { display: flex; animation: fadeIn 0.15s ease; }
.custom-dd .dd-item { padding: 12px 15px; cursor: pointer; color: var(--text-main); font-size: 14px; transition: background 0.15s; }
.custom-dd .dd-item:hover { background: var(--bg-hover); color: var(--blue); }
.small-dd .dd-btn { padding: 8px 12px; font-size: 13px; }

/* КАРТОЧКИ */
.form-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 30px; max-width: 450px; margin: 0 auto; box-shadow: var(--shadow); }
.legal-card { max-width: 800px; margin: 0 auto; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 40px; box-shadow: var(--shadow); }
.auth-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 40px; max-width: 400px; margin: 60px auto; box-shadow: var(--shadow); text-align: center; }
.auth-card h2 { margin-bottom: 25px; font-size: 24px; }
.auth-toggle { margin-top: 20px; color: var(--blue); font-size: 13px; cursor: pointer; }

/* РЫНКИ */
.tabs { display: flex; gap: 10px; margin-bottom: 25px; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.cat-btn { background: transparent; color: var(--text-muted); padding: 8px 16px; font-size: 14px; }
.cat-btn.active { color: var(--text-main); background: var(--bg-hover); }
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 15px; }
.coin-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; transition: var(--transition); box-shadow: var(--shadow); }
.coin-card:hover { border-color: var(--blue); transform: translateY(-2px); }

/* ТЕРМИНАЛ */
.terminal-header { display: flex; align-items: center; margin-bottom: 20px; }
.terminal-grid { display: flex; gap: 20px; height: calc(100vh - 160px); min-height: 600px; }
.tv-box { flex: 1; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.orderbook-box { width: 280px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; padding: 10px 0; box-shadow: var(--shadow); }
.order-box { width: 320px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 25px 20px; overflow-y: auto; box-shadow: var(--shadow); }

/* СТАКАН */
.ob-header { display: flex; justify-content: space-between; padding: 0 15px 10px; font-size: 12px; color: var(--text-muted); font-weight: 500; }
.ob-list { flex: 1; display: flex; flex-direction: column; overflow: hidden; font-family: monospace; font-size: 13px; }
.ob-row { display: flex; justify-content: space-between; padding: 3px 15px; position: relative; cursor: pointer; }
.ob-row:hover { background: var(--bg-hover); }
.ob-divider { text-align: center; padding: 10px; font-weight: bold; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin: 5px 0; }
.btn-submit-order { background: var(--green); color: #fff; width: 100%; padding: 14px; font-size: 16px; margin-top: 15px; }
.btn-submit-order.sell { background: var(--red); }

/* ТАБЛИЦЫ */
.table-container { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; margin-bottom: 25px; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { color: var(--text-muted); font-weight: 500; font-size: 13px; padding: 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 16px; border-bottom: 1px solid var(--border); font-size: 14px; color: var(--text-main); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-hover); }
.empty-state-row td { text-align: center; padding: 40px; color: var(--text-muted); }
.btn-action { background: var(--bg-hover); color: var(--text-main); padding: 6px 12px; font-size: 12px; }

/* БАЛАНСЫ, КОШЕЛЕК И ПРОФИЛЬ */
.balance-card { background: linear-gradient(135deg, var(--bg-card), var(--bg-main)); border: 1px solid var(--border); border-radius: var(--radius); padding: 35px 30px; position: relative; overflow: hidden; margin-bottom: 40px; box-shadow: var(--shadow); }
.bc-label { color: var(--text-muted); font-size: 14px; margin-bottom: 12px; font-weight: 500; }
.bc-amount { font-size: 42px; font-weight: 700; color: var(--text-main); margin-bottom: 12px; letter-spacing: -1px; }
.bc-sub { font-size: 14px; color: var(--text-muted); margin-bottom: 25px; }
.bc-actions { display: flex; gap: 15px; }

.profile-header-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 30px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 20px; box-shadow: var(--shadow); }
.ph-avatar { width: 64px; height: 64px; background: var(--bg-hover); border-radius: 50%; display: flex; align-items: center; justify-content: center; overflow: hidden; border: 1px solid var(--border); }
.ph-info { flex: 1; }
.ph-name-row { display: flex; align-items: center; gap: 10px; margin-bottom: 5px; }
.kyc-badge { display: inline-block; padding: 5px 12px; background: var(--bg-hover); border-radius: 4px; font-size: 12px; font-weight: 500; }

.stats-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 30px; margin-top: 20px; box-shadow: var(--shadow); }
.stats-header { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 20px; }
.stats-big-fiat { font-size: 32px; font-weight: 700; color: var(--text-main); }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; }
.stat-box { background: var(--bg-main); padding: 20px; border-radius: var(--radius); border: 1px solid var(--border); }
.stat-title { color: var(--text-muted); font-size: 13px; margin-bottom: 8px; }
.stat-val { font-size: 20px; font-weight: 700; }

/* ФОРМЫ KYC И ВЫВОДА */
.kyc-step { display: none; }
.kyc-step.active { display: block; }
.file-upload-box { display: block; border: 2px dashed var(--border); padding: 40px 20px; text-align: center; border-radius: var(--radius); cursor: pointer; color: var(--blue); font-weight: 500; transition: var(--transition); }
.file-upload-box:hover { border-color: var(--blue); background: rgba(41, 98, 255, 0.05); }
.file-upload-box.file-chosen { border-style: solid; border-color: var(--green); color: var(--green); }
.file-upload-box input { display: none; }
.qr-block { text-align: center; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }
.qr-block img { width: 160px; height: 160px; padding: 10px; background: #fff; border-radius: var(--radius); margin-bottom: 15px; }
.address-box { background: var(--bg-main); padding: 15px; border-radius: var(--radius); font-family: monospace; font-size: 13px; word-break: break-all; margin-bottom: 15px; border: 1px solid var(--border); }

/* УТИЛИТЫ */
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-10 { margin-top: 10px; } .mt-20 { margin-top: 20px; } .mt-30 { margin-top: 30px; }
.mb-10 { margin-bottom: 10px; } .mb-20 { margin-bottom: 20px; } .mb-30 { margin-bottom: 30px; }
.error-msg { color: var(--red); font-size: 13px; margin-bottom: 15px; display: none; background: var(--red-bg); padding: 10px; border-radius: 4px; }
.warning-text { font-size: 12px; color: var(--yellow); }

/* ФУТЕР */
footer { text-align: center; padding: 30px 20px; border-top: 1px solid var(--border); margin-top: auto; color: var(--text-muted); font-size: 13px; }
.footer-links span { cursor: pointer; margin: 0 10px; transition: var(--transition); }
.footer-links span:hover { color: var(--text-main); }
.footer-support { margin: 15px 0; }

/* МОБИЛЬНАЯ АДАПТАЦИЯ */
@media (max-width: 992px) {
    .terminal-grid { flex-direction: column; height: auto; }
    .tv-box { height: 400px; }
    .orderbook-box, .order-box { width: 100%; }
    .mobile-hide { display: none !important; }
}
@media (max-width: 768px) {
    .nav-links { display: none; flex-direction: column; position: absolute; top: 64px; left: 0; width: 100%; background: var(--bg-card); border-bottom: 1px solid var(--border); padding: 10px; box-shadow: var(--shadow); }
    .nav-links.show { display: flex; }
    .hamburger { display: block; }
    .bc-actions { flex-direction: column; }
    table, thead, tbody, th, td, tr { display: block; }
    thead tr { position: absolute; top: -9999px; left: -9999px; }
    tr { margin-bottom: 15px; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; background: var(--bg-main); box-shadow: var(--shadow); }
    td { border: none; padding: 8px 10px; display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
    td::before { content: attr(data-label); font-weight: 500; color: var(--text-muted); margin-right: 15px; }
    .empty-state-row td { display: block; text-align: center; }
    .empty-state-row td::before { display: none; }
}