:root {
    --bg-main: #0f1720;
    --bg-panel: #1e2835;
    --bg-modal: #151d29;
    --border: #2B2B43;
    --border-light: #333;
    --text-main: #e6eef8;
    --text-muted: #888;
    --accent: #2962ff;
    --accent-hover: #1e88e5;
    --success: #00e396;
    --danger: #ef5350;
    --warning: #ff9800;
}

body {
    background: var(--bg-main);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    padding: 6px;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

input, button, select {
    padding: 0 10px;
    border-radius: 4px;
    border: 1px solid var(--border-light);
    background: var(--bg-panel);
    color: white;
    font-size: 14px;
    height: 36px;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s;
}

input:focus, select:focus {
    border-color: var(--accent);
}

select {
    cursor: pointer;
    min-width: 130px;
}

#symbolInput {
    width: 120px;
    text-transform: uppercase;
    font-weight: bold;
}

.tf-group {
    display: flex;
    background: var(--bg-panel);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.tf-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0 12px;
    font-size: 13px;
    cursor: pointer;
    font-weight: 600;
    border-right: 1px solid var(--border-light);
    border-radius: 0;
    height: 34px;
    transition: all 0.2s;
}

.tf-btn:last-child {
    border-right: none;
}

.tf-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.tf-btn.active {
    background: var(--accent);
    color: white;
}

#loadBtn {
    background: var(--accent);
    border: none;
    font-weight: bold;
    cursor: pointer;
    padding: 0 16px;
}

#loadBtn:active {
    background: var(--accent-hover);
    transform: translateY(1px);
}

#loadBtn:disabled {
    background: #555;
    cursor: not-allowed;
    transform: none;
}

#gridBtn, #listBtn, #draw-line-btn, #clear-drawings-btn {
    background: #444;
    border: none;
    font-weight: bold;
    cursor: pointer;
}

#gridBtn.active {
    background: #e91e63;
    color: white;
}

#draw-line-btn.active {
    background: #ff9800;
    color: white;
}

#listBtn:hover, #gridBtn:hover:not(.active), #clear-drawings-btn:hover {
    background: #555;
}

.charts-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}

#price-chart {
    width: 100%;
    flex-grow: 1;
    min-height: 50%;
    border-bottom: 1px solid var(--border);
    position: relative; /* ВАЖНО ДЛЯ CANVAS */
}

#ind-chart {
    width: 100%;
    height: 30%;
    min-height: 150px;
}

.status {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    display: none;
}

@media (min-width: 600px) {
    .status {
        display: block;
    }
}

/* Модальное окно */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(3px);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.modal-overlay.show {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--bg-modal);
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 95%;
    max-width: 600px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 { margin: 0; font-size: 16px; color: white; }
.close-btn { background: transparent; border: none; color: var(--text-muted); font-size: 24px; cursor: pointer; padding: 0; line-height: 1; height: auto; }
.close-btn:hover { color: white; }
.modal-search { padding: 15px 20px; border-bottom: 1px solid var(--border); }
.modal-search input { width: 100%; background: #0b1220; border: 1px solid var(--border-light); font-size: 15px; }
.symbols-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; padding: 20px; overflow-y: auto; }
.symbol-item { background: var(--bg-panel); padding: 10px 8px; text-align: center; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 600; border: 1px solid transparent; transition: all 0.15s ease; display: flex; flex-direction: column; gap: 4px; }
.symbol-market-tag { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.symbol-item:hover { background: var(--accent); border-color: #5584ff; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(41, 98, 255, 0.3); }
.symbol-item:hover .symbol-market-tag { color: rgba(255, 255, 255, 0.7); }

/* ЭКРАН ЗАГРУЗКИ */
#auth-loader { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg-main); display: flex; flex-direction: column; justify-content: center; align-items: center; z-index: 9999; color: white; }
.spinner { border: 4px solid var(--border); border-top: 4px solid var(--accent); border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* =========================================
   СТИЛИ ЛИЧНОГО КАБИНЕТА
   ========================================= */
.cabinet-container {
    max-width: 420px;
    margin: 0 auto;
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
}

.cab-header { margin-bottom: 24px; padding: 0 4px; }
.cab-header h2 { margin: 0 0 4px 0; font-size: 24px; font-weight: 700; }
.subtitle { margin: 0; font-size: 14px; color: var(--text-muted); }

.card {
    background-color: var(--bg-panel);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
}

.card h3 { margin: 0 0 8px 0; font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px; font-weight: 600; }

.balance-card { text-align: center; padding: 24px 20px; border: 1px solid rgba(41, 98, 255, 0.3); background: linear-gradient(180deg, var(--bg-panel) 0%, #151d29 100%); }
.balance { font-size: 36px; font-weight: 800; margin: 8px 0 0 0; letter-spacing: -0.5px; color: #fff; }
.currency { font-size: 20px; color: var(--accent); font-weight: 600; }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stat-value { font-size: 20px; font-weight: 700; margin-top: 4px; color: #fff; }

.btn-main { background-color: var(--accent); color: white; border: none; width: 100%; padding: 14px; border-radius: 12px; font-size: 16px; font-weight: 600; cursor: pointer; transition: transform 0.1s; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-main:active { transform: scale(0.98); }
.btn-success { background-color: var(--success); color: #000; box-shadow: 0 4px 12px rgba(0, 227, 150, 0.2); }

.status-badge { display: inline-block; padding: 6px 12px; border-radius: 20px; font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.status-active { background-color: rgba(0, 227, 150, 0.15); color: var(--success); }
.status-inactive { background-color: rgba(239, 83, 80, 0.15); color: var(--danger); }