* { margin:0; padding:0; box-sizing:border-box; }
body { background:#0a0a0f; color:#ddd; font-family:Arial, sans-serif; overflow:hidden; height:100vh; }
.main { display:grid; grid-template-columns: 50px 1fr 5px 260px; height:100vh; width: 100vw; overflow: hidden; }
.left-toolbar { width:50px; background:#111118; border-right:1px solid #222; display:flex; flex-direction:column; align-items:center; padding-top:10px; gap:12px; }
.tool-btn { width:36px; height:36px; background:#1a1a22; border:1px solid #333; color:#ccc; cursor:pointer; border-radius:6px; font-size:18px; }
.tool-btn.active { background:#00ffaa; color:#000; border-color:#00ffaa; }
.clear-drawings-btn { margin-top:auto; margin-bottom:12px; color:#ff8080; }
.clear-drawings-btn:hover { border-color:#ff4d4d; color:#fff; background:#2a1616; }
.chart-area { display:flex; flex-direction:column; position: relative; min-width: 0; min-height: 0; overflow: hidden; }
.top-bar { height:50px; background:#111118; border-bottom:1px solid #222; display:flex; align-items:center; padding:0 15px; gap:10px; position: relative; }
.current-symbol-display { font-size:18px; font-weight:bold; color:#00ffaa; min-width: 120px; }
.connection-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 92px;
    height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid #3f4955;
    color: #d8e2ef;
    background: #1b232f;
}

.connection-status-badge.live {
    border-color: #178f68;
    background: rgba(23, 143, 104, 0.18);
    color: #59d9ac;
}

.connection-status-badge.reconnecting {
    border-color: #c88f1b;
    background: rgba(200, 143, 27, 0.18);
    color: #ffcc73;
}

.connection-status-badge.stale {
    border-color: #bf3e4b;
    background: rgba(191, 62, 75, 0.16);
    color: #ff9aa4;
}
.timeframe-btn { padding:6px 12px; background:#1a1a22; border:none; color:#ccc; border-radius:6px; cursor:pointer; }
.timeframe-btn.active { background:#00ffaa; color:#000; font-weight:bold; }
.multi-btn { width:36px; height:36px; display:flex; align-items:center; justify-content:center; background:#1a1a22; border:1px solid #333; color:#ccc; border-radius:6px; cursor:pointer; font-size:14px; font-weight:700; }
.multi-btn:hover { background:#222; }
.multi-btn.active { background:#00ffaa; color:#000; border-color:#00ffaa; }
.top-bar-right { margin-left:auto; display:flex; align-items:center; gap:10px; }
.auth-area { display:flex; align-items:center; gap:10px; }
.auth-top-btn, .auth-logout-btn { height:36px; padding:0 14px; display:flex; align-items:center; justify-content:center; background:#1a1a22; border:1px solid #333; color:#ddd; border-radius:6px; cursor:pointer; font-size:13px; font-weight:700; }
.auth-top-btn:hover, .auth-logout-btn:hover { background:#222; }
.auth-user-box { display:flex; align-items:center; gap:10px; }
.auth-greeting { font-size:13px; color:#9edbc5; white-space:nowrap; }
.indicators-btn { width:36px; height:36px; display:flex; align-items:center; justify-content:center; background:#1a1a22; border:1px solid #333; color:#ccc; border-radius:6px; cursor:pointer; font-size:13px; font-weight:700; }
.settings-btn { width:36px; height:36px; display:flex; align-items:center; justify-content:center; background:#1a1a22; border:1px solid #333; color:#ccc; border-radius:6px; cursor:pointer; }
.indicators-btn:hover,
.settings-btn:hover { background:#222; }
.settings-panel { position:absolute; top:55px; right:15px; width:220px; background:#111118; border:1px solid #333; border-radius:8px; padding:12px; display:none; flex-direction:column; gap:10px; z-index:200; }
.settings-panel.active { display:flex; }
.layout-panel { right:138px; }
.indicators-panel { right:56px; }
.indicators-panel { max-height: calc(100vh - 80px); overflow-y: auto; }

.layout-option-btn {
    padding: 8px 10px;
    background: #1a1a22;
    border: 1px solid #333;
    color: #ccc;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    text-align: center;
    font-weight: 800;
}

.layout-option-btn:hover {
    background: color-mix(in srgb, var(--ui-surface-2) 86%, #fff 14%);
    border-color: color-mix(in srgb, var(--ui-border) 70%, #fff 30%);
}

.layout-option-btn.active {
    background: color-mix(in srgb, var(--ui-accent) 76%, var(--ui-surface-2) 24%);
    color: #f3f7ff;
    border-color: var(--ui-accent-strong);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--ui-accent) 36%, transparent);
}

#layout-btn.active {
    background: color-mix(in srgb, var(--ui-accent) 76%, var(--ui-surface-2) 24%);
    color: #f3f7ff;
    border-color: var(--ui-accent-strong);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--ui-accent) 36%, transparent);
}

#layout-btn {
    font-size: 19px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: -0.02em;
}

/* Контейнер для графиков */
.charts-container { flex: 1; display: grid; gap: 1px; background: #0a0a0f; grid-template-columns: 1fr; grid-template-rows: 1fr; min-width: 0; min-height: 0; overflow: hidden; }
.charts-mode-single { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.charts-mode-two-horizontal { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; }
.charts-mode-two-vertical { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
.charts-mode-four { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }

.chart-wrapper { position: relative; border: 2px solid transparent; cursor: pointer; transition: border-color 0.2s; overflow: hidden; }
.chart-wrapper.active { border-color: #00ffaa; }
.chart-wrapper:not(.active) { border-color: #1a1a22; }
.chart-inner { width: 100%; height: 100%; }

.chart-symbol-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 700;
    color: #e6fff6;
    background: rgba(12, 18, 24, 0.72);
    border: 1px solid #2b3a48;
    border-radius: 5px;
    pointer-events: none;
    z-index: 6;
}

.chart-countdown-badge {
    position: absolute;
    right: 8px;
    bottom: 8px;
    padding: 1px 6px;
    font-size: 11px;
    color: #9ec3ff;
    background: rgba(10, 15, 26, 0.74);
    border: 1px solid #2a3b5d;
    border-radius: 4px;
    pointer-events: none;
    z-index: 6;
    display: none;
}

.settings-title { font-size:12px; color:#888; text-transform: uppercase; letter-spacing: 1px; }
.settings-panel label { display:flex; align-items:center; gap:8px; font-size:13px; color:#ccc; cursor:pointer; }
.settings-panel input[type="checkbox"] { width: 14px; height: 14px; }

/* Кнопки переключения темы */
.theme-buttons { display: flex; gap: 8px; }
.theme-btn { padding: 6px 12px; background: #1a1a22; border: 1px solid #333; color: #888; border-radius: 6px; cursor: pointer; font-size: 16px; transition: all 0.2s; }
.theme-btn:hover { background: #222; border-color: #444; }
.theme-btn.active { background: #00ffaa; color: #000; border-color: #00ffaa; }

.settings-panel input[type="number"] { width: 100%; min-width: 100px; padding: 4px 6px; font-size: 13px; border-radius: 4px; border: 1px solid #333; background: #10101a; color: #ddd; }
.settings-panel select { width: 100%; min-width: 100px; padding: 4px 6px; font-size: 13px; border-radius: 4px; border: 1px solid #333; background: #10101a; color: #ddd; }
.indicator-group { border-top: 1px solid #2a2a33; padding-top: 8px; margin-top: 6px; }
.indicator-group:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.indicator-toggle-row { justify-content: space-between; width: 100%; }
.indicator-toggle-row span { font-size: 13px; color: #ddd; }
.ema-modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); display: flex; align-items: center; justify-content: center; z-index: 400; }
.ema-modal-card { width: min(96vw, 600px); background: #111118; border: 1px solid #333; border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.ema-modal-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #ccc; }
.ema-modal-row { display: grid; grid-template-columns: 92px 72px 62px 72px 92px 132px; gap: 6px; align-items: center; }
.ema-inline-field { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #ccc; white-space: nowrap; }
.ema-inline-field input[type="number"] { width: 34px; min-width: 34px; }
.ema-inline-field input[type="color"] { width: 24px; min-width: 24px; height: 20px; padding: 0; }
.ema-inline-field select { width: 100%; min-width: 70px; }
.ema-modal-card input[type="number"],
.ema-modal-card input[type="color"],
.ema-modal-card select { width: 100%; padding: 4px 6px; border-radius: 4px; border: 1px solid #333; background: #10101a; color: #ddd; font-size: 12px; }
.ema-modal-header { display: flex; align-items: center; justify-content: space-between; }
.ema-modal .indicator-group.ema-focus { outline: 1px solid #00ffaa; border-radius: 6px; padding: 8px; background: rgba(0, 255, 170, 0.06); }
.ema-modal-close { width: 28px; height: 28px; border: 1px solid #333; border-radius: 6px; background: #1a1a22; color: #ccc; cursor: pointer; }
.ema-modal-close:hover { background: #222; }
.save-btn { border: 1px solid #2c9; background: #00cc88; color: #03180f; border-radius: 6px; padding: 8px; font-weight: 700; cursor: pointer; }
.save-btn:hover { filter: brightness(0.95); }
.auth-modal { position: fixed; inset: 0; background: rgba(5, 8, 14, 0.76); backdrop-filter: blur(8px); align-items: center; justify-content: center; z-index: 450; }
.auth-dialog { position: relative; width: min(92vw, 440px); background: linear-gradient(180deg, #121824 0%, #0d1118 100%); border: 1px solid #293447; border-radius: 18px; padding: 28px; box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45); display: flex; flex-direction: column; gap: 14px; }
.auth-close-btn { position: absolute; top: 14px; right: 14px; width: 30px; height: 30px; border-radius: 50%; border: 1px solid #344359; background: #121923; color: #c8d2e1; cursor: pointer; }
.auth-close-btn:hover { background: #1a2432; }
.auth-brand { font-size: 24px; font-weight: 700; color: #ecf4ff; letter-spacing: 0.02em; }
.auth-subtitle { font-size: 13px; line-height: 1.5; color: #90a4bc; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.auth-tab { height: 40px; border: 1px solid #304154; border-radius: 10px; background: #0f151f; color: #9bb0c8; font-weight: 700; cursor: pointer; }
.auth-tab.active { background: linear-gradient(180deg, #19314a 0%, #13263b 100%); color: #edf6ff; border-color: #3d5c7f; }
.auth-panel { display: none; flex-direction: column; gap: 12px; }
.auth-panel.active { display: flex; }
.auth-label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: #9fb2c8; text-transform: uppercase; letter-spacing: 0.04em; }
.auth-input { width: 100%; border: 1px solid #314459; border-radius: 10px; background: #0c121a; color: #f3f7fb; padding: 12px 14px; font-size: 14px; outline: none; }
.auth-input:focus { border-color: #5d8dc7; box-shadow: 0 0 0 3px rgba(93, 141, 199, 0.18); }
.auth-submit-btn, .auth-secondary-btn, .auth-link-btn { border: none; border-radius: 10px; cursor: pointer; font-weight: 700; }
.auth-submit-btn { height: 42px; background: linear-gradient(180deg, #27c58c 0%, #149d6d 100%); color: #042515; }
.auth-secondary-btn { height: 38px; background: #1b2a39; color: #dbe9f6; border: 1px solid #324b67; }
.auth-link-btn { padding: 0; background: transparent; color: #7fb6ff; text-align: left; }
.forgot-password-box { margin-top: 4px; padding: 12px; background: rgba(16, 24, 36, 0.92); border: 1px solid #26384d; border-radius: 12px; }
.auth-message { min-height: 18px; font-size: 13px; color: #ff8d8d; }
.notify-container { position:fixed; right:20px; bottom:20px; display:flex; flex-direction:column; gap:10px; z-index:300; pointer-events:none; }
.notify-item { min-width:220px; max-width:320px; background: rgba(20, 20, 30, 0.95); border:1px solid #333; color:#fff; padding:12px 38px 12px 14px; border-radius:8px; box-shadow:0 12px 36px rgba(0,0,0,0.25); opacity:0; transform: translateY(20px); transition: opacity 0.25s ease, transform 0.25s ease; font-size:13px; position:relative; pointer-events:auto; }
.notify-item.visible { opacity:1; transform: translateY(0); }
.notify-item.warn { border-color:#00ffaa; }
.notify-item.gold { border-color:#d9b24c; box-shadow: 0 0 0 1px rgba(217,178,76,0.35), 0 12px 36px rgba(0,0,0,0.25); }
.notify-item.growth { border-color:#00cc88; }
.notify-item.fall { border-color:#ff4d4d; }
.notify-close { position:absolute; top:6px; right:8px; width:22px; height:22px; border:none; border-radius:50%; background:transparent; color:#bbb; font-size:16px; line-height:20px; cursor:pointer; }
.notify-close:hover { color:#fff; background:rgba(255,255,255,0.08); }
.timeframe-btn.active { background:#00ffaa; color:#000; font-weight:bold; }
#chart-container { flex:1; position:relative; }
.sidebar { width:260px; background:#111118; border-left:1px solid #222; padding:15px; display:flex; flex-direction:column; }
.history-sidebar { min-width: 0; background:#111118; border-left:1px solid #222; padding:15px; display:flex; flex-direction:column; }
.resizer { width: 5px; background: #222; cursor: ew-resize; flex-shrink: 0; }
.resizer:hover { background: #444; }
.current-price { display:none; }
.section-title { font-size:11px; margin:15px 0 5px; color:#555; text-transform: uppercase; letter-spacing: 1px; }
.alert-list { flex:1; overflow-y:auto; list-style:none; }
.alert-item { background:#1a1a22; padding:8px 10px; border-radius:6px; margin-bottom:6px; display:flex; justify-content:space-between; align-items:center; border-left: 3px solid #00ffaa; font-size: 13px; }
.level-item { border-left-color: #555; }
.delete-btn { background:none; color:#555; border:none; cursor:pointer; font-size: 18px; }
#ruler-label { position: absolute; pointer-events: none; background: rgba(0, 255, 170, 0.9); color: #000; padding: 4px 8px; border-radius: 4px; font-size: 12px; display: none; z-index: 100; font-weight: bold; }
.tabs { display: flex; gap: 5px; margin-bottom: 15px; }
.tab-btn { flex: 1; padding: 8px; background: #1a1a22; border: 1px solid #333; color: #888; border-radius: 4px; cursor: pointer; }
.tab-btn.active { background: #333; color: #fff; }
.tab-content { display: none; flex: 1; flex-direction: column; overflow: hidden; }
.tab-content.active { display: flex; }
.search-input { width: 100%; padding: 10px; margin-bottom: 10px; background: #1a1a22; border: 1px solid #333; color: #fff; border-radius: 6px; outline: none; }
.pairs-controls-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
}

.search-input-compact {
    flex: 1 1 0;
    min-width: 0;
    margin-bottom: 0;
}

.pairs-controls-row .vol-filter-label {
    flex: 0 0 auto;
    margin-left: 6px;
}

/* === Фильтр объёма в строке пар === */
.vol-filter-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #888;
    white-space: nowrap;
    flex-shrink: 0;
}

.vol-filter-input {
    width: 52px;
    padding: 5px 6px;
    background: #1a1a22;
    border: 1px solid #333;
    color: #ccc;
    border-radius: 6px;
    font-size: 12px;
    text-align: center;
    outline: none;
    appearance: textfield;
    -moz-appearance: textfield;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.vol-filter-input:hover {
    border-color: #444;
}

.vol-filter-input:focus {
    border-color: #00ffaa;
    box-shadow: 0 0 0 2px rgba(0, 255, 170, 0.15);
}

.vol-filter-input::-webkit-outer-spin-button,
.vol-filter-input::-webkit-inner-spin-button { -webkit-appearance: none; }

/* === Светлая тема для фильтра объёма === */
body.light-theme .vol-filter-input {
    background: #fff;
    border-color: #ddd;
    color: #222;
}

body.light-theme .vol-filter-input:hover {
    border-color: #ccc;
}

body.light-theme .vol-filter-input:focus {
    border-color: #ffa500;
    box-shadow: 0 0 0 2px rgba(255, 165, 0, 0.15);
}

/* === Компактный Telegram Chat ID === */
.tg-id-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 6px;
    margin: 4px 0 8px;
    width: 100%;
}
.tg-id-label {
    font-size: 12px;
    color: #888;
    white-space: nowrap;
}
.tg-id-input {
    width: 100%;
    min-width: 0;
    padding: 4px 8px;
    background: #1a1a22;
    border: 1px solid #333;
    border-radius: 5px;
    color: #ccc;
    font-size: 12px;
    box-sizing: border-box;
}

.columns-toggle-btn {
    height: 36px;
    width: 36px;
    min-width: 36px;
    padding: 0;
    margin-left: auto;
    border: 1px solid #333;
    border-radius: 6px;
    background: #1a1a22;
    color: #ccc;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

#settings-btn {
    font-size: 16px;
    font-weight: 700;
}

.columns-toggle-btn:hover {
    background: #222;
}

.pairs-columns-panel {
    position: absolute;
    top: 40px;
    right: 0;
    width: 180px;
    background: #111118;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 8px;
    display: none;
    flex-direction: column;
    gap: 6px;
    z-index: 220;
}

.pairs-columns-panel.active {
    display: flex;
}

.pairs-columns-panel label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #ccc;
    cursor: pointer;
}

.pairs-columns-panel input[type="checkbox"] {
    width: 14px;
    height: 14px;
}
.pair-item { cursor: pointer; padding: 10px; border-bottom: 1px solid #1a1a22; font-size: 14px; }
/* === ИСПРАВЛЕНИЕ СКРОЛЛА ПРАВОЙ КОЛОНКИ === */
.history-sidebar {
    background: #111118;
    border-left: 1px solid #222;
    min-width: 0;
    padding: 15px;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.tab-content {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}

.tab-content.active {
    display: flex;
}

.pairs-scroll {
    flex: 1;
    overflow-y: auto;
    background: #111118;
    border-radius: 6px;
    margin-top: 8px;
}

.pin-btn {
    background: transparent;
    border: none;
    color: #ffd700;
    font-size: 14px;
    cursor: pointer;
    margin-right: 6px;
    vertical-align: middle;
}

.pin-btn:hover {
    color: #fff;
}

.pair-row td:first-child {
    display: flex;
    align-items: center;
}

/* Таблица пар */
.pairs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    background: #111118;
}

.pairs-table th {
    background: #1a1a22;
    padding: 10px 8px;
    text-align: left;
    cursor: pointer;
    user-select: none;
    border-bottom: 2px solid #333;
    font-weight: 600;
    color: #ccc;
    position: sticky;
    top: 0;
    z-index: 10;
}

.pairs-table th:hover { background: #222; }

.pairs-table td {
    padding: 9px 8px;
    border-bottom: 1px solid #1a1a22;
}

.pairs-table tr:hover {
    background: #1f1f27;
}

.pairs-table td:nth-child(2),
.pairs-table td:nth-child(3),
.pairs-table td:nth-child(4),
.pairs-table td:nth-child(5),
.pairs-table td:nth-child(6),
.pairs-table td:nth-child(7) {
    text-align: right;
    font-family: monospace;
    font-weight: 500;
}

.pairs-table .positive { color: #00ffaa; }
.pairs-table .negative { color: #ff4444; }

/* Разделитель между закреплёнными и обычными парами */
.separator-row {
    height: 0 !important;
    border-bottom: 3px solid #444 !important;
    padding: 0 !important;
}

/* Выделение выбранной пары */
.pair-row.selected {
    background: #1a1a2e;
    border-left: 4px solid #ffa500;
    padding-left: 0;
}

.pair-row.selected td:first-child {
    padding-left: 12px;
}

/* ====================== СВЕТЛАЯ ТЕМА ====================== */
body.light-theme { 
    background: #f5f5f5; 
    color: #222; 
}

body.light-theme .main { 
    background: #f5f5f5; 
}

body.light-theme .left-toolbar { 
    background: #f0f0f0; 
    border-right-color: #ddd; 
}

body.light-theme .tool-btn { 
    background: #fff; 
    border-color: #ddd; 
    color: #222; 
}

body.light-theme .settings-panel select {
    background: #fff;
    border-color: #ccc;
    color: #222;
}

body.light-theme .theme-btn {
    background: #fff;
    border-color: #ddd;
    color: #888;
}

body.light-theme .theme-btn:hover {
    background: #f5f5f5;
    border-color: #bbb;
}

body.light-theme .theme-btn.active {
    background: #ffa500;
    border-color: #ff9500;
    color: #fff;
}

body.light-theme .indicator-group {
    border-top-color: #dddddd;
}

body.light-theme .indicator-toggle-row span {
    color: #222;
}

body.light-theme .ema-modal-card {
    background: #f0f0f0;
    border-color: #ddd;
}

body.light-theme .ema-modal-card label {
    color: #222;
}

body.light-theme .ema-inline-field {
    color: #222;
}

body.light-theme .ema-modal-card input[type="number"],
body.light-theme .ema-modal-card input[type="color"],
body.light-theme .ema-modal-card select {
    background: #fff;
    border-color: #ccc;
    color: #222;
}

body.light-theme .ema-modal-close {
    background: #fff;
    border-color: #ccc;
    color: #222;
}

@media (max-width: 760px) {
    .ema-modal-card { width: min(95vw, 520px); max-height: calc(100vh - 24px); overflow-y: auto; }
    .ema-modal-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

body.light-theme .ema-modal .indicator-group.ema-focus {
    outline-color: #00a370;
    background: rgba(0, 163, 112, 0.08);
}

body.light-theme .tool-btn.active { 
    background: #00cc88; 
    color: #fff; 
    border-color: #00cc88; 
}

body.light-theme .clear-drawings-btn {
    color: #c62828;
}

body.light-theme .chart-area { 
    background: #fff; 
}

body.light-theme .chart-symbol-badge {
    color: #173042;
    background: rgba(255, 255, 255, 0.9);
    border-color: #cfd8e3;
}

body.light-theme .chart-countdown-badge {
    color: #17427f;
    background: rgba(255, 255, 255, 0.92);
    border-color: #c8d8f0;
}

body.light-theme .top-bar { 
    background: #f0f0f0; 
    border-bottom-color: #ddd; 
}

body.light-theme .current-symbol-display { 
    color: #00a370; 
}

body.light-theme .connection-status-badge {
    border-color: #cbd5e1;
    background: #ffffff;
    color: #334155;
}

body.light-theme .connection-status-badge.live {
    border-color: #178f68;
    background: rgba(23, 143, 104, 0.14);
    color: #117453;
}

body.light-theme .connection-status-badge.reconnecting {
    border-color: #c88f1b;
    background: rgba(200, 143, 27, 0.14);
    color: #9a6a0f;
}

body.light-theme .connection-status-badge.stale {
    border-color: #bf3e4b;
    background: rgba(191, 62, 75, 0.12);
    color: #9f2f39;
}

body.light-theme .timeframe-btn { 
    background: #f0f0f0; 
    color: #222; 
    border-color: #ddd; 
}

body.light-theme .timeframe-btn.active { 
    background: #00cc88; 
    color: #fff; 
}

body.light-theme .indicators-btn {
    background: #f0f0f0;
    border-color: #ddd;
    color: #222;
}

body.light-theme .settings-btn { 
    background: #f0f0f0; 
    border-color: #ddd; 
    color: #222; 
}

body.light-theme .indicators-btn:hover,
body.light-theme .settings-btn:hover { 
    background: #e8e8e8; 
}

body.light-theme .settings-panel { 
    background: #f0f0f0; 
    border-color: #ddd; 
}

body.light-theme .settings-panel label { 
    color: #333; 
}

body.light-theme .settings-title { 
    color: #666; 
}

body.light-theme .history-sidebar { 
    background: #f0f0f0; 
    border-left-color: #ddd; 
}

body.light-theme .resizer { 
    background: #ddd; 
}

body.light-theme .resizer:hover { 
    background: #bbb; 
}

body.light-theme .tab-btn { 
    background: #fff; 
    border-color: #ddd; 
    color: #666; 
}

body.light-theme .tab-btn.active { 
    background: #f0f0f0; 
    color: #222; 
}

body.light-theme .search-input { 
    background: #fff; 
    border-color: #ddd; 
    color: #222; 
}

body.light-theme .columns-toggle-btn {
    background: #ffffff;
    border-color: #cfd6e0;
    color: #1b2533;
}

body.light-theme .columns-toggle-btn:hover {
    background: #e4e7ec;
    border-color: #bac3d0;
}

body.light-theme .pairs-columns-panel {
    background: #ffffff;
    border-color: #d7dde7;
}

body.light-theme .pairs-columns-panel label {
    color: #1b2533;
}

body.light-theme .search-input::placeholder { 
    color: #999; 
}

body.light-theme .alert-list { 
    background: #f0f0f0; 
}

body.light-theme .alert-item { 
    background: #fff; 
    border-color: #ddd; 
    border-left-color: #00cc88; 
    color: #222; 
}

body.light-theme .alert-item.level-item { 
    border-left-color: #aaa; 
}

body.light-theme .delete-btn { 
    color: #999; 
}

body.light-theme .pairs-scroll { 
    background: #f0f0f0; 
}

body.light-theme .pairs-table { 
    background: #fff; 
    color: #222; 
}

body.light-theme .pairs-table thead { 
    background: #f0f0f0; 
    color: #333; 
}

body.light-theme .pairs-table th { 
    color: #333; 
    border-color: #ddd; 
}

body.light-theme .pairs-table th { 
    background: #f0f0f0; 
    color: #333; 
    border-color: #ddd; 
}

body.light-theme .pairs-table th:hover { 
    background: #e8e8e8; 
}

body.light-theme .pairs-table td { 
    color: #222; 
    border-color: #eee; 
}

body.light-theme .pairs-table td.positive {
    color: #00a36f;
    font-weight: 600;
}

body.light-theme .pairs-table td.negative {
    color: #d93b3b;
    font-weight: 600;
}

body.light-theme .pairs-table tr:hover { 
    background: #f9f9f9; 
}

body.light-theme .separator-row {
    border-bottom-color: #ccc !important;
}

body.light-theme .pair-row.selected {
    background: #e8f4f8;
    border-left-color: #ff9500;
}

body.light-theme .section-title {
    color: #999; 
}

body.light-theme .clear-btn { 
    background: #f0f0f0 !important; 
    color: #666 !important; 
}

body.light-theme .notify-item { 
    background: rgba(255, 255, 255, 0.95); 
    border-color: #ddd; 
    color: #222; 
}

body.light-theme .notify-item.warn { 
    border-color: #00cc88; 
}

body.light-theme .notify-item.growth {
    border-color: #00b070;
}

body.light-theme .notify-item.fall {
    border-color: #e53935;
}

body.light-theme #ruler-label { 
    background: rgba(0, 200, 136, 0.9); 
}

/* ====================== PREMIUM THEME LAYER ====================== */
:root {
    --ui-bg: #17191d;
    --ui-bg-soft: #1d2025;
    --ui-surface: rgba(28, 31, 36, 0.95);
    --ui-surface-2: rgba(34, 38, 44, 0.96);
    --ui-border: #343941;
    --ui-border-soft: #2a2f36;
    --ui-text: #d6d9de;
    --ui-text-soft: #969da8;
    --ui-accent: #1fa177;
    --ui-accent-strong: #15815f;
    --ui-positive: #26a69a;
    --ui-negative: #ef5350;
    --ui-shadow: 0 18px 50px rgba(4, 10, 18, 0.42);
}

body.light-theme {
    --ui-bg: #f6f8fb;
    --ui-bg-soft: #ffffff;
    --ui-surface: rgba(255, 255, 255, 0.92);
    --ui-surface-2: rgba(250, 251, 255, 0.98);
    --ui-border: #dfe3eb;
    --ui-border-soft: #ebeff5;
    --ui-text: #131722;
    --ui-text-soft: #6a7285;
    --ui-accent: #178f68;
    --ui-accent-strong: #117453;
    --ui-positive: #089981;
    --ui-negative: #f23645;
    --ui-shadow: 0 16px 40px rgba(24, 52, 82, 0.14);
}

body {
    position: relative;
    background: radial-gradient(980px 480px at -14% -24%, #1a2130 0%, transparent 58%),
                radial-gradient(920px 420px at 112% 122%, #1a2130 0%, transparent 55%),
                var(--ui-bg);
    color: var(--ui-text);
    font-family: "Inter", "Segoe UI", sans-serif;
    letter-spacing: 0.01em;
}

body.light-theme {
    background: radial-gradient(900px 380px at -8% -18%, #eef2f8 0%, transparent 58%),
                radial-gradient(880px 380px at 108% 118%, #eef2f8 0%, transparent 55%),
                var(--ui-bg);
}

.left-toolbar,
.top-bar,
.history-sidebar,
.settings-panel,
.ema-modal-card,
.auth-dialog {
    background: var(--ui-surface);
    border-color: var(--ui-border);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--ui-border) 55%, transparent), var(--ui-shadow);
}

.left-toolbar,
.top-bar,
.history-sidebar {
    backdrop-filter: blur(10px);
}

.chart-wrapper:not(.active) {
    border-color: var(--ui-border-soft);
}

.chart-wrapper.active {
    border-color: var(--ui-accent);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--ui-accent) 45%, transparent);
}

.current-symbol-display {
    color: var(--ui-accent);
    font-weight: 800;
    letter-spacing: 0.02em;
}

.tool-btn,
.timeframe-btn,
.multi-btn,
.indicators-btn,
.settings-btn,
.tab-btn,
.auth-top-btn,
.auth-logout-btn,
.theme-btn,
.search-input,
.settings-panel select,
.settings-panel input[type="number"],
.ema-modal-card input[type="number"],
.ema-modal-card input[type="color"],
.ema-modal-card select {
    background: var(--ui-surface-2);
    border: 1px solid var(--ui-border);
    border-radius: 6px;
    border-color: var(--ui-border);
    color: var(--ui-text);
    transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

.tool-btn:hover,
.timeframe-btn:hover,
.multi-btn:hover,
.indicators-btn:hover,
.settings-btn:hover,
.tab-btn:hover,
.auth-top-btn:hover,
.auth-logout-btn:hover,
.theme-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(7, 15, 26, 0.26);
}

.tool-btn.active,
.timeframe-btn.active,
.multi-btn.active,
.theme-btn.active {
    background: var(--ui-accent);
    color: #f7fbff;
    border-color: var(--ui-accent-strong);
}

body.light-theme .tool-btn.active,
body.light-theme .timeframe-btn.active,
body.light-theme .multi-btn.active,
body.light-theme .theme-btn.active {
    color: #f7fbff;
}

.settings-title,
.section-title,
.auth-subtitle,
.auth-label,
.indicator-toggle-row span,
.auth-greeting {
    color: var(--ui-text-soft);
}

.pairs-scroll,
.pairs-table,
.pairs-table th,
.pairs-table td,
.alert-item,
.search-input,
.tab-content {
    color: var(--ui-text);
}

.pairs-scroll,
.pairs-table {
    background: color-mix(in srgb, var(--ui-surface) 88%, #000 12%);
}

.pairs-table th {
    background: color-mix(in srgb, var(--ui-surface-2) 90%, #000 10%);
    border-bottom-color: var(--ui-border);
}

.pairs-table td {
    border-bottom-color: var(--ui-border-soft);
}

.pairs-table tr:hover {
    background: color-mix(in srgb, var(--ui-accent) 9%, transparent);
}

.pair-row.selected {
    background: color-mix(in srgb, var(--ui-accent) 14%, transparent);
    border-left-color: var(--ui-accent);
}

.pairs-table .positive {
    color: var(--ui-positive);
}

.pairs-table .negative {
    color: var(--ui-negative);
}

.notify-item {
    background: color-mix(in srgb, var(--ui-surface) 96%, #000 4%);
    border-color: var(--ui-border);
    color: var(--ui-text);
}

.notify-item.warn {
    border-color: var(--ui-accent);
}

.notify-item.growth {
    border-color: var(--ui-positive);
}

.notify-item.fall {
    border-color: var(--ui-negative);
}

@keyframes premiumFade {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.top-bar,
.left-toolbar,
.history-sidebar {
    animation: premiumFade 0.24s ease;
}

/* Стили для модального окна редактирования объектов */
#edit-object-modal input[type="color"] {
    cursor: pointer;
}

#edit-object-modal .save-btn,
.ema-modal-card .save-btn {
    width: 100%;
    margin-top: 10px;
}

.compact-modal-card {
    width: min(92vw, 420px);
    gap: 8px;
}

#edit-yesterday-modal .compact-modal-card {
    width: min(92vw, 310px);
}

.yl-section-header {
    font-size: 11px;
    font-weight: 700;
    color: #aaa;
    margin: 4px 0 2px;
    letter-spacing: 0.5px;
}

.yl-row {
    gap: 6px;
}

.compact-modal-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.compact-modal-card .ema-inline-field {
    min-width: 0;
}

.compact-modal-card .ema-inline-field input[type="number"],
.compact-modal-card .ema-inline-field input[type="color"],
.compact-modal-card .ema-inline-field select {
    width: 100%;
    min-width: 0;
}

.compact-modal-card .indicator-group {
    padding-top: 10px;
    margin-top: 2px;
}

body.light-theme #edit-object-modal input,
body.light-theme #edit-object-modal select,
body.light-theme #edit-triggered-alert-modal input,
body.light-theme #edit-triggered-alert-modal select {
    background: #f0f3f9 !important;
    color: #333 !important;
}

@media (max-width: 980px) {
    .main {
        grid-template-columns: 42px 1fr 4px 230px;
    }

    .top-bar {
        padding: 0 10px;
        gap: 6px;
    }

    .timeframe-btn {
        padding: 5px 9px;
    }
}

/* ====================== UNIFIED BUTTON/THEME FIX ====================== */
body {
    background: radial-gradient(980px 420px at -12% -22%, #262a30 0%, transparent 58%),
                radial-gradient(920px 380px at 112% 124%, #23272d 0%, transparent 55%),
                #17191d;
}

body.light-theme {
    background: radial-gradient(950px 360px at -10% -18%, #edf1f6 0%, transparent 58%),
                radial-gradient(900px 360px at 110% 120%, #eef2f8 0%, transparent 55%),
                #f6f8fb;
}

.auth-tab.active {
    background: linear-gradient(180deg, #243231 0%, #1b2928 100%);
    color: #edf6f1;
    border-color: #33514e;
}

.auth-input:focus {
    border-color: color-mix(in srgb, var(--ui-accent) 72%, #ffffff 28%);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ui-accent) 24%, transparent);
}

.auth-link-btn {
    color: color-mix(in srgb, var(--ui-accent) 80%, #dff8ef 20%);
}

body.light-theme .chart-countdown-badge {
    color: #2d665a;
    border-color: #b9d9d1;
}

.tool-btn,
.timeframe-btn,
.multi-btn,
.indicators-btn,
.settings-btn,
.tab-btn,
.theme-btn,
.auth-top-btn,
.auth-logout-btn,
.ema-modal-close {
    border-radius: 6px;
    border: 1px solid var(--ui-border);
    background: var(--ui-surface-2);
    color: var(--ui-text);
    box-shadow: none;
}

.tool-btn:hover,
.timeframe-btn:hover,
.multi-btn:hover,
.indicators-btn:hover,
.settings-btn:hover,
.tab-btn:hover,
.theme-btn:hover,
.auth-top-btn:hover,
.auth-logout-btn:hover,
.ema-modal-close:hover {
    background: color-mix(in srgb, var(--ui-surface-2) 86%, #fff 14%);
    border-color: color-mix(in srgb, var(--ui-border) 70%, #fff 30%);
    transform: none;
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--ui-border) 55%, transparent);
}

.tool-btn.active,
.timeframe-btn.active,
.multi-btn.active,
.theme-btn.active,
.tab-btn.active {
    background: color-mix(in srgb, var(--ui-accent) 82%, #1e2b45 18%);
    border-color: var(--ui-accent-strong);
    color: #f3f7ff;
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--ui-accent) 38%, transparent);
}

body.light-theme .tool-btn.active,
body.light-theme .timeframe-btn.active,
body.light-theme .multi-btn.active,
body.light-theme .theme-btn.active,
body.light-theme .tab-btn.active {
    background: color-mix(in srgb, var(--ui-accent) 88%, #ffffff 12%);
    color: #ffffff;
    border-color: var(--ui-accent-strong);
}

.tab-btn,
.timeframe-btn {
    font-weight: 600;
}

.settings-panel,
.history-sidebar,
.left-toolbar,
.top-bar {
    background: color-mix(in srgb, var(--ui-surface) 94%, #000 6%);
    border-color: var(--ui-border);
}

body.light-theme .settings-panel,
body.light-theme .history-sidebar,
body.light-theme .left-toolbar,
body.light-theme .top-bar {
    background: color-mix(in srgb, #ffffff 92%, #f2f5fa 8%);
}

.search-input,
.settings-panel select,
.settings-panel input[type="number"],
.auth-input {
    border-color: var(--ui-border);
    background: color-mix(in srgb, var(--ui-surface-2) 92%, #000 8%);
}

body.light-theme .search-input,
body.light-theme .settings-panel select,
body.light-theme .settings-panel input[type="number"],
body.light-theme .auth-input {
    background: #ffffff;
}

/* ====================== LIGHT THEME: BUTTON CONSISTENCY ====================== */
body.light-theme .layout-panel {
    width: 176px;
}

body.light-theme .layout-panel .layout-option-btn {
    font-size: 16px;
    padding: 7px 8px;
}

body.light-theme .tool-btn,
body.light-theme .timeframe-btn,
body.light-theme .multi-btn,
body.light-theme .indicators-btn,
body.light-theme .settings-btn,
body.light-theme .tab-btn,
body.light-theme .theme-btn,
body.light-theme .layout-option-btn,
body.light-theme .auth-top-btn,
body.light-theme .auth-logout-btn,
body.light-theme .auth-tab,
body.light-theme .ema-modal-close {
    background: #ffffff;
    color: #1b2533;
    border-color: #cfd6e0;
}

body.light-theme .tool-btn:not(.active):hover,
body.light-theme .timeframe-btn:not(.active):hover,
body.light-theme .multi-btn:not(.active):hover,
body.light-theme .indicators-btn:not(.active):hover,
body.light-theme .settings-btn:not(.active):hover,
body.light-theme .tab-btn:not(.active):hover,
body.light-theme .theme-btn:not(.active):hover,
body.light-theme .layout-option-btn:not(.active):hover,
body.light-theme .auth-top-btn:hover,
body.light-theme .auth-logout-btn:hover,
body.light-theme .auth-tab:not(.active):hover,
body.light-theme .ema-modal-close:hover {
    background: #e4e7ec;
    border-color: #bac3d0;
    color: #1b2533;
}

body.light-theme .tool-btn.active,
body.light-theme .timeframe-btn.active,
body.light-theme .multi-btn.active,
body.light-theme .indicators-btn.active,
body.light-theme .settings-btn.active,
body.light-theme .tab-btn.active,
body.light-theme .theme-btn.active,
body.light-theme .layout-option-btn.active,
body.light-theme .auth-tab.active,
body.light-theme #layout-btn.active {
    background: #178f68;
    border-color: #117453;
    color: #ffffff;
}

/* Keep pairs columns controls in the same visual system as all other buttons/panels. */
.columns-toggle-btn {
    background: var(--ui-surface-2);
    border-color: var(--ui-border);
    color: var(--ui-text);
}

.columns-toggle-btn:hover {
    background: color-mix(in srgb, var(--ui-surface-2) 86%, #fff 14%);
    border-color: color-mix(in srgb, var(--ui-border) 70%, #fff 30%);
}

.columns-toggle-btn.active {
    background: color-mix(in srgb, var(--ui-accent) 82%, #1e2b45 18%);
    border-color: var(--ui-accent-strong);
    color: #f3f7ff;
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--ui-accent) 38%, transparent);
}

.pairs-columns-panel {
    background: color-mix(in srgb, var(--ui-surface) 96%, #000 4%);
    border-color: var(--ui-border);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--ui-border) 55%, transparent), var(--ui-shadow);
}

.pairs-columns-panel label {
    color: var(--ui-text);
}

body.light-theme .columns-toggle-btn.active {
    background: #178f68;
    border-color: #117453;
    color: #ffffff;
}

/* Final layout-panel unification layer (both themes). */
#layout-panel .layout-option-btn {
    min-height: 34px;
    background: var(--ui-surface-2);
    border: 1px solid var(--ui-border);
    color: var(--ui-text);
    box-shadow: none;
}

#layout-panel .layout-option-btn:hover {
    background: color-mix(in srgb, var(--ui-surface-2) 86%, #fff 14%);
    border-color: color-mix(in srgb, var(--ui-border) 70%, #fff 30%);
}

#layout-panel .layout-option-btn.active {
    background: color-mix(in srgb, var(--ui-accent) 82%, #1e2b45 18%);
    border-color: var(--ui-accent-strong);
    color: #f3f7ff;
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--ui-accent) 38%, transparent);
}

body.light-theme #layout-panel .layout-option-btn.active {
    background: #178f68;
    border-color: #117453;
    color: #ffffff;
}