:root {
    --bg-primary: #0a0808;
    --bg-secondary: #141010;
    --bg-card: rgba(20, 16, 16, 0.92);
    --bg-card-hover: rgba(30, 24, 24, 0.95);
    --gold: #d4a853;
    --gold-dark: #b8922f;
    --gold-light: #f0d080;
    --green: #26A17B;
    --red: #FF4757;
    --yellow: #f1c40f;
    --blue: #3498db;
    --purple: #9b59b6;
    --cyan: #00f3ff;
    --orange: #ff8c00;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.4);
    --border-color: rgba(212, 168, 83, 0.12);
    --border-hover: rgba(212, 168, 83, 0.25);
    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.exchange-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 15px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ============ ВЫПАДАЮЩИЙ СПИСОК ПАР ============ */
.pair-selector {
    position: relative;
    margin-bottom: 15px;
    z-index: 100;
}

.pair-dropdown-wrapper {
    position: relative;
    width: 100%;
    max-width: 280px;
}

.pair-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    background: rgba(20, 16, 16, 0.95);
    border: 1px solid rgba(212, 168, 83, 0.2);
    border-radius: 14px;
    color: #ffffff;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.pair-dropdown-btn:hover {
    border-color: rgba(212, 168, 83, 0.4);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.5);
}

.pair-dropdown-price {
    margin-left: auto;
    font-size: 12px;
    color: #888;
    font-family: monospace;
}

.pair-dropdown-arrow {
    font-size: 12px;
    color: #888;
    transition: transform 0.3s;
}

.pair-dropdown-menu {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    background: rgba(20, 16, 16, 0.98);
    border: 1px solid rgba(212, 168, 83, 0.2);
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
    animation: dropdownIn 0.2s ease;
}

@keyframes dropdownIn {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.pair-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: #ffffff;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
    text-align: left;
}

.pair-dropdown-item:hover {
    background: rgba(212, 168, 83, 0.1);
}

.pair-dropdown-item.active {
    background: rgba(212, 168, 83, 0.15);
    border-left: 3px solid #d4a853;
}

.pair-item-price {
    margin-left: auto;
    font-size: 11px;
    color: #888;
    font-family: monospace;
}

/* ============ ВЕРХНЯЯ ПАНЕЛЬ ============ */
.top-bar {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 15px;
    margin-bottom: 15px;
}

.pair-info, .balance-card {
    background: rgba(20, 16, 16, 0.92);
    border: 1px solid rgba(212, 168, 83, 0.15);
    border-radius: 14px;
    padding: 18px;
}

.pair-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #d4a853;
    display: flex;
    align-items: center;
    gap: 10px;
}

.price-change {
    font-size: 0.75rem;
    padding: 3px 10px;
    border-radius: 6px;
    font-weight: 600;
}
.price-change.up { background: rgba(38, 161, 123, 0.2); color: #26A17B; }
.price-change.down { background: rgba(255, 71, 87, 0.2); color: #FF4757; }

.price-stats {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.stat-item { display: flex; flex-direction: column; }
.stat-label {
    color: #888;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.stat-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: #ffffff;
    font-family: monospace;
}

/* ============ БАЛАНС ============ */
.balance-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: #ffffff;
}

.balance-amount {
    font-weight: 600;
    font-family: monospace;
}
.balance-amount.usdt { color: #00f3ff; }

/* ============ КНОПКИ ============ */
.action-btn {
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s;
    font-size: 0.7rem;
}
.action-btn.deposit { background: linear-gradient(135deg, #d4a853, #ff2b9e); color: #0a0808; }
.action-btn.withdraw { background: linear-gradient(135deg, #26A17B, #00f3ff); color: #0a0808; }
.action-btn:hover { transform: translateY(-2px); }

/* ============ ОСНОВНАЯ СЕТКА ============ */
.main-grid {
    display: grid;
    grid-template-columns: 280px 1fr 320px;
    gap: 15px;
    margin-bottom: 15px;
}

.card {
    background: rgba(20, 16, 16, 0.92);
    border: 1px solid rgba(212, 168, 83, 0.15);
    border-radius: 14px;
    padding: 16px;
}

.card-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #d4a853;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ============ СТАКАН ============ */
.orderbook-header {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    padding: 6px 10px;
    font-size: 0.65rem;
    color: #888;
    text-transform: uppercase;
}

.order-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    padding: 4px 10px;
    cursor: pointer;
    font-family: monospace;
    font-size: 0.8rem;
    position: relative;
    border-radius: 4px;
    color: #ffffff;
}

.order-row:hover { background: rgba(255, 255, 255, 0.05); }

.order-row .depth-bar {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    pointer-events: none;
    opacity: 0.12;
}
.order-row.ask .depth-bar { background: #FF4757; }
.order-row.bid .depth-bar { background: #26A17B; }
.order-row.ask .price { color: #FF4757; }
.order-row.bid .price { color: #26A17B; }

.spread-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: rgba(212, 168, 83, 0.05);
    border-radius: 8px;
    margin: 8px 0;
    color: #ffffff;
}

.current-price-big {
    font-size: 1.2rem;
    font-weight: 700;
    color: #d4a853;
    font-family: monospace;
}

/* ============ ФОРМА ============ */
.order-type-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 10px;
}

.order-type-btn {
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
    color: #888;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.3s;
}

.order-type-btn.active-buy {
    background: rgba(38, 161, 123, 0.2);
    color: #26A17B;
    border-color: #26A17B;
}
.order-type-btn.active-sell {
    background: rgba(255, 71, 87, 0.2);
    color: #FF4757;
    border-color: #FF4757;
}
.order-type-btn.active {
    background: rgba(212, 168, 83, 0.2);
    color: #d4a853;
    border-color: #d4a853;
}

.input-group { margin-bottom: 10px; }
.input-group label {
    display: block;
    color: #888;
    font-size: 0.7rem;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.input-group input {
    width: 100%;
    padding: 10px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border-radius: 8px;
    font-size: 0.85rem;
    font-family: monospace;
}

.input-group input:focus {
    outline: none;
    border-color: #d4a853;
}

/* Слайдер */
.slider-container { padding: 10px 0; }
.slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, #26A17B, #d4a853, #FF4757);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}
.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #d4a853;
    cursor: pointer;
    border: 2px solid #0a0808;
}
.slider-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 10px;
    color: #888;
}

.available-balance {
    background: rgba(212, 168, 83, 0.08);
    border: 1px solid rgba(212, 168, 83, 0.2);
    border-radius: 10px;
    padding: 10px 14px;
    margin: 10px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #888;
    flex-wrap: wrap;
}

.available-balance .value {
    color: #d4a853;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    text-align: right;
}

.submit-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
}
.submit-btn.buy { background: linear-gradient(135deg, #26A17B, #0aa66e); color: white; }
.submit-btn.sell { background: linear-gradient(135deg, #FF4757, #d43f54); color: white; }
.submit-btn:hover { transform: translateY(-2px); }

.fee-info {
    text-align: center;
    color: #888;
    font-size: 0.65rem;
    margin-top: 8px;
}

/* ============ ТАБЫ ============ */
.orders-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(212, 168, 83, 0.1);
    padding-bottom: 8px;
}

.tab-btn {
    padding: 7px 16px;
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.8rem;
    transition: all 0.3s;
}
.tab-btn:hover { color: #d4a853; }
.tab-btn.active {
    color: #d4a853;
    background: rgba(212, 168, 83, 0.12);
}

table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
th {
    text-align: left;
    color: #888;
    padding: 8px;
    border-bottom: 1px solid rgba(212, 168, 83, 0.1);
    font-size: 0.7rem;
    text-transform: uppercase;
}
td {
    padding: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: #ffffff;
}

.buy-text { color: #26A17B !important; }
.sell-text { color: #FF4757 !important; }

.status-badge {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
}
.status-active { background: rgba(38, 161, 123, 0.15); color: #26A17B; }
.status-filled { background: rgba(255, 255, 255, 0.08); color: #888; }
.status-cancelled { background: rgba(255, 71, 87, 0.15); color: #FF4757; }

.cancel-btn {
    background: none;
    border: 1px solid #FF4757;
    color: #FF4757;
    border-radius: 6px;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 0.7rem;
}
.cancel-btn:hover { background: #FF4757; color: white; }

/* ============ ГРАФИК ============ */
.chart-container { height: 320px; position: relative; }
.chart-controls { display: flex; gap: 4px; margin-bottom: 10px; }
.chart-btn {
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #888;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.7rem;
}
.chart-btn.active {
    background: #d4a853;
    color: #0a0808;
    border-color: #d4a853;
}

.market-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 10px;
}
.market-stat {
    text-align: center;
    padding: 10px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
}
.market-stat .label { color: #888; font-size: 0.6rem; text-transform: uppercase; }
.market-stat .value { color: #ffffff; font-size: 0.9rem; font-weight: 600; }

/* ============ МОДАЛЬНЫЕ ОКНА ============ */
.modal-content {
    background: #141010;
    border: 1px solid rgba(212, 168, 83, 0.2);
    border-radius: 14px;
    color: #ffffff;
}
.modal-title { color: #d4a853; }
.form-control-dark {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 10px;
    color: #ffffff;
    width: 100%;
}

/* ============ АДАПТИВНОСТЬ ============ */
@media (max-width: 1200px) {
    .main-grid { grid-template-columns: 1fr; }
    .top-bar { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .market-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ============ ПРОКРУТКА ТАБЛИЦ ============ */
.orders-tabs + div {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(212, 168, 83, 0.3) transparent;
}

.orders-tabs + div::-webkit-scrollbar {
    height: 4px;
}

.orders-tabs + div::-webkit-scrollbar-track {
    background: transparent;
}

.orders-tabs + div::-webkit-scrollbar-thumb {
    background: rgba(212, 168, 83, 0.3);
    border-radius: 10px;
}

.orders-tabs + div table {
    min-width: 600px;
    width: 100%;
}

/* Для стакана на мобильных */
#asks-container, #bids-container {
    overflow-x: hidden;
}

/* Адаптация для мобильных */
@media (max-width: 768px) {
    .orders-tabs + div table {
        min-width: 500px;
        font-size: 0.7rem;
    }
    
    .orders-tabs + div th,
    .orders-tabs + div td {
        padding: 6px 4px;
        white-space: nowrap;
    }
    
    /* Скрываем менее важные колонки на маленьких экранах */
    .orders-tabs + div th:nth-child(1),
    .orders-tabs + div td:nth-child(1) {
        display: none;
    }
}

@media (max-width: 480px) {
    .orders-tabs + div table {
        min-width: 400px;
        font-size: 0.65rem;
    }
    
    .orders-tabs + div th,
    .orders-tabs + div td {
        padding: 4px 3px;
    }
}

/* ============ ПРОКРУТКА ТАБЛИЦ ============ */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(212, 168, 83, 0.3) transparent;
    max-width: 100%;
}

.table-scroll::-webkit-scrollbar {
    height: 4px;
}

.table-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.table-scroll::-webkit-scrollbar-thumb {
    background: rgba(212, 168, 83, 0.3);
    border-radius: 10px;
}

.table-scroll table {
    min-width: 600px;
    width: 100%;
}

/* Адаптация для мобильных */
@media (max-width: 768px) {
    .table-scroll table {
        min-width: 500px;
        font-size: 0.7rem;
    }
    
    .table-scroll th,
    .table-scroll td {
        padding: 6px 4px;
        white-space: nowrap;
    }
}

@media (max-width: 480px) {
    .table-scroll table {
        min-width: 400px;
        font-size: 0.65rem;
    }
    
    .table-scroll th,
    .table-scroll td {
        padding: 4px 3px;
    }
}

/* Индикатор прокрутки */
.table-scroll {
    position: relative;
}

.table-scroll::after {
    content: '→';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(212, 168, 83, 0.5);
    font-size: 20px;
    pointer-events: none;
    animation: scrollHint 2s infinite;
}

@keyframes scrollHint {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}

@media (min-width: 769px) {
    .table-scroll::after {
        display: none;
    }
}
