* { box-sizing: border-box; }

:root {
    --bg-main: #0b0e11;
    --bg-panel: #181a20;
    --bg-hover: #2b3139;
    --text-main: #eaecef;
    --text-muted: #848e9c;
    --green: #0ecb81;
    --green-hover: #0b9e65;
    --red: #f6465d;
    --red-hover: #c9384b;
    --border: #2b3139;
}

body {
    margin: 0; font-family: Arial, Helvetica, sans-serif;
    background-color: var(--bg-main); color: var(--text-main); font-size: 14px;
    overflow-x: hidden; 
}

/* Кастомные скроллбары */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-main); }
::-webkit-scrollbar-thumb { background: #2b3139; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #474d57; }

/* Бегущая строка */
.ticker-wrap { 
    width: 100%; 
    overflow: hidden; 
    background: var(--bg-main); 
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border); 
    white-space: nowrap; 
    height: 34px; 
    display: flex; 
    align-items: center;
    font-size: 12px;
}
.ticker-item { 
    display: inline-flex;
    align-items: center;
    margin-right: 35px; 
    font-size: 12px;
}
.ticker-item b {
    color: var(--text-main);
    margin-left: 2px;
}

/* Навигация */
.navbar {
    display: flex; justify-content: space-between; align-items: center; padding: 0 20px;
    background: var(--bg-panel); border-bottom: 1px solid var(--border); height: 56px;
}
.navbar a { color: var(--text-main); text-decoration: none; margin-right: 20px; font-weight: 500; transition: color 0.2s; }
.navbar a:hover { color: var(--green); }
.profile-info { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; }
.profile-info > * { margin-left: 15px; }
.profile-info > *:first-child { margin-left: 0; }

/* Терминал (Сетка) */
.terminal-layout { 
    display: flex; 
    height: calc(100vh - 90px); 
    overflow: hidden; 
    width: 100%;
}

.panel { 
    background: var(--bg-panel); 
    display: flex; 
    flex-direction: column; 
    overflow-y: auto; 
    overflow-x: hidden;
}
.panel-left { width: 260px; min-width: 260px; flex-shrink: 0; border-right: 1px solid var(--border); }
.panel-center { flex: 1; min-width: 0; }
.panel-right { width: 300px; min-width: 300px; flex-shrink: 0; border-left: 1px solid var(--border); }

.panel-header { padding: 12px 15px; border-bottom: 1px solid var(--border); font-weight: 600; background: rgba(255,255,255,0.02); flex-shrink: 0; }
.panel-body { padding: 15px; overflow-y: auto; flex: 1; }

/* Формы ввода */
label { display: block; margin-bottom: 6px; color: var(--text-muted); font-size: 12px; font-weight: 500; }

input {
    width: 100%; padding: 10px 12px; margin-bottom: 15px; background: var(--bg-main);
    border: 1px solid var(--border); color: white; border-radius: 6px; font-family: monospace;
    transition: border-color 0.2s;
}
input:focus { outline: none; border-color: var(--green); }

/* Выпадающие списки (Combobox) */
select {
    width: 100%; 
    padding: 10px 36px 10px 12px; 
    margin-bottom: 15px; 
    background: var(--bg-main);
    border: 1px solid var(--border); 
    color: white; 
    border-radius: 6px; 
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.2s;
    appearance: none;
    -webkit-appearance: none;
    -moz-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/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
}
select:focus { 
    outline: none; 
    border-color: var(--green); 
}
select option {
    background: var(--bg-panel);
    color: var(--text-main);
    padding: 10px;
}

/* Кнопки */
button { 
    width: 100%; padding: 12px; border: none; border-radius: 6px; cursor: pointer; 
    font-weight: 600; color: white; transition: background 0.2s, transform 0.1s; 
}
button:active { transform: scale(0.98); }
.btn-buy { background-color: var(--green); }
.btn-buy:hover { background-color: var(--green-hover); }
.btn-sell { background-color: var(--red); }
.btn-sell:hover { background-color: var(--red-hover); }

/* Кнопки таймфреймов */
.btn-tf {
    padding: 4px 8px; font-size: 11px; background: #2b3139; border: none; 
    color: #848e9c; cursor: pointer; border-radius: 3px; width: auto;
    transition: background 0.2s, color 0.2s;
}
.btn-tf:hover { background: #3b424d; color: white; }

.btn-neutral { 
    background-color: var(--bg-hover); 
    border: 1px solid var(--border); 
    color: white !important; 
    text-decoration: none;   
    display: inline-block;   
    text-align: center;
}
.btn-neutral:hover { 
    background-color: #3b424d; 
    color: white; 
}

.text-green { color: var(--green); }
.text-red { color: var(--red); }

/* Поле поиска в левой панели пар */
.search-pair-input {
    width: 100%;
    padding: 6px 10px;
    margin-bottom: 0;
    background: var(--bg-main);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: 4px;
    font-size: 11px;
    font-family: inherit;
}
.search-pair-input:focus {
    outline: none;
    border-color: var(--green);
}

/* Стакан и списки */
.pair-list { list-style: none; padding: 0; margin: 0; }
.pair-item { 
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    padding: 8px 12px; 
    border-bottom: 1px solid var(--border); 
    cursor: pointer; 
    text-decoration: none; 
    color: var(--text-main); 
    transition: background 0.2s; 
}
.pair-item:hover { background: rgba(255,255,255,0.03); }
.pair-item.active { border-left: 3px solid var(--green); background: rgba(14, 203, 129, 0.05); }

.pair-info { display: flex; flex-direction: column; }
.pair-name { font-weight: 600; font-size: 12px; color: var(--text-main); }

.pair-stats { display: flex; flex-direction: column; text-align: right; }
.pair-price { font-size: 12px; font-weight: 500; color: var(--text-main); font-family: monospace; }
.pair-change { font-size: 11px; font-weight: 600; margin-top: 1px; }

.order-row { display: flex; justify-content: space-between; font-family: monospace; font-size: 12px; padding: 5px 8px; cursor: pointer; border-radius: 4px; transition: background 0.1s; }
.order-row:hover { background: var(--bg-hover); }

/* График */
.chart-container { 
    flex-grow: 1; 
    width: 100%; 
    min-height: 400px; 
    position: relative; 
    overflow: hidden; 
    flex-shrink: 0;
}

/* Формы ордеров */
.order-form-container { 
    border-top: 1px solid var(--border); 
    padding: 20px; 
    display: flex; 
    justify-content: space-between;
    background: var(--bg-panel); 
    flex-shrink: 0;
    position: relative;
    z-index: 10; 
}
.order-side, .order-side-right { 
    width: 48%; 
    flex: 0 0 48%;
    box-sizing: border-box;
}

.my-orders-wrap {
    border-top: 1px solid var(--border); 
    padding: 15px; 
    flex-shrink: 0;
}

.my-history-wrap {
    border-top: 1px solid var(--border); 
    padding: 15px; 
    flex-shrink: 0;
}


/* СТИЛИ КОШЕЛЬКА (WALLET.PHP) */
.wallet-container {
    max-width: 850px;
    margin: 40px auto;
    background: var(--bg-panel);
    padding: 30px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.wallet-title {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 20px;
}

.balance-grid {
    display: flex;
    gap: 20px;
    margin-bottom: 25px;
}

.balance-card {
    flex: 1;
    background: var(--bg-main);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.balance-label {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 8px;
}

.balance-value {
    font-size: 26px;
    font-weight: bold;
    color: var(--green);
    font-family: monospace;
}

.actions-grid {
    display: flex;
    gap: 20px;
    align-items: stretch;
}

.action-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: var(--bg-main);
    padding: 22px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.action-card-body {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.action-title {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 16px;
}

.action-desc {
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.5;
    margin-top: 0;
    margin-bottom: 20px;
    min-height: 48px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    margin-bottom: 6px;
}

.form-group input, .form-group select {
    margin-bottom: 0;
}

.readonly-address {
    font-size: 11px;
    color: #a0a6b2;
    cursor: pointer;
    text-overflow: ellipsis;
}

.action-form {
    margin-top: auto;
    padding-top: 15px;
}

.action-form-full {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

/* Уведомления (Alerts) */
.alert {
    width: 100%;
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 13px;
    font-weight: 500;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 10px;
    line-height: 1.4;
}

.alert-green {
    color: var(--green);
    border: 1px solid var(--green);
    background: rgba(14, 203, 129, 0.1);
}

.alert-red {
    color: var(--red);
    border: 1px solid var(--red);
    background: rgba(246, 70, 93, 0.1);
}

.alert-warning {
    color: #f39c12;
    border: 1px solid #f39c12;
    background: rgba(243, 156, 18, 0.1);
}

/* АДАПТИВНОСТЬ */
@media (max-width: 1024px) {
    .panel-left { width: 180px; min-width: 180px; }
    .panel-right { width: 220px; min-width: 220px; }
}
@media (max-width: 600px) {
    .terminal-layout { flex-direction: column; height: auto; overflow: visible; }
    .panel { width: 100%; border-left: none; border-right: none; border-bottom: 1px solid var(--border); overflow-y: visible; }
    .panel-center { order: 1; }
    .panel-right { order: 2; }
    .panel-left { order: 3; }
    .chart-container { height: 400px; flex: none; }
    .navbar { flex-direction: column; height: auto; padding: 15px 20px; }
    .profile-info { width: 100%; justify-content: space-between; margin-top: 10px; }
    
    .order-form-container { flex-direction: column; gap: 20px; }
    .order-side, .order-side-right { width: 100%; flex: 1 1 100%; }

    .balance-grid, .actions-grid { flex-direction: column; }
    .wallet-container { margin: 15px; padding: 20px; }
    .action-desc { min-height: auto; }
}