/* fonts.css is linked directly from index.html — an @import here would serialise
   the request behind this file and hide it from the preload scanner. */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #0d0f14;
    --bg2: #13151e;
    --bg3: #181b26;
    --bgh: #1e2235;
    --bgh2: #252c3f;
    --bd: rgba(255, 255, 255, 0.06);
    --bd2: rgba(255, 255, 255, 0.12);
    --t1: #d1d4dc;
    --t2: #6b7080;
    --t3: #363a45;
    --gr: #26c97a;
    --grglow: rgba(38, 201, 122, 0.35);
    --rd: #ff4560;
    --rdglow: rgba(255, 69, 96, 0.35);
    --ac: #7c3aed;
    --acglow: rgba(124, 58, 237, 0.45);
    --bn: #f59e0b;
    --bb: #3b82f6;
    --ox: #8b5cf6;
    --radius: 6px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'JetBrains Mono', 'Roboto Mono', 'SF Mono', Menlo, Monaco, Consolas, monospace;
    --table-grid: minmax(60px, 1.5fr) 46px 52px 34px 44px 34px;
}

html,
body {
    height: 100%;
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
    background: var(--bg);
    color: var(--t1);
    overflow: hidden;
}

input, button, select, textarea, optgroup, table, th, td {
    font-family: inherit;
}

::-webkit-scrollbar {
    width: 3px;
    height: 3px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bd2);
    border-radius: 2px;
}

/* ── Layout ── */
button {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font: inherit;
    color: inherit;
    outline: none;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
    background: var(--bg);
}

#nav {
    display: flex;
    align-items: center;
    height: 44px;
    background: var(--screener-header-bg, #13151e);
    border-bottom: 1px solid var(--bd);
    padding: 0 16px;
    gap: 20px;
    flex-shrink: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.5px;
    margin-right: 24px;
    user-select: none;
}

.logo-img {
    height: 24px;
    width: auto;
    object-fit: contain;
    margin-right: 6px;
    filter: drop-shadow(0 0 6px rgba(171, 71, 188, 0.4));
    transition: transform 0.2s ease, filter 0.2s ease;
}

.logo:hover .logo-img {
    transform: scale(1.08);
    filter: drop-shadow(0 0 10px rgba(171, 71, 188, 0.7));
}

.logo-c {
    color: var(--ac);
}

.logo-rest {
    color: var(--t1);
}

.ntabs {
    display: flex;
    gap: 2px;
}

.ntab {
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    color: var(--t2);
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.15s, color 0.15s;
    user-select: none;
}

.ntab:hover {
    color: var(--t1);
    background: var(--bgh);
}

.ntab.on {
    color: #fff;
    background: var(--ac);
}

.nright {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sbox {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--screener-header-bg, var(--bg3));
    border: 1px solid var(--bd);
    border-radius: var(--radius);
    padding: 0 10px;
    height: 30px;
    width: 160px;
    transition: border-color 0.12s;
}

.sbox:focus-within {
    border-color: var(--bd2);
}

.sbox input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--t1);
    font-size: 12px;
    font-family: var(--font);
    width: 100%;
}

.sbox input::placeholder {
    color: var(--t3);
}

.sico {
    color: var(--t3);
    font-size: 13px;
    flex-shrink: 0;
}

.lang-btn {
    padding: 4px 10px;
    background: var(--screener-header-bg, var(--bg3));
    border: 1px solid var(--bd);
    border-radius: var(--radius);
    color: var(--t2);
    font-size: 11px;
    cursor: pointer;
    font-family: var(--font);
}

.settings-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--screener-header-bg, var(--bg3));
    border: 1px solid var(--bd);
    border-radius: var(--radius);
    color: var(--t2);
    cursor: pointer;
    transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}

.settings-btn:hover {
    color: var(--t1);
    border-color: var(--bd2);
    background: var(--bgh);
}

.settings-btn svg {
    transition: transform 0.4s ease;
}

.settings-btn:hover svg {
    transform: rotate(45deg);
}

#main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

#dt {
    width: 28px;
    background: var(--bg2);
    border-right: 1px solid var(--bd);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 0;
    gap: 4px;
    flex-shrink: 0;
}

.dtb {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--t3);
    cursor: pointer;
    border-radius: 4px;
    font-size: 12px;
    transition: background-color 0.12s, color 0.12s;
}

.dtb:hover {
    color: var(--t1);
    background: var(--bgh);
}

/* ── Chart toolbar ── */
#chart-area {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    min-width: 0;
}

#ctbar {
    display: flex;
    align-items: center;
    height: 34px;
    background: var(--screener-header-bg, rgba(13, 15, 20, 0.98));
    border-bottom: 1px solid var(--bd);
    padding: 0 6px;
    gap: 4px;
    flex-shrink: 0;
    white-space: nowrap;
    overflow-x: auto;
    overflow-y: visible;
    scrollbar-width: none;
    position: relative;
}

#ctbar::-webkit-scrollbar {
    display: none;
}

.sym-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    background: transparent;
    transition: background 0.1s;
    user-select: none;
    flex-shrink: 0;
}

.sym-btn:hover {
    background: var(--bgh);
}

.sym-chg {
    font-size: 11px;
    font-weight: 600;
    display: inline-block;
    text-align: left;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
    font-family: var(--font);
    min-width: 65px;
    flex-shrink: 0;
}

.sym-chg.pos {
    color: var(--gr);
}

.sym-chg.neg {
    color: var(--rd);
}

.tfg {
    display: flex;
    gap: 2px;
    align-items: center;
    flex-shrink: 0;
}

.tfb {
    padding: 2px 5px;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--t2);
    cursor: pointer;
    border-radius: 3px;
    border: none;
    background: transparent;
    font-family: var(--font);
    transition: background-color 0.15s, color 0.15s;
    user-select: none;
    min-width: 22px;
    text-align: center;
}

.tfb:hover {
    color: var(--t1);
    background: var(--bgh);
}

.tfb.on {
    color: #fff;
    background: var(--ac);
}

.sep {
    width: 1px;
    height: 16px;
    background: var(--bd);
    flex-shrink: 0;
    margin: 0 4px;
}

.stat {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    margin-right: 4px;
    flex-shrink: 0;
    white-space: nowrap;
}

.stat:nth-child(n+3) {
    margin-right: 4px;
}

.sl {
    color: var(--t2);
    font-size: 10.5px;
    flex-shrink: 0;
}

.sv {
    color: var(--t1);
    font-weight: 600;
    display: inline-block;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
    font-family: var(--font);
    flex-shrink: 0;
}

.sv.pos {
    color: var(--gr);
}

.sv.neg {
    color: var(--rd);
}

#schg {
    min-width: 65px;
}

#sv {
    min-width: 48px;
}

#snatr {
    min-width: 36px;
}

#scorr {
    min-width: 28px;
}

#sfun {
    min-width: 135px;
}

#soi {
    min-width: 52px;
}

/* ── Exchange Dropdown ── */
.exc-wrap {
    margin-left: auto;
    margin-left: auto;
    position: relative;
    padding-right: 8px;
    flex-shrink: 0 !important;
    z-index: 10000;
}

.exc-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 11px;
    background: var(--bg3);
    border: 1px solid var(--bd);
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--t1);
    user-select: none;
    transition: background-color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease, outline-color 0.12s ease;
    min-width: 0;
    max-width: none;
    overflow: visible;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    outline: none !important;
}

.exc-btn:focus,
.exc-btn:focus-visible {
    outline: none !important;
    border-color: var(--ac);
}

.exc-btn:hover {
    border-color: var(--bd2);
    background: var(--bgh);
}

.exc-btn.open {
    border-color: var(--ac);
    box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.25);
    background: var(--bgh);
}

.exc-dot {
    width: 24px;
    height: 18px;
    border-radius: 2px;
    flex-shrink: 0;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-size: contain !important;
    opacity: 1 !important;
}

.exc-arrow {
    flex-shrink: 0;
    font-size: 9px;
    color: var(--t2);
    margin-left: auto;
    transition: transform 0.2s;
}

.exc-btn.open .exc-arrow {
    transform: rotate(180deg);
}

.exc-menu {
    position: fixed !important;
    top: auto;
    right: auto;
    min-width: 220px;
    background: #13151e !important;
    border: 1px solid var(--bd2);
    border-radius: 10px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.85);
    z-index: 999999 !important;
    overflow: hidden;
    display: none;
    animation: fadeIn 0.15s ease;
}

.exc-menu.open {
    display: block !important;
}

/* Multichart View: Hide single-coin stats and sym-btn in #ctbar to give ample room for multichart toolbar controls and exchange selector */
body.view-is-multichart #ctbar .stat,
body.view-is-multichart #ctbar .sep:nth-of-type(n+2),
body.view-is-multichart #ctbar #sym-btn {
    display: none !important;
}

body.view-is-multichart #ctbar .grid-config {
    display: flex !important;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

#ctbar #exc-wrap {
    margin-left: auto;
    position: relative;
    padding-right: 14px;
    margin-right: 4px;
    flex-shrink: 0 !important;
    z-index: 10000;
}

#ctbar #exc-btn {
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    min-width: max-content;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.exc-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 13px;
    font-size: 12px;
    font-weight: 500;
    color: var(--t1);
    cursor: pointer;
    transition: background-color 0.1s, border-bottom-color 0.1s, color 0.1s, opacity 0.1s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.exc-item:last-child {
    border-bottom: none;
}

.exc-item:hover {
    background: var(--bgh);
    color: var(--t1);
}

.exc-item.on {
    color: var(--t1);
    background: var(--bgh2);
}

.exc-item.on .exc-dot {
    box-shadow: none;
}

.exc-item.disabled {
    opacity: 1;
    cursor: pointer;
    pointer-events: auto;
}

.exc-soon {
    margin-left: auto;
    font-size: 9px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 3px;
    background: var(--bg2);
    color: var(--t3);
    letter-spacing: 0.3px;
}

.exc-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.exc-pro-badge {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 9.5px;
    font-weight: 700;
    line-height: 1;
    padding: 2.5px 6px;
    border-radius: 4px;
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.20), rgba(245, 158, 11, 0.08));
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.35);
    box-shadow: 0 0 8px rgba(251, 191, 36, 0.12);
    letter-spacing: 0.5px;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
    user-select: none;
}

.exc-free-tag {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
    padding: 2px 5px;
    border-radius: 4px;
    background: rgba(38, 201, 122, 0.12);
    color: #26c97a;
    border: 1px solid rgba(38, 201, 122, 0.25);
    letter-spacing: 0.5px;
    user-select: none;
}

.exc-item[data-pro-only="true"]:hover .exc-pro-badge {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.32), rgba(245, 158, 11, 0.18));
    border-color: rgba(251, 191, 36, 0.6);
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.3);
    transform: scale(1.05);
}

body.user-is-pro .exc-pro-badge {
    display: none;
}

body.user-is-pro .exc-free-tag {
    display: none;
}

/* ── View Toggle (Chart/Heatmap) ── */
.view-toggle {
    display: flex;
    gap: 4px;
    background: var(--screener-header-bg, var(--bg3));
    padding: 2px;
    border-radius: var(--radius);
    border: 1px solid var(--bd);
}

.vt-btn {
    width: 28px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--t2);
    cursor: pointer;
    border-radius: 4px;
    border: none;
    background: transparent;
    transition: background-color 0.1s, color 0.1s;
}

.vt-btn:hover {
    color: var(--t1);
    background: var(--bgh);
}

.vt-btn.on {
    color: #fff;
    background: var(--ac);
}

.chart-density-toggle {
    display: flex;
    align-items: center;
    gap: 7px;
    height: 28px;
    padding: 0 10px;
    border: 1px solid var(--bd);
    border-radius: 8px;
    background:
        linear-gradient(180deg, rgba(36, 39, 57, 0.96) 0%, rgba(18, 20, 30, 0.98) 100%);
    color: var(--t2);
    font-size: 12px;
    font-weight: 600;
    transition: border-color 0.14s ease, box-shadow 0.14s ease, color 0.14s ease;
    flex-shrink: 0;
}

.chart-density-toggle:hover {
    color: var(--t1);
    border-color: rgba(124, 58, 237, 0.28);
    box-shadow: 0 0 0 1px rgba(124, 58, 237, 0.08);
}

.chart-density-toggle.on {
    color: #f5f3ff;
    border-color: rgba(124, 58, 237, 0.55);
    box-shadow:
        0 0 0 1px rgba(124, 58, 237, 0.14),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.chart-density-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.chart-density-toggle-count {
    min-width: 22px;
    height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(124, 58, 237, 0.16);
    color: #c4b5fd;
    font-size: 10px;
    font-weight: 700;
}

.chart-density-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 18px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    padding: 0;
    outline: none;
}

.chart-density-switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.45);
    transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1), left 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.chart-density-switch:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
}

.chart-density-switch.on {
    background: #16c784;
    border-color: rgba(22, 199, 132, 0.4);
}

.chart-density-switch.on::after {
    left: 20px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.chart-density-settings-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--bd);
    border-radius: 8px;
    background:
        linear-gradient(180deg, rgba(36, 39, 57, 0.96) 0%, rgba(18, 20, 30, 0.98) 100%);
    color: var(--t2);
    cursor: pointer;
    transition: border-color 0.14s ease, box-shadow 0.14s ease, color 0.14s ease;
    flex-shrink: 0;
}

.chart-density-settings-toggle:hover {
    color: var(--t1);
    border-color: rgba(124, 58, 237, 0.28);
    box-shadow: 0 0 0 1px rgba(124, 58, 237, 0.08);
}

.chart-density-settings-toggle.on {
    color: #f5f3ff;
    border-color: rgba(124, 58, 237, 0.55);
    box-shadow:
        0 0 0 1px rgba(124, 58, 237, 0.14),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* ── Grid Config ── */
.grid-config {
    display: flex;
    align-items: center;
    gap: 10px;
}

.grid-select {
    display: none;
}

/* ── Custom Grid Select ── */
.custom-grid-select-wrap {
    position: relative;
    display: inline-block;
    user-select: none;
}

.custom-grid-select-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    background: var(--bg2);
    border: 1px solid var(--ac);
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--t1);
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    height: 24px;
    min-width: 105px;
    box-sizing: border-box;
}

.custom-grid-select-btn:hover {
    border-color: var(--acglow);
    background: var(--bgh);
}

.custom-grid-select-btn.open {
    border-color: var(--ac);
    background: var(--bgh2);
    box-shadow: 0 0 0 2px var(--acglow);
}

.custom-grid-select-arrow {
    font-size: 8px;
    color: var(--t2);
    margin-left: auto;
    transition: transform 0.2s ease;
}

.custom-grid-select-btn.open .custom-grid-select-arrow {
    transform: rotate(180deg);
}

.custom-grid-select-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 120px;
    background: var(--screener-header-bg, var(--bg3));
    border: 1px solid var(--bd2);
    border-radius: 6px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 15px rgba(124, 58, 237, 0.1);
    z-index: 1000;
    overflow: hidden;
    display: none;
}

.custom-grid-select-menu.open {
    display: block;
    animation: customFadeIn 0.15s ease forwards;
}

@keyframes customFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.custom-grid-select-item {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--t1);
    cursor: pointer;
    transition: background-color 0.15s ease, border-bottom-color 0.15s ease, color 0.15s ease, padding-left 0.15s ease;
    border-bottom: 1px solid var(--bd);
    box-sizing: border-box;
}

.custom-grid-select-item:last-child {
    border-bottom: none;
}

.custom-grid-select-item:hover {
    background: rgba(124, 58, 237, 0.12);
    color: var(--t1);
    padding-left: 14px;
}

.custom-grid-select-item.on {
    color: #fff;
    background: var(--ac);
    font-weight: 600;
}

.grid-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--screener-header-bg, var(--bg3));
    border: 1px solid var(--bd);
    border-radius: 4px;
    padding: 2px 6px;
}

.grid-nav-btn {
    background: transparent;
    border: none;
    color: var(--t2);
    cursor: pointer;
    font-size: 10px;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.1s;
}

.grid-nav-btn:hover {
    color: var(--ac);
}

.grid-page-num {
    font-size: 10px;
    font-weight: 700;
    color: var(--t1);
    min-width: 40px;
    text-align: center;
}

/* ── Multi-Chart Grid ── */
#chart-grid-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: grid;
    background: #1a1c22; /* Серо-черный фон для сетки */
    gap: 4px; /* Более широкие зазоры */
    padding: 4px;
    z-index: 40;
}

.grid-cell {
    position: relative;
    background: transparent; /* Background handled by canvas fill */
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid transparent; /* Убрана обводка по умолчанию */
    border-radius: 4px;
    transition: border-color 0.15s;
}

.grid-cell:hover {
    border-color: rgba(255, 255, 255, 0.05);
}

.cell-header {
    height: 26px;
    background: #1e222d;
    display: flex;
    align-items: center;
    padding: 0 8px;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
    border-bottom: 1px solid #2a2e39;
}

.cell-header-left {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cell-ex-icon {
    width: 22px;
    height: 14px;
    border-radius: 2px;
}

.cell-tf {
    font-size: 11px;
    background: rgba(255, 255, 255, 0.05);
    padding: 1px 4px;
    border-radius: 3px;
    color: var(--t2);
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
}

.cell-tf:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* ── Mini TF Menu ── */
#mini-tf-menu {
    position: absolute;
    background: #1e222d;
    border: 1px solid #3d4250;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    z-index: 2100;
    display: none;
    flex-direction: column;
    padding: 4px;
}

.mini-tf-item {
    padding: 4px 12px;
    cursor: pointer;
    font-size: 11px;
    color: #d1d4dc;
    border-radius: 2px;
}

.mini-tf-item:hover {
    background: #2a2e39;
    color: #fff;
}

.mini-tf-item.on {
    color: #5e3aee;
    font-weight: 700;
}

.cell-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cell-fs-btn {
    cursor: pointer;
    color: var(--t3);
    display: flex;
    align-items: center;
    opacity: 0.5;
    transition: opacity 0.15s, color 0.15s;
    padding: 2px;
    border-radius: 3px;
}

.cell-fs-btn:hover {
    opacity: 1;
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.cell-price {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: #d1d4dc;
    letter-spacing: -0.2px;
}

.cell-sym { 
    color: #d1d4dc; 
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background 0.1s;
}
.cell-sym:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* ── Mini Chart Search ── */
#mini-search-box {
    position: absolute;
    background: #1e222d;
    border: 1px solid #3d4250;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    z-index: 2000;
    display: none;
    flex-direction: column;
    width: 220px;
    overflow: hidden;
}

#mini-search-input {
    background: #0d0f14;
    border: none;
    border-bottom: 1px solid #2a2e39;
    color: #fff;
    padding: 8px 12px;
    font-size: 13px;
    width: 100%;
    outline: none;
}

#mini-search-results {
    max-height: 250px;
    overflow-y: auto;
}

.mini-search-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 12px;
    color: #d1d4dc;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

.mini-search-item:hover {
    background: #2a2e39;
    color: #fff;
}

.msi-ex {
    font-size: 9px;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
    background: rgba(255,255,255,0.1);
    color: #aaa;
}
.cell-chg { font-size: 10px; font-weight: 600; }
.cell-chg.pos { color: #26a69a; }
.cell-chg.neg { color: #ef5350; }

.cell-canvas-wrap {
    flex: 1;
    position: relative;
    background: #0d0f14;
}

.cell-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.grid-cell[hidden] { display: none; }

/* .grid-cell.active {
    border-color: var(--ac);
    box-shadow: 0 0 0 1px var(--ac);
    z-index: 5;
} */

/* ── Screener Heatmap ── */
#screener-heatmap {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    z-index: 50;
    display: flex;
    flex-direction: column;
}

#sh-toolbar {
    height: 32px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    background: var(--bg2);
    border-bottom: 1px solid var(--bd);
}

.sh-sort-btn {
    padding: 2px 10px;
    font-size: 10px;
    font-weight: 700;
    color: var(--t2);
    background: var(--bg3);
    border: 1px solid var(--bd);
    border-radius: 4px;
    cursor: pointer;
}

.sh-sort-btn.on {
    color: #fff;
    background: var(--ac);
    border-color: var(--ac);
}

#sh-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    grid-auto-rows: minmax(60px, auto);
    gap: 1px;
    padding: 1px;
    overflow-y: auto;
    background: var(--bd);
}

.sh-item {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 8px;
    cursor: pointer;
    transition: transform 0.1s, filter 0.1s;
}

.sh-item:hover {
    filter: brightness(1.2);
    z-index: 10;
}

.sh-sym {
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 1px rgba(0,0,0,0.4);
}

.sh-chg {
    font-size: 10px;
    font-weight: 600;
    color: rgba(255,255,255,0.9);
}

.sh-vol {
    font-size: 9px;
    color: rgba(255,255,255,0.5);
}

.density-exc-wrap {
    position: relative;
}

.density-exc-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg3);
    border: 1px solid var(--bd);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--t1);
    user-select: none;
    transition: background-color 0.12s, border-color 0.12s, box-shadow 0.12s;
    min-width: 140px;
    justify-content: space-between;
}

.density-exc-btn:hover {
    border-color: var(--bd2);
    background: var(--bgh);
}

.density-exc-btn.open {
    border-color: var(--ac);
    box-shadow: 0 0 0 1px rgba(124, 58, 237, 0.15);
}

.density-exc-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: max-content;
    min-width: 195px;
    background: var(--bg3);
    border: 1px solid var(--bd2);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
    animation: fadeIn 0.15s ease;
    max-height: 400px;
    overflow-y: auto;
}

.density-exc-menu.open {
    display: block;
}

.density-exc-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--t2);
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    user-select: none;
}

.density-exc-item:last-child {
    border-bottom: none;
}

.density-exc-item:hover {
    background: var(--bgh);
    color: var(--t1);
}

.density-exc-item.all {
    background: var(--bg2);
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid var(--bd2);
}

.dex-cb, .dex-cb-all {
    appearance: none;
    background-color: transparent;
    margin: 0;
    font: inherit;
    color: currentColor;
    width: 16px;
    height: 16px;
    border: 1px solid var(--bd2);
    border-radius: 4px;
    display: grid;
    place-content: center;
    cursor: pointer;
    transition: background-color 0.1s, border-color 0.1s;
    flex-shrink: 0;
}

.dex-cb:checked, .dex-cb-all:checked {
    background-color: var(--ac);
    border-color: var(--ac);
}

.dex-cb::before, .dex-cb-all::before {
    content: "";
    width: 9px;
    height: 9px;
    transform: scale(0);
    transition: 120ms transform ease-in-out;
    box-shadow: inset 1em 1em white;
    transform-origin: bottom left;
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

.dex-cb:checked::before, .dex-cb-all:checked::before {
    transform: scale(1);
}

.dex-name {
    flex: 1;
}

.chart-density-panel {
    position: absolute;
    top: 12px;
    right: 14px;
    z-index: 80;
    width: 320px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(124, 58, 237, 0.4) transparent;
    display: none;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    border: 1px solid rgba(124, 58, 237, 0.2);
    border-radius: 14px;
    background:
        linear-gradient(180deg, rgba(21, 24, 37, 0.94) 0%, rgba(11, 13, 21, 0.96) 100%);
    backdrop-filter: blur(18px);
    box-shadow:
        0 22px 60px rgba(0, 0, 0, 0.48),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.chart-density-panel::-webkit-scrollbar {
    width: 4px;
}
.chart-density-panel::-webkit-scrollbar-thumb {
    background: rgba(124, 58, 237, 0.4);
    border-radius: 4px;
}

.chart-density-panel.open {
    display: flex;
}


#chart-formations-panel {
    position: absolute;
    top: 12px;
    left: 44px;
    right: auto;
    z-index: 85;
}

/* ── Indicators Panel ───────────────────────────────────────────────────────── */
.chart-indicators-panel {
    position: absolute;
    top: 12px;
    left: 44px;
    z-index: 80;
    width: 300px;
    max-height: calc(100% - 24px);
    overflow-y: auto;
    display: none;
    flex-direction: column;
    gap: 8px;
    padding: 14px;
    border: 1px solid rgba(124, 58, 237, 0.2);
    border-radius: 14px;
    background:
        linear-gradient(180deg, rgba(21, 24, 37, 0.96) 0%, rgba(11, 13, 21, 0.98) 100%);
    backdrop-filter: blur(18px);
    box-shadow:
        0 22px 60px rgba(0, 0, 0, 0.48),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.chart-indicators-panel::-webkit-scrollbar {
    width: 4px;
}
.chart-indicators-panel::-webkit-scrollbar-thumb {
    background: rgba(124, 58, 237, 0.3);
    border-radius: 4px;
}

.chart-indicators-panel.open {
    display: flex;
}

.indicator-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.02);
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.indicator-card:hover {
    background: rgba(255, 255, 255, 0.045);
    border-color: rgba(255, 255, 255, 0.1);
}

.indicator-card.on {
    border-color: rgba(124, 58, 237, 0.35);
    background: rgba(124, 58, 237, 0.06);
}

.indicator-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.indicator-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.indicator-name {
    flex: 1;
    font-size: 12.5px;
    font-weight: 700;
    color: #f5f3ff;
    letter-spacing: 0.02em;
}

.indicator-toggle {
    height: 24px;
    padding: 0 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--t2);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

.indicator-toggle:hover {
    color: var(--t1);
    background: rgba(255, 255, 255, 0.08);
}

.indicator-toggle.on {
    color: #fff;
    background: linear-gradient(180deg, rgba(22, 199, 132, 0.85) 0%, rgba(16, 163, 108, 0.9) 100%);
    border-color: rgba(22, 199, 132, 0.6);
    box-shadow: 0 4px 12px rgba(22, 199, 132, 0.2);
}

.indicator-desc {
    font-size: 10.5px;
    line-height: 1.45;
    color: rgba(209, 212, 220, 0.4);
    transition: color 0.15s ease;
}

.indicator-card:hover .indicator-desc {
    color: rgba(209, 212, 220, 0.65);
}

.chart-density-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.chart-density-panel-title {
    font-size: 14px;
    font-weight: 700;
    color: #f5f3ff;
}

.chart-density-panel-subtitle {
    margin-top: 4px;
    font-size: 11px;
    color: var(--t2);
}

.chart-density-close {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.03);
    color: var(--t2);
    font-size: 15px;
    transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
    flex-shrink: 0;
}

.chart-density-close:hover {
    color: var(--t1);
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
}

.chart-density-panel-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.formation-touch-menu {
    position: fixed;
    z-index: 10050;
    width: 176px;
    padding: 8px;
    border: 1px solid rgba(139, 92, 246, .4);
    border-radius: 10px;
    background: #121521;
    box-shadow: 0 16px 38px rgba(0, 0, 0, .48);
}

.formation-touch-menu-title { padding: 3px 5px 8px; color: var(--t2); font-size: 10px; font-weight: 700; }
.formation-touch-menu-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.formation-touch-menu button { height: 29px; border: 1px solid rgba(255,255,255,.1); border-radius: 6px; background: #1b1f2d; color: var(--t2); font: 700 11px var(--font); cursor: pointer; }
.formation-touch-menu button:hover, .formation-touch-menu button.on { border-color: rgba(167,139,250,.85); background: #5b28bf; color: #fff; box-shadow: 0 3px 10px rgba(91,40,191,.32); }

.chart-density-section-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(209, 212, 220, 0.42);
}

.chart-density-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chart-density-filter-btn {
    height: 28px;
    padding: 0 11px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--t2);
    font-size: 12px;
    font-weight: 600;
    transition: background-color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease, color 0.12s ease;
}

.chart-density-filter-btn:hover {
    color: var(--t1);
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
}

.chart-density-filter-btn.on {
    color: #fff;
    background: linear-gradient(180deg, rgba(124, 58, 237, 0.95) 0%, rgba(109, 40, 217, 0.95) 100%);
    border-color: rgba(139, 92, 246, 0.75);
    box-shadow: 0 8px 18px rgba(109, 40, 217, 0.18);
}

.chart-density-indicators-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.chart-indicator-grid-btn {
    height: 28px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--t2);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease, color 0.12s ease;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 4px;
}

.chart-indicator-grid-btn:hover {
    color: var(--t1);
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
}

.chart-indicator-grid-btn.on {
    color: #fff;
    background: linear-gradient(180deg, rgba(124, 58, 237, 0.95) 0%, rgba(109, 40, 217, 0.95) 100%);
    border-color: rgba(139, 92, 246, 0.75);
    box-shadow: 0 4px 12px rgba(109, 40, 217, 0.15);
}

.chart-indicator-info-box {
    margin-top: 4px;
    padding: 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 10.5px;
    line-height: 1.4;
    color: rgba(209, 212, 220, 0.45);
    min-height: 48px;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.chart-density-exc-wrap {
    position: relative;
}

.chart-density-exc-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 8px 11px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 9px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--t1);
    transition: background-color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.chart-density-exc-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
}

.chart-density-exc-btn.open {
    border-color: rgba(124, 58, 237, 0.55);
    box-shadow: 0 0 0 1px rgba(124, 58, 237, 0.12);
}

.chart-density-exc-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 100%;
    max-height: 300px;
    overflow-y: auto;
    display: none;
    background: rgba(15, 17, 28, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.48);
}

.chart-density-exc-menu.open {
    display: block;
}

.chart-density-exc-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    color: var(--t2);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    transition: background 0.1s ease, color 0.1s ease;
}

.chart-density-exc-item:last-child {
    border-bottom: none;
}

.chart-density-exc-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--t1);
}

.chart-density-exc-item.all {
    position: sticky;
    top: 0;
    z-index: 5;
    background: rgba(20, 23, 36, 0.98);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.chart-dex-cb,
.chart-dex-cb-all {
    appearance: none;
    background-color: transparent;
    margin: 0;
    width: 16px;
    height: 16px;
    border: 1px solid var(--bd2);
    border-radius: 4px;
    display: grid;
    place-content: center;
    cursor: pointer;
    transition: background-color 0.1s, border-color 0.1s;
    flex-shrink: 0;
}

.chart-dex-cb:checked,
.chart-dex-cb-all:checked {
    background-color: var(--ac);
    border-color: var(--ac);
}

.chart-dex-cb::before,
.chart-dex-cb-all::before {
    content: "";
    width: 9px;
    height: 9px;
    transform: scale(0);
    transition: 120ms transform ease-in-out;
    box-shadow: inset 1em 1em white;
    transform-origin: bottom left;
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

.chart-dex-cb:checked::before,
.chart-dex-cb-all:checked::before {
    transform: scale(1);
}

/* ── Chart ── */
#cwrap {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: transparent; /* Fill handled by canvas */
}

/* ── Drawing tools — floating vertical panel inside cwrap ── */
#draw-tools {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 5px 3px;
    background: #1e222d;
    border: 1px solid #2a2e39;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
    user-select: none;
    min-width: 32px;
}

/* ── Settings Modal ── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.modal-overlay.open {
    display: flex;
}

.settings-modal {
    width: 680px;
    max-width: 95vw;
    height: 580px;
    max-height: 90vh;
    background: #13151e;
    border: 1px solid var(--bd2);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,0.6);
    animation: modalScale 0.2s ease-out;
}


@keyframes modalScale {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.settings-body {
    flex: 1;
    display: flex;
    min-height: 0;
}

.settings-sidebar {
    width: 160px;
    background: #0d0f14;
    border-right: 1px solid var(--bd);
    padding: 20px 0;
    display: flex;
    flex-direction: column;
}

.settings-tab {
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--t2);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.settings-tab:hover {
    color: var(--t1);
    background: rgba(255,255,255,0.03);
}

.settings-tab.active {
    color: #fff;
    background: var(--ac);
}

.settings-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.settings-footer {
    padding: 12px 24px;
    border-top: 1px solid var(--bd);
    display: flex;
    justify-content: flex-end;
    background: #0d0f14;
}

.settings-apply-btn {
    padding: 8px 20px;
    background: var(--ac);
    color: #fff;
    border-radius: 6px;
    font-weight: 600;
    font-size: 13px;
    border: none;
    cursor: pointer;
    transition: background 0.15s;
}

.settings-apply-btn:hover {
    background: #8b5cf6;
}

.settings-pane {
    display: none;
}

.settings-pane.active {
    display: block;
}

.settings-pane h2 {
    font-size: 18px;
    margin-bottom: 20px;
    color: #fff;
}

/* Formation Overlay Settings – touch count buttons */
.fov-touch-btn {
    padding: 3px 8px;
    border-radius: 5px;
    border: 1px solid var(--bd2);
    background: var(--bg3);
    color: var(--t2);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    flex: 1;
    text-align: center;
    min-width: 32px;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.fov-touch-btn:hover {
    border-color: var(--purple);
    color: var(--t1);
}
.fov-touch-btn.active {
    background: var(--purple);
    border-color: var(--purple);
    color: #fff;
}



.settings-group {
    margin-bottom: 24px;
}

.settings-group label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--t3);
    margin-bottom: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.theme-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.theme-opt {
    padding: 10px;
    background: var(--bg3);
    border: 1px solid var(--bd);
    border-radius: 6px;
    font-size: 12px;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}

.theme-opt:hover {
    border-color: var(--bd2);
}

.theme-opt.active {
    border-color: var(--ac);
    background: rgba(124, 58, 237, 0.1);
    color: #fff;
}

/* Custom Color Picker */
.custom-color-picker {
    position: relative;
    user-select: none;
}

.color-preview {
    width: 28px;
    height: 18px;
    border-radius: 3px;
    border: 1px solid #434651;
    cursor: pointer;
    background: var(--bg);
}

.color-preview:hover {
    border-color: #5d606b;
}

.color-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #1e222d;
    border: 1px solid #363c4e;
    border-radius: 6px;
    padding: 12px;
    z-index: 100;
    display: none;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.color-dropdown.open {
    display: block;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(11, 18px);
    gap: 4px;
    margin-bottom: 8px;
}

.c-swatch {
    width: 18px;
    height: 18px;
    border-radius: 2px;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.1);
    transition: transform 0.1s;
}

.c-swatch:hover {
    transform: scale(1.15);
    border-color: #fff;
    z-index: 2;
}

.color-footer {
    border-top: 1px solid #363c4e;
    padding-top: 8px;
    display: flex;
}

.add-custom-color {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid #363c4e;
    color: #d1d4dc;
    border-radius: 4px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.add-custom-color:hover {
    background: #2a2e39;
    color: #fff;
    border-color: #4c5265;
}

.opacity-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

.opacity-control input[type="range"] {
    width: 80px;
    height: 4px;
    background: var(--bg3);
    border-radius: 2px;
    appearance: none;
    outline: none;
}

.opacity-control input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 12px;
    height: 12px;
    background: var(--ac);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s;
}

.opacity-control input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.opacity-control span {
    font-size: 11px;
    color: var(--t2);
    min-width: 30px;
}

/* Dual pickers for candles */
.candle-settings-rows {
    display: flex;
    flex-direction: column;
}

.dual-pickers {
    display: flex;
    gap: 8px;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    color: var(--t1);
    transition: color 0.2s;
    height: 100%;
}

.check-row:hover {
    color: #fff;
}

.beautiful-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--bg3);
    border: 1px solid var(--bd2);
    border-radius: 5px;
    cursor: pointer;
    position: relative;
    transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    margin: 0; /* Important for alignment */
}

.beautiful-checkbox:checked {
    background: var(--ac);
    border-color: var(--ac);
    box-shadow: 0 0 10px var(--acglow);
}

.beautiful-checkbox:checked::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 1px; /* Center vertically inside 18px box */
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.beautiful-checkbox:hover {
    border-color: var(--ac);
    background: var(--bgh);
}

.s-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--bd);
}

.s-row:last-child {
    border-bottom: none;
}

.s-row span {
    font-size: 13px;
    color: var(--t1);
}

.settings-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    color: var(--t2);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.settings-close:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}

/* Switch UI */
.switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--bg3);
    transition: background-color .3s cubic-bezier(0.4, 0, 0.2, 1), border-color .3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 20px;
    border: 1px solid var(--bd2);
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px; width: 14px;
    left: 2px; bottom: 2px;
    background-color: var(--t2);
    transition: background-color .3s cubic-bezier(0.4, 0, 0.2, 1), transform .3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

input:checked + .slider { background-color: var(--ac); border-color: var(--ac); }
input:checked + .slider:before { transform: translateX(16px); background-color: #fff; }

/* Chart Back Button */
.chart-back-btn {
    width: 28px;
    height: 28px;
    background: var(--bg2);
    border: 1px solid var(--bd2);
    border-radius: 6px;
    color: var(--t2);
    display: none; /* Controlled by JS: none or flex */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s, transform 0.2s;
    flex-shrink: 0;
    margin-right: 4px;
}

.chart-back-btn:hover {
    background: var(--bg3);
    color: var(--ac);
    border-color: var(--ac);
    transform: scale(1.05);
}

.chart-back-btn svg {
    display: block;
}
/* Reset Button Styles */
.settings-reset-btn {
    padding: 6px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--t2);
    background: transparent;
    border: 1px solid var(--bd2);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
    margin-right: auto;
}

.settings-reset-btn:hover {
    color: var(--rd);
    border-color: var(--rd);
    background: rgba(255, 69, 96, 0.05);
}

.dt-btn {
    width: 26px;
    height: 26px;
    border: none;
    background: transparent;
    color: var(--tool-accent, #d1d4dc);
    cursor: pointer;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s, color 0.1s;
    flex-shrink: 0;
    position: relative;
}
.dt-btn[data-tool="none"],
.dt-btn[data-bt-tool="none"],
.dt-btn[data-j-tool="none"],
#magnet-btn,
#bt-magnet,
#clear-draw,
#bt-clear,
#j-clear-draw,
#bt-undo {
    color: #d1d4dc;
}
.dt-btn svg {
    width: 17px;
    height: 17px;
    display: block;
    flex-shrink: 0;
}
.dt-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}
.dt-btn.on {
    background: linear-gradient(180deg, #8b5cf6 0%, #6d42ff 100%);
    color: #fff;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.08) inset,
        0 0 14px rgba(109, 66, 255, 0.45);
}
.dt-btn.magnet-on {
    color: #00baff;
    background: rgba(0, 186, 255, 0.14);
}
.dt-btn.del:hover {
    background: rgba(255, 69, 96, 0.15);
    color: var(--rd);
}
/* Tooltip on hover */
.dt-btn::after {
    content: attr(title);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: rgba(18, 20, 30, 0.95);
    color: var(--t1);
    font-size: 10px;
    font-family: var(--font);
    white-space: nowrap;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.08);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 100;
}
.dt-btn:hover::after {
    opacity: 1;
}
.dt-sep {
    width: 18px;
    height: 1px;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.12) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    margin: 2px 0;
    flex-shrink: 0;
}
.dt-ico {
    font-family: sans-serif;
    font-style: normal;
}

#chart-canvas {
    position: relative;
    width: 100%;
    height: 100%;
    display: block;
}

#vol-canvas {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    pointer-events: none;
}

/* ── Resizer ── */
.resizer {
    width: 6px;
    background: transparent;
    cursor: col-resize;
    position: relative;
    z-index: 110;
    transition: background 0.1s;
    flex-shrink: 0;
}

.resizer:hover, .resizer.dragging {
    background: rgba(124, 58, 237, 0.4);
}

.resizer-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 30px;
    background: var(--bd2);
    border-radius: 2px;
}

.resizer-toggle {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 18px;
    height: 32px;
    background: var(--bg3);
    border: 1px solid var(--bd2);
    border-radius: 4px;
    color: var(--t2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 8px;
    padding: 0;
    z-index: 120;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s, transform 0.15s;
    opacity: 0;
}

.resizer:hover .resizer-toggle, .resizer.dragging .resizer-toggle {
    opacity: 1;
}

.resizer-toggle:hover {
    color: #fff;
    border-color: var(--ac);
    background: var(--ac);
}

#main.rp-collapsed #rp {
    width: 0 !important;
    min-width: 0 !important;
    border-left: none;
    overflow: hidden;
}

#main.rp-collapsed .resizer {
    width: 12px;
    background: var(--bg2);
    border-left: 1px solid var(--bd);
}

#main.rp-collapsed .resizer-toggle {
    opacity: 1;
    transform: translateX(-50%) rotate(180deg);
}

/* ── Right Panel ── */
#rp {
    max-width: 1100px;
    background: var(--screener-bg, rgba(13, 15, 20, 0.98));
    border-left: 1px solid var(--bd);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0s linear, min-width 0s linear;
}

#rp:not(.no-transition) {
    transition: width 0.2s ease, min-width 0.2s ease;
}

.rph {
    display: flex;
    align-items: center;
    padding: 8px 10px 6px;
    border-bottom: 1px solid var(--bd);
    gap: 6px;
    flex-shrink: 0;
    background: var(--screener-header-bg, transparent);
}

.rph-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--t1);
}

.cnt {
    font-size: 10px;
    color: var(--t3);
}

/* ── List headers & sort ── */
.lex {
    display: flex;
    gap: 2px;
    padding: 5px 10px;
    border-bottom: 1px solid var(--bd);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.sh {
    cursor: pointer;
    user-select: none;
    transition: color 0.12s;
    position: relative;
}

.sh:hover {
    color: var(--t1);
}

.sh.asc::after {
    content: " ↑";
    font-size: 8px;
    opacity: 0.8;
}

.sh.desc::after {
    content: " ↓";
    font-size: 8px;
    opacity: 0.8;
}

.clh {
    display: grid;
    grid-template-columns: var(--table-grid);
    column-gap: 4px;
    padding: 5px 6px 4px;
    border-bottom: 1px solid var(--bd);
    font-size: 10px;
    color: var(--t2);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
    font-weight: 700;
    overflow: hidden;
}

.cr {
    display: grid;
    grid-template-columns: var(--table-grid);
    column-gap: 4px;
    padding: 5px 6px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    align-items: center;
    transition: background 0.08s;
    font-size: 10px;
}

.clh > div, .cr > div:not(.ct) {
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ct {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

/* Hidden Columns Logic */
body.hide-col-chg #sh-chg, body.hide-col-chg .cc { display: none !important; }
body.hide-col-v #sh-v, body.hide-col-v .cv { display: none !important; }
body.hide-col-oi #sh-oi, body.hide-col-oi .coi { display: none !important; }
body.hide-col-trades #sh-trades, body.hide-col-trades .ctrades { display: none !important; }
body.hide-col-funding #sh-funding, body.hide-col-funding .cfunding { display: none !important; }
body.hide-col-corr #sh-corr, body.hide-col-corr .ccorr { display: none !important; }

.cc, .cv, .coi, .ctrades, .cfunding, .ccorr {
    padding-left: 2px;
    font-variant-numeric: tabular-nums;
}

#sh-chg {
    padding-right: 6px;
}

.cfunding {
    font-size: 10px;
    text-align: right;
    font-weight: 600;
}
.cfunding.pos { color: var(--gr); }
.cfunding.neg { color: var(--rd); }

.ccorr {
    font-size: 10px;
    text-align: right;
    font-weight: 500;
}

.coi, .ctrades {
    font-size: 10px;
    color: var(--t2);
    text-align: right;
    font-weight: 500;
}

.coi.low {
    color: var(--rd);
}

.coi.mid {
    color: var(--t2);
}

.coi.high {
    color: var(--gr);
}

.clh > div {
    text-align: right;
}

.clh > div:first-child {
    text-align: left;
}

#coin-list {
    flex: 1;
    overflow-y: auto;
}

#coin-list.compact .cr {
    height: 24px;
    min-height: 24px;
    padding: 1px 6px;
    line-height: 1;
}

#coin-list.compact .cdot {
    width: 18px;
    height: 12px;
}

#coin-list.compact .ct {
    gap: 4px;
}

#coin-list.compact .cname {
    font-size: 10px;
}

#coin-list.compact .cc, 
#coin-list.compact .cv, 
#coin-list.compact .coi, 
#coin-list.compact .ctrades, 
#coin-list.compact .ccorr {
    font-size: 9.5px;
}

.chart-animations-off #chart-area canvas,
.chart-animations-off .mc-canvas,
.chart-animations-off .chart-density-label,
.chart-animations-off .chart-density-price-badge {
    animation: none !important;
    transition: none !important;
}

/* ── Coin rows ── */
.cr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.cr.sel {
    background: rgba(124, 58, 237, 0.12);
    box-shadow: inset 2px 0 0 var(--ac);
}

.ct {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
}

.cdot {
    width: 24px;
    height: 16px;
    border-radius: 2px;
    flex-shrink: 0;
}

.cname {
    font-weight: 600;
    color: var(--t1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 11px;
}

.cc {
    text-align: right;
    font-size: 11px;
    font-weight: 500;
}

.cc.pos {
    color: var(--gr);
}

.cc.neg {
    color: var(--rd);
}

.cv {
    text-align: right;
    color: var(--t2);
    font-size: 10px;
    font-variant-numeric: tabular-nums;
}

.coi,
.ctrades {
    text-align: right;
    color: var(--t2);
    font-size: 10px;
    font-weight: 500;
}

/* ── Loading ── */
#loading {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    gap: 16px;
    transition: opacity 0.3s;
}

#loading.hide {
    opacity: 0;
    pointer-events: none;
}

.sp {
    width: 32px;
    height: 32px;
    border: 2px solid var(--bd2);
    border-top-color: var(--ac);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.lt {
    font-size: 12px;
    color: var(--t2);
}

.pb {
    width: 200px;
    height: 2px;
    background: var(--bd2);
    border-radius: 1px;
    overflow: hidden;
    margin-top: 4px;
}

.pbf {
    height: 100%;
    background: var(--ac);
    border-radius: 1px;
    width: 0;
    transition: width 0.5s ease;
}

/* ── Color Picker & Filter Menu ── */
#tag-menu,
#filter-menu,
#draw-color-menu,
#fib-settings-menu {
    position: absolute;
    background: #1a1c26;
    border: 1px solid #30364d;
    border-radius: 8px;
    padding: 10px;
    z-index: 10000;
    display: none;
    box-shadow:
        0 10px 25px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.05);
    min-width: 140px;
    pointer-events: auto;
}

#draw-color-menu {
    min-width: 132px;
    padding: 10px 10px 12px;
}

.brush-thickness-control {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.brush-thickness-label {
    font-size: 12px;
    color: #979797;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
}

.brush-thickness-label span:last-child {
    color: #fff;
    font-weight: 500;
}

#brush-thickness-slider {
    width: 100%;
    -webkit-appearance: none;
    height: 4px;
    background: #555;
    outline: none;
    opacity: 0.7;
    -webkit-transition: opacity .2s;
    transition: opacity .2s;
    border-radius: 2px;
}

#brush-thickness-slider:hover {
    opacity: 1;
}

#brush-thickness-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    border: 2px solid #fff;
}

#brush-thickness-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    border: 2px solid #fff;
}

#fib-settings-menu {
    min-width: 430px;
    max-width: 460px;
    padding: 12px;
}

.draw-color-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 9px;
    margin-bottom: 10px;
}

.fib-settings-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.fib-close-btn {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--t2);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}

.fib-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--t1);
}

.fib-settings-block {
    margin-bottom: 10px;
}

.fib-level-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 14px;
    max-height: 420px;
    overflow: auto;
    padding-right: 2px;
}

.fib-level-row {
    display: grid;
    grid-template-columns: 18px 1fr 30px;
    align-items: center;
    gap: 8px;
}

.fib-level-toggle {
    width: 16px;
    height: 16px;
    accent-color: #ffffff;
}

.fib-level-value {
    width: 100%;
    height: 34px;
    border: 1px solid #484d63;
    border-radius: 7px;
    background: #1c1f29;
    color: var(--t1);
    padding: 0 10px;
    font: 12px Inter, sans-serif;
    outline: none;
}

.fib-level-value:focus {
    border-color: rgba(59, 130, 246, 0.75);
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.22);
}

.fib-level-color {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    border: 2px solid rgba(255, 255, 255, 0.14);
    background: #fff;
    cursor: pointer;
}

.fib-level-row.disabled .fib-level-value {
    opacity: 0.55;
}

.fib-level-row.disabled .fib-level-color {
    opacity: 0.45;
}

.fib-add-level-btn {
    width: 100%;
    border: 1px dashed #4c5268;
    background: rgba(255, 255, 255, 0.03);
    color: var(--t2);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}

.fib-add-level-btn:hover {
    color: var(--t1);
    border-color: rgba(124, 58, 237, 0.55);
}

.fib-label {
    font-size: 10px;
    color: var(--t3);
    text-transform: uppercase;
    margin-bottom: 6px;
    font-weight: 700;
}

.fib-input {
    width: 100%;
    resize: vertical;
    min-height: 52px;
    border: 1px solid #30364d;
    border-radius: 8px;
    background: #11131b;
    color: var(--t1);
    padding: 8px 10px;
    font: 12px/1.4 Inter, sans-serif;
    outline: none;
}

.fib-input:focus {
    border-color: rgba(124, 58, 237, 0.65);
    box-shadow: 0 0 0 1px rgba(124, 58, 237, 0.2);
}

.fib-settings-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 4px;
}

.fib-one-color {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0 12px;
    color: var(--t2);
    font-size: 12px;
}

.fib-one-color input {
    width: 16px;
    height: 16px;
}

.fib-one-color span {
    flex: 1;
}

.fib-master-color {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    border: 2px solid rgba(255, 255, 255, 0.14);
    background: #fff;
    cursor: pointer;
}

.fib-action-btn {
    border: 1px solid #30364d;
    background: #212536;
    color: var(--t1);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}

.fib-action-btn.primary {
    background: linear-gradient(180deg, #8b5cf6 0%, #6d42ff 100%);
    border-color: rgba(139, 92, 246, 0.65);
}

.fib-action-btn:hover {
    filter: brightness(1.06);
}

.tag-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 8px;
}

.tag-btn {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    transition:
        transform 0.1s,
        border-color 0.1s;
}

.tag-btn:hover {
    transform: scale(1.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.tag-btn.on {
    border-color: #fff;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
}

.tag-btn.none {
    background: #2a2d3d;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tag-btn.none::after {
    content: "×";
    color: var(--t1);
    font-size: 18px;
    font-weight: 800;
    line-height: 1;
}

.tag-btn.none:hover {
    background: #35394d;
}

.tag-btn.none:hover::after {
    color: #fff;
}

#sh-base {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

#sh-base:hover {
    color: var(--ac);
}

#sh-base::after {
    content: " \25BE";
    font-size: 8px;
    opacity: 0.5;
}

#sh-base.active-filter {
    color: var(--ac);
}

.filter-title {
    font-size: 10px;
    color: var(--t3);
    text-transform: uppercase;
    margin-bottom: 8px;
    font-weight: 700;
}

.filter-actions {
    border-top: 1px solid #30364d;
    margin-top: 8px;
    padding-top: 8px;
    display: flex;
    justify-content: space-between;
}

.f-btn {
    background: none;
    border: none;
    color: var(--ac);
    font-size: 10px;
    cursor: pointer;
    padding: 0;
    font-weight: 600;
}

.f-btn:hover {
    text-decoration: underline;
}

.cdot.tagged {
    width: 14px;
    height: 14px;
    margin: 1px 5px;
    border-radius: 3px;
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.1);
}

/* ── Price flash — barely visible, only if you look closely ── */
@keyframes fu {
    0% {
        background: rgba(38, 201, 122, 0.07);
    }
    100% {
        background: transparent;
    }
}

@keyframes fd {
    0% {
        background: rgba(255, 69, 96, 0.07);
    }
    100% {
        background: transparent;
    }
}

.fu {
    animation: fu 0.5s ease-out forwards;
}

.fd {
    animation: fd 0.5s ease-out forwards;
}

/* ── Price cell colour nudge — ultra-subtle ── */
@keyframes price-up {
    0% {
        color: rgba(38, 201, 122, 0.55);
    }
    100% {
        color: inherit;
    }
}
@keyframes price-down {
    0% {
        color: rgba(255, 69, 96, 0.55);
    }
    100% {
        color: inherit;
    }
}
.cc.flash-up {
    animation: price-up 0.45s ease-out forwards;
}
.cc.flash-down {
    animation: price-down 0.45s ease-out forwards;
}

/* ── Connection status dot ── */
.conn-dot {
    position: relative;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--t3);
    flex-shrink: 0;
    transition: background 0.3s;
}

.conn-dot.ok {
    background: var(--gr);
    box-shadow: 0 0 5px var(--gr);
}

/* The pulse used to animate `box-shadow` on `.conn-dot.ok` directly — a
   paint-triggering property, animated forever, for the entire session, because
   the dot keeps `.ok` for as long as the socket is connected. Animating
   `transform` + `opacity` on a pseudo-element instead keeps it on the compositor,
   and `will-change` gives it its own layer. */
.conn-dot.ok::after {
    content: "";
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    background: var(--grglow);
    animation: conn-pulse 2s ease-in-out infinite;
    will-change: transform, opacity;
    pointer-events: none;
}

.conn-dot.err {
    background: var(--rd);
    box-shadow: 0 0 5px var(--rd);
}

@keyframes conn-pulse {
    0%,
    100% {
        transform: scale(0.9);
        opacity: 0.35;
    }
    50% {
        transform: scale(1.6);
        opacity: 0;
    }
}

/* ── Last candle price pill glow ── */
.price-up-glow {
    filter: drop-shadow(0 0 4px rgba(38, 201, 122, 0.6));
}
.price-down-glow {
    filter: drop-shadow(0 0 4px rgba(255, 69, 96, 0.6));
}

/* ══ Density Map View ══ */
#density-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
}

#density-toolbar {
    display: flex;
    align-items: center;
    min-height: 42px;
    padding: 6px 16px;
    gap: 12px;
    border-bottom: 1px solid var(--bd);
    background: rgba(13, 15, 20, 0.98);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.density-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--t1);
    white-space: nowrap;
}

.density-title svg {
    color: var(--ac);
}

.density-count {
    font-size: 10px;
    font-weight: 600;
    color: var(--ac);
    background: rgba(124, 58, 237, 0.15);
    padding: 2px 8px;
    border-radius: 10px;
    letter-spacing: 0.3px;
}

.density-search {
    position: relative;
}

.density-search input {
    width: 140px;
    height: 28px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--bd);
    border-radius: 6px;
    padding: 0 10px;
    font-size: 11px;
    color: var(--t1);
    font-family: var(--font);
    outline: none;
    transition: border-color 0.15s, width 0.2s;
}

.density-search input:focus {
    border-color: var(--ac);
    width: 180px;
}

.density-search input::placeholder {
    color: var(--t3);
}

.density-filters {
    display: flex;
    gap: 2px;
}

.density-quick-filters {
    display: flex;
    gap: 4px;
    align-items: center;
    /* The engine exposes more filters than before (significance, confluence).
       Wrap instead of overflowing the toolbar on narrow viewports. */
    flex-wrap: wrap;
    row-gap: 4px;
}

.density-select {
    height: 26px;
    max-width: 132px;
    padding: 0 24px 0 8px;
    border: 1px solid var(--bd);
    border-radius: 5px;
    color: var(--t2);
    background: #11141c;
    font: 500 10px var(--font);
    outline: none;
    cursor: pointer;
}

.density-select:hover,
.density-select:focus {
    color: var(--t1);
    border-color: var(--ac);
}

.density-filter-btn,
.density-sort-btn {
    padding: 4px 10px;
    font-size: 10px;
    font-weight: 500;
    font-family: var(--font);
    color: var(--t2);
    background: transparent;
    border: 1px solid var(--bd);
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
}

.density-filter-btn:hover,
.density-sort-btn:hover {
    color: var(--t1);
    background: var(--bgh);
    border-color: var(--bd2);
}

.density-filter-btn.on,
.density-sort-btn.on {
    color: #fff;
    background: var(--ac);
    border-color: var(--ac);
}

.density-legend {
    margin-left: auto;
    display: flex;
    gap: 12px;
    align-items: center;
}

.density-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    color: var(--t2);
}

.dl-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.dl-dot.bid {
    background: #26c97a;
    box-shadow: 0 0 6px rgba(38, 201, 122, 0.5);
}

.dl-dot.ask {
    background: #ff4560;
    box-shadow: 0 0 6px rgba(255, 69, 96, 0.5);
}

#density-canvas-wrap {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#density-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* ─── Formations View v2 ─────────────────────────────────────────────────── */
#formations-view {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: calc(100vh - var(--header-h, 50px));
    background: #0d0f14;
    overflow: hidden;
}

#formations-toolbar {
    position: relative;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 52px;
    border-bottom: 1px solid var(--bd);
    background: rgba(19, 21, 30, 0.7);
    backdrop-filter: blur(12px);
    flex-shrink: 0;
    gap: 16px;
}

.profile-language-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px; border: 1px solid var(--bd2); border-radius: 8px; color: var(--t2); font-size: 12px; }
.profile-language-control { position: relative; width: 224px; max-width: 100%; flex-shrink: 0; }
.profile-language-button { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 9px 10px; border: 1px solid var(--bd2); border-radius: 8px; background: var(--bg1); color: var(--t1); font: 500 12px var(--font); cursor: pointer; text-align: left; }
.profile-language-chevron { color: var(--t2); transition: transform 140ms ease; }
.profile-language-button[aria-expanded="true"] { border-color: var(--ac); }
.profile-language-button[aria-expanded="true"] .profile-language-chevron { transform: rotate(180deg); }
.profile-language-menu { position: absolute; top: calc(100% + 5px); right: 0; z-index: 5; width: 100%; max-height: min(300px, 42dvh); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 4px; border: 1px solid var(--bd2); border-radius: 9px; background: var(--bg2); box-shadow: 0 10px 28px rgba(0,0,0,.4); box-sizing: border-box; }
.profile-language-menu[hidden] { display: none; }
.profile-language-option { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--t2); font: 500 12px var(--font); cursor: pointer; text-align: left; }
.profile-language-copy { display: flex; flex-direction: column; gap: 3px; }
.profile-language-copy small { font-size: 10px; opacity: .75; }
#profile-language-status { flex-basis: 100%; color: var(--t2); }
.profile-language-button[aria-busy="true"] { opacity: .7; }
.profile-language-code { font: 600 10px var(--font-mono); opacity: .75; }
.profile-language-option[aria-selected="true"] { color: #fff; background: var(--ac); border-color: var(--ac); }
.profile-language-option:hover { color: var(--t1); background: var(--bg3); }
.profile-language-option[aria-selected="true"]:hover { color: #fff; background: var(--ac); }
.profile-language-option:focus-visible, .profile-language-button:focus-visible { outline: 2px solid var(--ac); outline-offset: 2px; }
.profile-language-option, .fmt-btn, .settings-tab, .ntab { transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease; }
@media (max-width: 480px) { .profile-language-row { flex-wrap: wrap; } .profile-language-control { width: 100%; } }
.switch input:focus-visible + .slider { outline: 2px solid var(--ac); outline-offset: 3px; }
.settings-pane.active { animation: settingsPaneEnter 140ms ease-out; }
@keyframes settingsPaneEnter { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) {
    .settings-pane.active, .settings-modal { animation: none; }
    .profile-language-option, .profile-language-chevron, .fmt-btn, .settings-tab, .ntab, .slider, .slider:before { transition: none; }
}
.chart-animations-off .settings-pane.active, .chart-animations-off .settings-modal { animation: none; }
.toast-action { margin-top: 5px; font-size: 11px; color: #a78bfa; font-weight: 600; }
.formation-alert-sync-status { margin: 0; padding: 0 24px; color: var(--t2, #9299ac); font-size: 11px; line-height: 1.5; min-height: 18px; }

.formations-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    color: var(--t1);
}

.formations-title svg {
    color: var(--ac);
}

.formations-count {
    font-size: 11px;
    font-weight: 500;
    color: var(--ac);
    background: rgba(124, 58, 237, 0.15);
    padding: 2px 7px;
    border-radius: 10px;
    margin-left: 4px;
    border: 1px solid rgba(124, 58, 237, 0.25);
}

.formations-filters {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
}

.fp-group {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.02);
    padding: 3px 6px;
    border-radius: 20px;
    border: 1px solid var(--bd);
}

.fp-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--t2);
    text-transform: uppercase;
    padding-left: 6px;
    padding-right: 4px;
    letter-spacing: 0.5px;
}

.fp-pill {
    background: transparent;
    border: none;
    color: var(--t2);
    font-size: 11px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 15px;
    cursor: pointer;
    transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.fp-pill:hover {
    color: var(--t1);
    background: rgba(255, 255, 255, 0.04);
}

.fp-pill.on {
    color: #fff;
    background: var(--ac);
    box-shadow: 0 2px 8px var(--acglow);
}

.fp-pill.long.on {
    background: var(--gr);
    box-shadow: 0 2px 8px var(--grglow);
}

.fp-pill.short.on {
    background: var(--rd);
    box-shadow: 0 2px 8px var(--rdglow);
}

.formations-grid-switcher {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(0, 0, 0, 0.15);
    padding: 3px;
    border-radius: 6px;
    border: 1px solid var(--bd);
}

.fg-btn {
    background: transparent;
    border: none;
    color: var(--t2);
    width: 26px;
    height: 26px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.fg-btn:hover {
    color: var(--t1);
    background: rgba(255, 255, 255, 0.05);
}

.fg-btn.on {
    color: #fff;
    background: var(--ac);
}

/* Match the screener's multi-chart grid exactly (see #chart-grid-container) so
   the formation mini charts are visually identical, not merely similar. */
#formations-grid {
    flex: 1;
    display: grid;
    gap: 4px;
    padding: 4px;
    overflow: hidden;
    background: #1a1c22;
    min-height: 0;
}

/* ── Pagination bar ─────────────────────────────────────── */
#formations-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 8px 16px;
    background: var(--bg1);
    border-top: 1px solid var(--bd1);
    flex-shrink: 0;
}

#formations-page-info {
    font-size: 12px;
    font-weight: 600;
    color: var(--t2);
    min-width: 50px;
    text-align: center;
}

.fg-page-btn {
    background: var(--bg3);
    border: 1px solid var(--bd2);
    color: var(--t2);
    font-size: 12px;
    font-weight: 600;
    padding: 5px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.fg-page-btn:hover:not(:disabled) {
    background: var(--ac);
    border-color: var(--ac);
    color: #fff;
    box-shadow: 0 0 8px var(--acglow);
}

.fg-page-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}


#formations-grid.fg-cols-1 {
    grid-template-columns: repeat(1, 1fr);
    grid-template-rows: repeat(1, 1fr);
}

#formations-grid.fg-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

#formations-grid.fg-cols-4 {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
}

#formations-grid.fg-cols-6 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
}

#formations-grid.fg-cols-9 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
}

#formations-grid.fg-cols-12 {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(3, 1fr);
}

.formation-chart-card {
    background: #11131c;
    border: 1px solid var(--bd);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.formation-chart-card:hover {
    border-color: var(--ac);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    transform: scale(1.005);
}

.formation-chart-card.long {
    border-top: 2px solid var(--gr);
}

.formation-chart-card.short {
    border-top: 2px solid var(--rd);
}

.formation-mini-canvas {
    width: 100%;
    height: 100%;
    flex: 1;
    display: block;
    background: #0f1118;
}

.fc-overlay-header {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    z-index: 5;
}

.fc-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: rgba(124, 58, 237, 0.15);
    color: #a78bfa;
    border: 1px solid rgba(124, 58, 237, 0.3);
}

.fc-dir {
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
}

.fc-dir.long {
    background: rgba(38, 201, 122, 0.15);
    color: var(--gr);
    border: 1px solid rgba(38, 201, 122, 0.3);
}

.fc-dir.short {
    background: rgba(255, 69, 96, 0.15);
    color: var(--rd);
    border: 1px solid rgba(255, 69, 96, 0.3);
}

.fc-overlay-info {
    position: absolute;
    top: 40px;
    left: 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    pointer-events: none;
    background: rgba(9, 10, 15, 0.7);
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(4px);
    z-index: 5;
}

.fc-coin-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.fc-coin {
    font-size: 13px;
    font-weight: 700;
    color: var(--t1);
}

.fc-ex {
    font-size: 9px;
    font-weight: 600;
    color: var(--t2);
    background: rgba(255, 255, 255, 0.06);
    padding: 1px 4px;
    border-radius: 3px;
}

.fc-tf {
    font-size: 10px;
    font-weight: 700;
    color: var(--ac);
}

.fc-overlay-footer {
    position: absolute;
    bottom: 8px;
    left: 8px;
    right: 8px;
    background: rgba(13, 15, 22, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    pointer-events: none;
    backdrop-filter: blur(8px);
    z-index: 5;
}

.fc-desc {
    font-size: 10.5px;
    color: var(--t1);
    line-height: 1.35;
}

.fc-desc b {
    color: var(--ac);
}

.fc-sub-desc {
    font-size: 9px;
    color: var(--t2);
    display: flex;
    justify-content: space-between;
}

.fc-confidence {
    color: #fb7185;
}

.formations-empty,
.formations-error {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px;
    color: var(--t2);
    font-size: 12px;
}

.fg-tf-switcher {
    display: flex;
    gap: 4px;
    align-items: center;
}

.fg-tf-btn {
    padding: 3px 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--t2);
    cursor: pointer;
    border-radius: 4px;
    border: none;
    background: transparent;
    font-family: var(--font);
    transition: background-color 0.15s, color 0.15s;
    user-select: none;
    min-width: 24px;
    text-align: center;
}

.fg-tf-btn:hover {
    color: var(--t1);
    background: var(--bgh);
}

.fg-tf-btn.on {
    color: #fff;
    background: var(--ac);
}

.exc-checkbox {
    width: 14px;
    height: 14px;
    border: 1px solid var(--bd2, #3b3d4f);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    transition: background-color 0.1s ease, border-color 0.1s ease;
    flex-shrink: 0;
}

.exc-item.on .exc-checkbox {
    background: var(--ac);
    border-color: var(--ac);
}

.exc-checkbox::after {
    content: "✓";
    color: #fff;
    font-size: 10px;
    font-weight: bold;
    display: none;
    line-height: 1;
}

.exc-item.on .exc-checkbox::after {
    display: block;
}

/* ── Formations Fullscreen Expanded Chart ── */
/* When a formation is expanded the real screener chart (#chart-area) is moved
   into #formations-fullchart, so the grid is hidden entirely rather than being
   stretched. This is what makes the expanded view identical to the screener:
   same canvas, same drawing toolbar, same timeframe bar. */
#formations-fullchart {
    display: none;
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

#formations-view.fullchart-active #formations-fullchart {
    display: flex;
}

#formations-view.fullchart-active #formations-grid,
#formations-view.fullchart-active #formations-pagination {
    display: none !important;
}

#formations-fullchart > #chart-area {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* The single/multi toggle and grid config belong to the screener layout; inside
   the Formations tab the expanded chart is always the single chart. */
#formations-fullchart #view-toggle,
#formations-fullchart #grid-config {
    display: none !important;
}

#formations-settings-btn:hover {
    color: var(--t1);
    border-color: var(--bd2);
    background: var(--bgh);
}

#formations-settings-btn.open {
    border-color: var(--ac);
    background: var(--bgh2);
    box-shadow: 0 0 0 2px var(--acglow);
}

/* ═══ Backtests — blind replay, native CryptoScreen styling ════════════════ */
#backtest-view {
    width: 100%;
    height: calc(100vh - 44px);
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
}

#bt-toolbar {
    position: relative;
    z-index: 60;
    height: 46px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    border-bottom: 1px solid var(--bd);
    background: var(--bg2);
}

.bt-module-name { display: flex; align-items: center; gap: 8px; min-width: 178px; padding-right: 12px; border-right: 1px solid var(--bd2); }
.bt-module-icon { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 6px; color: #fff; background: linear-gradient(145deg,#8b5cf6,#5b21b6); font-size: 11px; font-weight: 800; box-shadow: 0 0 12px rgba(124,58,237,.3); }
.bt-module-name div { display: flex; flex-direction: column; line-height: 1.15; }
.bt-module-name strong { color: var(--t1); font-size: 10px; }
.bt-module-name span:last-child { color: var(--t3); font-size: 8px; }
.bt-title { display: flex; align-items: center; gap: 7px; min-width: 165px; font-size: 12px; }
.bt-title #bt-symbol { color: var(--t1); font-weight: 700; letter-spacing: .2px; }
.bt-exchange-select { height: 28px; min-width: 90px; padding: 0 24px 0 8px; color: var(--t2); background: #10121a; border: 1px solid var(--bd); border-radius: 5px; outline: none; font: 10px var(--font); cursor: pointer; }
.bt-exchange-select:hover, .bt-exchange-select:focus { color: var(--t1); border-color: var(--bd2); }
.bt-live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ac); box-shadow: 0 0 7px var(--acglow); }
.bt-muted { color: var(--t2); font-size: 10px; }
.bt-tfs, .bt-speeds { display: flex; align-items: center; padding: 2px; border: 1px solid var(--bd); border-radius: 5px; background: rgba(0,0,0,.12); }
.bt-tf, .bt-chip, .bt-speeds button { height: 24px; padding: 0 9px; border-radius: 4px; color: var(--t2); font-size: 10px; font-weight: 600; transition: background-color .15s ease, border-color .15s ease, border-radius .15s ease, box-shadow .15s ease, color .15s ease, font-size .15s ease, height .15s ease, min-height .15s ease, outline-color .15s ease, padding .15s ease, width .15s ease; }
.bt-tf:hover, .bt-chip:hover, .bt-speeds button:hover { color: var(--t1); background: var(--bgh); }
.bt-tf.on, .bt-chip.on, .bt-speeds button.on { color: #fff; background: var(--ac); box-shadow: 0 2px 8px rgba(124,58,237,.2); }
.bt-chip { border: 1px solid var(--bd); }
.bt-sep { width: 1px; height: 22px; background: var(--bd2); margin: 0 2px; }
.bt-toolbar-spacer { flex: 1; }
.bt-pool { white-space: nowrap; color: var(--t2); font-size: 10px; font-weight: 500; }
.bt-primary, .bt-reveal { height: 28px; padding: 0 13px; border-radius: 5px; color: #fff; background: var(--ac); border: 1px solid rgba(167,139,250,.25); font-size: 10px; font-weight: 700; transition: box-shadow .15s, filter .15s, opacity .15s; }
.bt-primary:hover, .bt-reveal:hover { filter: brightness(1.12); box-shadow: 0 0 12px var(--acglow); }
.bt-indicator-settings { position: relative; }
.bt-indicators-btn { height: 26px; padding: 0 9px; color: var(--t2); background: var(--bg3); border: 1px solid var(--bd); border-radius: 5px; font-size: 9px; font-weight: 600; }
.bt-indicators-btn:hover, .bt-indicators-btn.open { color: #fff; border-color: rgba(124,58,237,.5); background: rgba(124,58,237,.16); }
.bt-indicators-menu { position: absolute; top: 33px; right: 0; z-index: 200; width: 310px; padding: 10px; background: rgba(19,21,30,.98); border: 1px solid var(--bd2); border-radius: 8px; box-shadow: 0 18px 45px rgba(0,0,0,.55); backdrop-filter: blur(14px); }
.bt-indicators-menu[hidden] { display: none; }
.bt-indicators-head { display: flex; align-items: flex-end; justify-content: space-between; padding: 1px 2px 9px; border-bottom: 1px solid var(--bd); }
.bt-indicators-head strong { color: var(--t1); font-size: 11px; }
.bt-indicators-head span { color: var(--t3); font-size: 8px; }
.bt-section-title { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--t3); margin: 8px 0 4px 2px; }
.bt-indicators-grid { display: grid; grid-template-columns: repeat(5,1fr); gap: 6px; padding-top: 2px; margin-bottom: 4px; }
.bt-indicators-grid button { min-height: 29px; padding: 5px 3px; display: flex; align-items: center; justify-content: center; color: var(--t2); background: rgba(255,255,255,.025); border: 1px solid var(--bd); border-radius: 7px; text-align: center; }
.bt-indicators-grid button span { font-size: 9px; font-weight: 700; }
.bt-indicators-grid button b { display: none; }
.bt-indicators-grid button:hover { color: var(--t1); background: var(--bgh); }
.bt-indicators-grid button.on { color: #fff; border-color: rgba(124,58,237,.55); background: rgba(124,58,237,.18); }

#bt-workspace { min-height: 0; flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 286px; }

#bt-chart-panel { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: #0d0f14; }
#bt-chart-head { height: 34px; padding: 0 12px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--bd); background: rgba(19,21,30,.72); }
#bt-chart-head > div:first-child { display: flex; align-items: center; gap: 10px; }
#bt-watermark { font-size: 12px; color: var(--t1); }
#bt-date { color: var(--t2); font-size: 10px; }
.bt-ohlc { display: flex; gap: 8px; font-size: 10px; color: var(--t2); font-variant-numeric: tabular-nums; }
#bt-canvas-wrap { position: relative; flex: 1; min-height: 0; overflow: hidden; }
#bt-canvas { width: 100%; height: 100%; display: block; cursor: crosshair; }
#bt-vol-canvas { position: absolute; bottom: 0; left: 0; width: 100%; pointer-events: none; }
#bt-draw-tools { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); z-index: 20; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 32px; padding: 5px 3px; border: 1px solid #2a2e39; border-radius: 6px; background: #1e222d; box-shadow: 0 4px 16px rgba(0,0,0,.45); user-select: none; }
#bt-draw-tools .dt-btn { color: var(--tool-accent, #d1d4dc); }
#bt-draw-tools .dt-btn.on { color: #fff; }
#j-draw-tools { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); z-index: 20; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 32px; padding: 5px 3px; border: 1px solid #2a2e39; border-radius: 6px; background: #1e222d; box-shadow: 0 4px 16px rgba(0,0,0,.45); user-select: none; }
#j-draw-tools .dt-btn { color: var(--tool-accent, #d1d4dc); }
#j-draw-tools .dt-btn.on { color: #fff; background: rgba(94,58,238,.35); border: 1px solid rgba(160,124,255,.4); }
.bt-color-cycle span { width: 11px; height: 11px; border-radius: 50%; background: var(--bt-active-color,#8b5cf6); box-shadow: 0 0 7px var(--bt-active-color,#8b5cf6); }
.bt-loader { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 10px; background: rgba(13,15,20,.9); color: var(--t2); font-size: 11px; }
.bt-loader[hidden], .bt-result[hidden] { display: none; }
.bt-loader .sp { width: 24px; height: 24px; }
.bt-result { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 4; min-width: 270px; padding: 10px 14px; border-radius: 7px; border: 1px solid var(--bd2); background: rgba(19,21,30,.94); backdrop-filter: blur(10px); text-align: center; font-size: 11px; box-shadow: 0 8px 30px rgba(0,0,0,.35); }
.bt-result strong { display: block; margin-bottom: 3px; font-size: 13px; }
.bt-result.good strong { color: var(--gr); }
.bt-result.bad strong { color: var(--rd); }

#bt-replaybar { height: 46px; flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding: 0 10px; border-top: 1px solid var(--bd); background: var(--bg2); }
.bt-replay-label { margin-right: 4px; color: var(--t3); font-size: 8px; font-weight: 700; letter-spacing: .7px; }
.bt-control { height: 28px; padding: 0 12px; color: var(--t1); background: var(--bg3); border: 1px solid var(--bd2); border-radius: 5px; font-size: 10px; font-weight: 600; }
.bt-control:hover { background: var(--bgh); }
.bt-control:disabled, .bt-reveal:disabled { opacity: .35; cursor: not-allowed; }
.bt-progress { flex: 1; max-width: 180px; height: 3px; border-radius: 2px; overflow: hidden; background: var(--bd2); }
#bt-progress-fill { display: block; height: 100%; width: 0; background: var(--ac); box-shadow: 0 0 7px var(--ac); transition: width .2s; }
.bt-reveal { margin-left: auto; }

#bt-trade-panel { min-height: 0; overflow-y: auto; padding: 12px; background: linear-gradient(180deg,#13151e,#10121a); border-left: 1px solid var(--bd); }
.bt-plan-head { display: flex; align-items: flex-start; justify-content: space-between; padding-bottom: 10px; }
.bt-plan-head > div { display: flex; flex-direction: column; gap: 3px; }
.bt-plan-head strong { color: var(--t1); font-size: 13px; }
.bt-plan-head span { color: var(--t3); font-size: 8px; }
#bt-plan-state { padding: 4px 7px; color: #a78bfa; background: rgba(124,58,237,.12); border: 1px solid rgba(124,58,237,.25); border-radius: 4px; font-size: 8px; }
.bt-stage-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 3px; margin-bottom: 12px; padding: 3px; background: rgba(0,0,0,.14); border: 1px solid var(--bd); border-radius: 6px; }
.bt-stage-row span { padding: 5px 2px; color: var(--t3); border-radius: 4px; text-align: center; font-size: 8px; font-weight: 600; }
.bt-stage-row span.on { color: #fff; background: rgba(124,58,237,.7); }
.bt-field > span, .bt-panel-heading { color: var(--t3); font-size: 8px; font-weight: 700; letter-spacing: .55px; }
.bt-field { display: block; margin-bottom: 9px; }
.bt-field > span { display: block; margin: 0 0 5px 2px; }
.bt-field input, .bt-field textarea, .bt-field select { width: 100%; padding: 0 10px; color: var(--t1); font: 10px var(--font); background: #0d0f16; border: 1px solid var(--bd2); border-radius: 5px; outline: none; resize: none; }
.bt-field input { height: 32px; }
.bt-field select { height: 32px; cursor: pointer; }
.bt-leverage-field > span { display: flex; align-items: center; justify-content: space-between; }
.bt-leverage-field output { color: var(--ac); font-size: 12px; font-weight: 800; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.bt-field input[type="range"] { height: 32px; padding: 0; accent-color: var(--ac); cursor: pointer; }
.bt-field input[type="range"]:disabled { cursor: not-allowed; opacity: .55; }
.bt-leverage-field .bt-leverage-control { position: relative; display: block; height: 38px; margin: 0 2px; }
.bt-leverage-field #bt-leverage {
  display: block;
  width: 100%;
  height: 20px !important;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  outline: none;
  background: transparent;
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  z-index: 2;
}
.bt-leverage-field #bt-leverage::-webkit-slider-runnable-track {
  height: 5px;
  border: 1px solid rgba(167,139,250,.18);
  border-radius: 99px;
  background: linear-gradient(to right, var(--ac) 0 var(--bt-leverage-fill, 0%), rgba(148,163,184,.38) var(--bt-leverage-fill, 0%) 100%);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.3);
}
.bt-leverage-field #bt-leverage::-moz-range-track {
  height: 5px;
  border: 1px solid rgba(167,139,250,.18);
  border-radius: 99px;
  background: linear-gradient(to right, var(--ac) 0 var(--bt-leverage-fill, 0%), rgba(148,163,184,.38) var(--bt-leverage-fill, 0%) 100%);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.3);
}
.bt-leverage-field #bt-leverage::-webkit-slider-thumb {
  width: 15px;
  height: 15px;
  margin-top: -6px;
  border: 2px solid #eee9ff;
  border-radius: 50%;
  background: var(--ac);
  box-shadow: 0 0 0 3px rgba(124,58,237,.22), 0 2px 8px rgba(0,0,0,.45);
  -webkit-appearance: none;
  appearance: none;
  transition: box-shadow .15s ease, transform .15s ease;
}
.bt-leverage-field #bt-leverage::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border: 2px solid #eee9ff;
  border-radius: 50%;
  background: var(--ac);
  box-shadow: 0 0 0 3px rgba(124,58,237,.22), 0 2px 8px rgba(0,0,0,.45);
  transition: box-shadow .15s ease, transform .15s ease;
}
.bt-leverage-field #bt-leverage:hover::-webkit-slider-thumb,
.bt-leverage-field #bt-leverage:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 5px rgba(124,58,237,.28), 0 2px 10px rgba(0,0,0,.5); transform: scale(1.08); }
.bt-leverage-field #bt-leverage:hover::-moz-range-thumb,
.bt-leverage-field #bt-leverage:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 5px rgba(124,58,237,.28), 0 2px 10px rgba(0,0,0,.5); transform: scale(1.08); }
.bt-leverage-field .bt-leverage-marks { position: absolute; top: 22px; left: 7px; right: 7px; height: 16px; pointer-events: none; }
.bt-leverage-field .bt-leverage-mark { position: absolute; left: var(--bt-mark); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--t2); }
.bt-leverage-field .bt-leverage-mark i { width: 4px; height: 4px; border-radius: 50%; background: #8a8da3; }
.bt-leverage-field .bt-leverage-mark small { font-size: 9px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.bt-leverage-field .bt-leverage-mark.is-passed { color: var(--t1); }
.bt-leverage-field .bt-leverage-mark.is-passed i { background: var(--ac); box-shadow: 0 0 6px var(--ac); }
.bt-leverage-field .bt-leverage-control.is-disabled { opacity: .5; }
.bt-field input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
.bt-field input[type="number"]::-webkit-inner-spin-button, .bt-field input[type="number"]::-webkit-outer-spin-button { margin: 0; -webkit-appearance: none; }
.bt-field textarea { min-height: 54px; padding-top: 8px; line-height: 1.4; }
.bt-field input:focus, .bt-field textarea:focus, .bt-field select:focus { border-color: rgba(124,58,237,.65); box-shadow: 0 0 0 2px rgba(124,58,237,.1); }
.bt-plan-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 5px; }
.bt-size-hint { grid-column: 1 / -1; margin: -3px 0 4px 2px; color: var(--t3); font-size: 8px; }
.bt-level-input { display: flex; height: 32px; }
.bt-level-input input { min-width: 0; height: 32px; border-radius: 5px 0 0 5px; }
.bt-level-input button { width: 42px; flex-shrink: 0; color: #fff; background: rgba(124,58,237,.55); border: 1px solid rgba(124,58,237,.55); border-left: 0; border-radius: 0 5px 5px 0; font-size: 9px; font-weight: 700; }
.bt-level-input button.price-mode { color: #a78bfa; background: rgba(124,58,237,.12); }
.bt-side-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 12px; }
.bt-side-actions button { height: 36px; border-radius: 6px; font-size: 11px; font-weight: 800; }
#bt-long { color: var(--gr); background: rgba(38,201,122,.12); border: 1px solid rgba(38,201,122,.2); }
#bt-short { color: var(--rd); background: rgba(255,69,96,.12); border: 1px solid rgba(255,69,96,.2); }
#bt-long:hover { color: #09140f; background: var(--gr); }
#bt-short:hover { color: #18090d; background: var(--rd); }
#bt-long.on { color: #06150d; background: var(--gr); box-shadow: 0 0 12px rgba(38,201,122,.22); }
#bt-short.on { color: #18090d; background: var(--rd); box-shadow: 0 0 12px rgba(255,69,96,.22); }
.bt-commit-plan { width: 100%; height: 34px; margin-bottom: 10px; color: #fff; background: linear-gradient(180deg,#8b5cf6,#6d42ff); border-radius: 6px; font-size: 10px; font-weight: 700; }
.bt-commit-plan:disabled { opacity: .3; cursor: not-allowed; }
.bt-account-strip { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-bottom: 8px; }
.bt-account-strip span { padding: 7px; color: var(--t3); background: rgba(0,0,0,.12); border: 1px solid var(--bd); border-radius: 5px; font-size: 8px; }
.bt-account-strip b { display: block; margin-top: 3px; color: var(--t1); font-size: 10px; }
.bt-reset-balance { width: 100%; margin: -2px 0 10px; padding: 5px; border: 1px solid var(--bd2); border-radius: 5px; color: var(--t3); background: rgba(255,255,255,.02); font-size: 9px; }
.bt-reset-balance:hover:not(:disabled) { color: var(--t1); border-color: rgba(139,92,246,.5); }
.bt-reset-balance:disabled { opacity: .45; cursor: not-allowed; }
.bt-close-position { width: 100%; height: 29px; margin: 7px 0 12px; color: var(--t2); border: 1px solid var(--bd2); border-radius: 5px; font-size: 10px; }
.bt-close-position:not(:disabled):hover { color: var(--t1); background: var(--bgh); }
.bt-close-position:disabled { opacity: .3; cursor: not-allowed; }
.bt-panel-heading { padding: 8px 2px 6px; border-top: 1px solid var(--bd); }
.bt-empty { padding: 12px 8px; color: var(--t3); background: rgba(0,0,0,.08); border: 1px dashed var(--bd2); border-radius: 5px; font-size: 9px; line-height: 1.45; text-align: center; }
.bt-position { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 9px; border: 1px solid var(--bd); border-radius: 5px; background: rgba(0,0,0,.1); font-size: 9px; }
.bt-position span { color: var(--t2); }
.bt-position b { display: block; margin-top: 2px; color: var(--t1); font-size: 10px; }
.bt-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.bt-stats span { padding: 7px 3px; color: var(--t3); background: rgba(0,0,0,.1); border: 1px solid var(--bd); border-radius: 5px; text-align: center; font-size: 8px; }
.bt-stats b { display: block; margin-top: 3px; color: var(--t1); font-size: 10px; }

@media (max-width: 1050px) {
    #bt-workspace { grid-template-columns: minmax(0, 1fr) 245px; }
    .bt-chip, .bt-pool { display: none; }
    .bt-module-name { display: none; }
}

@media (max-width: 760px) {
    #bt-workspace { grid-template-columns: minmax(0, 1fr); }
    #bt-trade-panel { display: none; }
    .bt-title .bt-muted, .bt-toolbar .bt-sep { display: none; }
}

/* ── Smart Money Concepts (SMC) Indicator Buttons ── */
.smc-btn.on {
    background: rgba(124, 58, 237, 0.25) !important;
    border-color: rgba(124, 58, 237, 0.65) !important;
    color: #c4b5fd !important;
    box-shadow: 0 0 10px rgba(124, 58, 237, 0.25);
}
.smc-btn:hover {
    border-color: rgba(167, 139, 250, 0.4);
}

/* ── Cross-Device & Touch Responsiveness Optimization ── */

/* Canvas touch handling */
#chart-canvas, .cell-canvas, #vol-canvas {
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

/* Safe Area Insets for iPhones / Notch displays */
body {
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}

/* Smooth custom horizontal scrollbars for overflow control bars */
.chart-bar, .chart-controls, .screener-header, .screener-filters, .exc-menu {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.chart-bar::-webkit-scrollbar, .chart-controls::-webkit-scrollbar {
    height: 4px;
}
.chart-bar::-webkit-scrollbar-thumb, .chart-controls::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

/* ── Breakpoint L: MacBook 13"/14" & Medium Laptops (1024px - 1439px) ── */
@media (max-width: 1439px) {
    .exc-btn {
        max-width: none;
    }
    .chart-bar {
        overflow-x: auto;
        flex-wrap: nowrap;
        white-space: nowrap;
        padding-bottom: 2px;
    }
    .chart-btn-group {
        flex-shrink: 0;
    }
}

/* ── Breakpoint M: Tablets / iPads / Small Laptops (768px - 1023px) ── */
@media (max-width: 1023px) {
    .exc-btn {
        max-width: none;
        font-size: 11px;
    }
    #exc-name {
        font-size: 11px;
    }
    .chart-bar {
        gap: 6px;
        padding: 4px 8px;
    }
    .chart-btn-group button, .chart-tf-btn, .vt-btn {
        padding: 4px 8px;
        font-size: 11px;
    }
    /* Modal responsive fit */
    .modal-content, .density-settings-modal {
        width: 92% !important;
        max-width: 500px !important;
        margin: 20px auto !important;
    }
    /* Table horizontal scrolling wrapper */
    .table-container, .screener-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ══════════════════════════════════════════════════════════════════
   MOBILE  ≤ 767px  —  Full vertical layout, ALL features preserved
   Chart on top · Screener list below · Touch-friendly · iOS Safari
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {

  /* ── Viewport: iOS Safari dynamic bar support ── */
  html, body {
    height: 100%;
    overflow: hidden;
    /* NO touch-action here — canvas needs touch-action:none to handle pan/zoom */
  }

  #app {
    height: 100dvh;
    /* fallback for older browsers */
    min-height: -webkit-fill-available;
  }

  /* ── Prevent accidental text selection on drag/touch ── */
  #chart-area, #cwrap, #draw-tools, #ctbar, #rp, .cr, .rph, .clh, .lex,
  #density-view, #formations-view, #backtest-view {
    -webkit-user-select: none;
    user-select: none;
  }

  /* ── Canvas: must have touch-action:none for JS pan/zoom ── */
  #cwrap {
    touch-action: none;
  }

  /* ── Fix density map height for 40px mobile nav ── */
  #density-view {
    height: calc(100dvh - 40px);
    height: calc(100vh - 40px);
    flex: 1;
  }

  /* ── Fix formations/backtest for 40px mobile nav ── */
  #formations-view {
    height: calc(100dvh - 40px) !important;
    height: calc(100vh - 40px) !important;
  }

  /* Formations grid on mobile: 2 charts stacked top-to-bottom (1 column, 2 rows) */
  #formations-grid,
  #formations-grid.fg-cols-2,
  #formations-grid.fg-cols-1,
  #formations-grid.fg-cols-4 {
    grid-template-columns: 1fr !important;
    grid-template-rows: repeat(2, 1fr) !important;
    gap: 4px !important;
    padding: 4px !important;
  }
  /* Cells are .grid-cell (shared with the screener grid), not the legacy
     .formation-chart-card markup. */
  #formations-grid > .grid-cell:nth-child(n+3) {
    display: none !important;
  }

  /* ═══ BACKTESTS VIEW MOBILE ═══ */
  #backtest-view {
    height: calc(100dvh - 40px);
    height: calc(100vh - 40px);
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  #bt-toolbar {
    height: 36px !important;
    min-height: 36px !important;
    padding: 0 6px !important;
    gap: 4px !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    scrollbar-width: none !important;
    -webkit-overflow-scrolling: touch !important;
    flex-wrap: nowrap !important;
  }
  #bt-toolbar::-webkit-scrollbar { display: none; }
  .bt-module-name { display: none !important; }
  .bt-title { min-width: 0 !important; font-size: 11px !important; }
  .bt-exchange-select { height: 24px !important; min-width: 70px !important; font-size: 9.5px !important; padding: 0 16px 0 6px !important; }
  .bt-tf, .bt-chip, .bt-speeds button { height: 22px !important; padding: 0 6px !important; font-size: 9.5px !important; }
  .bt-primary, .bt-reveal { height: 24px !important; padding: 0 8px !important; font-size: 9.5px !important; }

  #bt-workspace {
    grid-template-columns: 1fr !important;
    display: flex !important;
    flex-direction: column !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  #bt-chart-panel {
    height: 52dvh !important;
    height: 52vh !important;
    min-height: 250px !important;
    flex: none !important;
  }

  #bt-chart-head {
    height: 28px !important;
    padding: 0 8px !important;
    font-size: 10px !important;
  }

  /* Compact floating draw tools inside Backtest chart on mobile */
  #bt-draw-tools {
    left: 4px !important;
    padding: 4px 2px !important;
    gap: 1px !important;
    min-width: 26px !important;
    border-radius: 6px !important;
  }
  #bt-draw-tools .dt-btn {
    width: 22px !important;
    height: 22px !important;
    min-width: 22px !important;
    min-height: 22px !important;
    padding: 3px !important;
    border-radius: 4px !important;
    font-size: 10px !important;
  }
  #bt-draw-tools .dt-btn svg {
    width: 11px !important;
    height: 11px !important;
  }
  #bt-draw-tools .dt-sep {
    margin: 1px 0 !important;
    height: 1px !important;
  }

  #bt-replaybar {
    height: 38px !important;
    min-height: 38px !important;
    overflow-x: auto !important;
    padding: 0 6px !important;
    gap: 4px !important;
    scrollbar-width: none !important;
    -webkit-overflow-scrolling: touch !important;
  }
  #bt-replaybar::-webkit-scrollbar { display: none; }
  .bt-replay-label { font-size: 7px !important; margin-right: 2px !important; }
  .bt-control { height: 24px !important; padding: 0 8px !important; font-size: 9.5px !important; }

  /* Backtest Trade Panel below chart on mobile */
  #bt-trade-panel {
    border-left: none !important;
    border-top: 1px solid var(--bd) !important;
    flex: 1 !important;
    width: 100% !important;
    padding: 10px 10px 24px !important;
    background: #0f1118 !important;
  }

  .bt-plan-head strong { font-size: 12px !important; }
  .bt-side-actions { margin-top: 8px !important; gap: 6px !important; }
  .bt-side-actions button { height: 32px !important; font-size: 10.5px !important; }
  .bt-field input { height: 28px !important; font-size: 10px !important; }
  .bt-level-input { height: 28px !important; }
  .bt-level-input input { height: 28px !important; }
  .bt-level-input button { height: 28px !important; }
  .bt-commit-plan { height: 32px !important; font-size: 10px !important; margin-bottom: 8px !important; }
  .bt-account-strip { gap: 4px !important; margin-bottom: 6px !important; }
  .bt-account-strip span { padding: 5px !important; font-size: 7.5px !important; }
  .bt-account-strip b { font-size: 9.5px !important; }

  /* ═══ NAV ═══ */
  #nav {
    height: 40px;
    min-height: 40px;
    padding: 0 8px;
    gap: 4px;
    overflow-x: auto;
    overflow-y: visible;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
  }
  #nav::-webkit-scrollbar { display: none; }

  .logo {
    margin-right: 2px;
    flex-shrink: 0;
    gap: 2px;
  }
  .logo-img { height: 18px; }
  /* Hide text — only icon on mobile to give tabs max space */
  .logo-c, .logo-rest { display: none; }

  .ntabs { flex-shrink: 0; gap: 1px; }
  .ntab {
    padding: 4px 8px;
    font-size: 10.5px;
    white-space: nowrap;
    flex-shrink: 0;
    border-radius: 4px;
    min-height: 30px;
    display: flex;
    align-items: center;
  }

  .nright {
    flex-shrink: 0;
    gap: 4px;
    margin-left: auto;
  }

  .sbox {
    width: 110px;
    min-width: 80px;
    height: 28px;
    padding: 0 8px;
  }

  .sbox input { font-size: 11px; }
  .sbox input::placeholder { font-size: 10px; }

  .lang-btn {
    padding: 3px 7px;
    font-size: 10px;
    flex-shrink: 0;
  }

  .settings-btn, .profile-btn {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
  }

  /* ═══ MAIN: vertical stack ═══ */
  #main {
    flex-direction: column !important;
    overflow: hidden;
  }

  /* ═══ DRAW TOOLS sidebar: slim ═══ */
  #dt {
    width: 22px;
    padding: 4px 0;
  }
  .dtb { width: 18px; height: 18px; font-size: 10px; }

  /* ═══ DRAW TOOLS floating panel: compact on mobile ═══ */
  #draw-tools {
    left: 4px;
    padding: 4px 2px;
    gap: 1px;
    min-width: 26px;
    border-radius: 6px;
  }
  #draw-tools .dt-btn {
    width: 22px !important;
    height: 22px !important;
    min-width: 22px !important;
    min-height: 22px !important;
    padding: 3px !important;
    border-radius: 4px;
  }
  #draw-tools .dt-btn svg { width: 11px !important; height: 11px !important; }
  #draw-tools .dt-sep { margin: 1px 0; height: 1px; }

  /* ═══ CHART AREA: maximum space for chart on mobile ═══ */
  #chart-area {
    height: 68dvh;
    /* fallback */
    height: 68vh;
    min-height: 260px;
    max-height: 78vh;
    flex: none !important;
    overflow: hidden;
  }

  /* ═══ CHART TOOLBAR: single horizontal scroll row ═══ */
  #ctbar {
    height: 34px;
    min-height: 34px;
    max-height: 34px;
    padding: 0 5px;
    gap: 3px;
    overflow-x: auto;
    overflow-y: visible;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
  }
  #ctbar::-webkit-scrollbar { display: none; }

  .sym-btn {
    font-size: 11px;
    flex-shrink: 0;
    padding: 2px 3px;
  }
  .sym-chg {
    font-size: 10px;
    min-width: 48px;
  }

  /* Timeframe buttons — touch-friendly */
  .tfb {
    padding: 3px 6px;
    font-size: 10.5px;
    min-width: 26px;
    min-height: 28px;
    flex-shrink: 0;
    border-radius: 4px;
  }

  /* Stat labels in toolbar */
  .stat { font-size: 10px; margin-right: 3px; flex-shrink: 0; }
  .sl   { font-size: 9.5px; }
  .sv   { font-size: 10px; }

  /* Exchange selector button */
  .exc-btn {
    padding: 4px 9px;
    font-size: 11px;
    max-width: none;
    flex-shrink: 0;
  }

  /* View toggle / density buttons */
  .vt-btn {
    min-width: 28px;
    min-height: 28px;
    padding: 4px;
    flex-shrink: 0;
  }

  #chart-density-settings-toggle {
    min-width: 28px;
    min-height: 28px;
    flex-shrink: 0;
  }

  .chart-back-btn {
    min-width: 28px;
    min-height: 28px;
    flex-shrink: 0;
  }

  /* Grid config nav (multichart) */
  .grid-nav { gap: 3px; flex-shrink: 0; }
  .grid-nav-btn { padding: 2px 6px; font-size: 11px; }
  #grid-page-label { font-size: 10px; }

  /* ═══ RESIZER: hidden on mobile ═══ */
  #rp-resizer { display: none !important; }

  /* ═══ RIGHT PANEL: fills remaining space ═══ */
  #rp {
    flex: 1 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: 0;
    border-left: none !important;
    border-top: 1px solid var(--bd);
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  /* Cancel collapsed state on mobile — always show panel */
  #main.rp-collapsed #rp {
    width: 100% !important;
    min-width: 0 !important;
    overflow: hidden;
  }

  /* Panel header (Монеты + count) */
  .rph {
    padding: 4px 8px 3px;
    min-height: 26px;
  }
  .rph-title { font-size: 10px; }
  .cnt { font-size: 9.5px; }

  /* Exchange filter bar (lex) — horizontal scroll */
  .lex {
    overflow-x: auto;
    overflow-y: visible;
    flex-wrap: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding: 4px 8px;
    gap: 3px;
  }
  .lex::-webkit-scrollbar { display: none; }

  /* Column headers */
  .clh {
    padding: 4px 6px 3px;
    font-size: 9.5px;
  }

  /* ═══ COIN LIST: touch-optimised ═══ */
  #coin-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  /* Coin rows — compact so ~5 rows visible, still touch-friendly */
  .cr {
    min-height: 28px;
    padding: 3px 6px;
    font-size: 10px;
  }

  /* Screener filters bar */
  .screener-filters {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .screener-filters::-webkit-scrollbar { display: none; }

  /* ═══ MODALS: full-width ═══ */
  .modal-content, .density-settings-modal {
    width: 95% !important;
    max-width: 100% !important;
    padding: 14px !important;
    border-radius: 10px !important;
  }

  /* Larger touch targets */
  .chart-tf-btn, .chart-indicator-grid-btn {
    min-height: 32px;
    min-width: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Multi-chart grid cell mobile */
  .cell-header { font-size: 10px; padding: 0 4px; }
}

/* ══════════════════════════════════════════════════════════════
   TABLET  768–1023px  —  Desktop layout, more compact
   ══════════════════════════════════════════════════════════════ */
@media (min-width: 768px) and (max-width: 1023px) {
  .sbox { width: 130px; }
  .stat { font-size: 10px; }
  .sl   { font-size: 9.5px; }
  .exc-btn { font-size: 11px; padding: 4px 9px; }
  #nav { padding: 0 10px; gap: 12px; }
  .ntab { padding: 5px 10px; font-size: 11px; }
  .tfb  { padding: 2px 5px; font-size: 10px; }

  .modal-content, .density-settings-modal {
    width: 92% !important;
    max-width: 500px !important;
    margin: 20px auto !important;
  }

  .table-container, .screener-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .chart-tf-btn, .vt-btn, .chart-indicator-grid-btn {
    min-height: 32px;
    min-width: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .cell-header { font-size: 10px; padding: 0 4px; }
}


/* ── Usability & Shortcut Modal Enhancements ── */
.shortcuts-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--bg3);
    border: 1px solid var(--bd);
    border-radius: var(--radius);
    color: var(--t2);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.shortcuts-btn:hover {
    color: var(--t1);
    border-color: var(--ac);
    background: var(--bgh);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(8, 10, 16, 0.82);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    align-items: center;
    justify-content: center;
    z-index: 99999;
    animation: modalOverlayFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Only `opacity` is animated here. The previous keyframes animated
   `backdrop-filter` from blur(0) to blur(16px), which re-runs a full-viewport
   blur+saturate on every frame for the whole 200 ms — by far the most expensive
   rule in this file. Fading the already-blurred layer in looks the same. */
@keyframes modalOverlayFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.shortcuts-modal-content {
    max-width: 480px;
    background: var(--bg2);
    border: 1px solid var(--bd2);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
}

/* ── Profile Button & User Profile Modal ── */
.profile-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--screener-header-bg, var(--bg3));
    border: 1px solid var(--bd);
    border-radius: var(--radius);
    color: var(--t2);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

.profile-btn:hover {
    color: var(--t1);
    border-color: var(--ac);
    background: var(--bgh);
    box-shadow: 0 0 10px rgba(124, 58, 237, 0.35);
}

.profile-btn svg {
    transition: transform 0.15s ease, stroke 0.15s ease;
}

.profile-btn:hover svg {
    transform: scale(1.1);
    stroke: var(--t1);
}

.profile-modal-content {
    max-width: 440px;
    width: 100%;
    background: var(--bg2);
    border: 1px solid var(--bd2);
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-sizing: border-box;
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}

#profile-modal { box-sizing: border-box; padding: 12px; }
#profile-modal .profile-modal-content { margin: 0 auto !important; }
#profile-modal .modal-header { position: sticky; top: 0; z-index: 1; flex: none; padding: 5px 0; background: var(--bg2); }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--t2);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.modal-close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.profile-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
}

.profile-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 12px;
    background: var(--bg3);
    border: 1px solid var(--bd);
    border-radius: 10px;
}

.profile-avatar-box {
    position: relative;
    flex-shrink: 0;
}

.profile-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed 0%, #4c1d95 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
}

.profile-status-online {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 11px;
    height: 11px;
    background: #26c97a;
    border: 2px solid #13151e;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(38, 201, 122, 0.8);
}

.profile-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow: hidden;
}

.profile-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.profile-name {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-badge-pro {
    font-size: 9px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    background: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 0 8px rgba(168, 85, 247, 0.4);
}

.profile-email {
    font-size: 11px;
    color: var(--t2);
}

.profile-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.profile-stat-card {
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid var(--bd);
    border-radius: 8px;
    padding: 7px 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.profile-stat-label {
    font-size: 10px;
    color: var(--t2);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.profile-stat-val {
    font-size: 12px;
    font-weight: 600;
    color: var(--t1);
}

.profile-stat-val.pos {
    color: var(--gr);
}

.profile-stat-val.accent {
    color: #c084fc;
}

.profile-actions {
    display: flex;
    gap: 8px;
}

.profile-act-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--bg3);
    border: 1px solid var(--bd2);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--t1);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

.profile-act-btn:hover {
    background: var(--bgh);
    border-color: var(--ac);
    color: #fff;
    box-shadow: 0 0 8px rgba(124, 58, 237, 0.25);
}

.profile-promo-section {
    padding-top: 10px;
    border-top: 1px solid var(--bd);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.profile-promo-section label {
    font-size: 11px;
    font-weight: 600;
    color: var(--t2);
    display: flex;
    align-items: center;
    gap: 5px;
}

.profile-promo-row {
    display: flex;
    gap: 8px;
}

.profile-promo-row input {
    flex: 1;
    background: var(--bg3);
    border: 1px solid var(--bd2);
    border-radius: 6px;
    padding: 7px 10px;
    font-size: 12px;
    color: #fff;
    outline: none;
    text-transform: uppercase;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.profile-promo-row input:focus {
    border-color: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.18);
}

.profile-promo-row button {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: 1px solid rgba(16, 185, 129, 0.4);
    border-radius: 6px;
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

.profile-promo-row button:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.35);
}

.profile-promo-row button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.profile-promo-msg {
    font-size: 11.5px;
    padding: 6px 10px;
    border-radius: 6px;
    margin-top: 2px;
    line-height: 1.35;
}

.profile-promo-msg.success {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: #34d399;
}

.profile-promo-msg.error {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #f87171;
}

.profile-edit-section {
    padding-top: 10px;
    border-top: 1px solid var(--bd);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.profile-edit-section label {
    font-size: 11px;
    font-weight: 600;
    color: var(--t2);
}

.profile-input-group {
    display: flex;
    gap: 8px;
}

.profile-input-group input {
    flex: 1;
    background: var(--bg3);
    border: 1px solid var(--bd2);
    border-radius: 6px;
    padding: 7px 10px;
    font-size: 12px;
    color: #fff;
    outline: none;
    transition: border-color 0.15s;
}

.profile-input-group input:focus {
    border-color: var(--ac);
}

.profile-input-group button {
    background: var(--ac);
    border: none;
    border-radius: 6px;
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: background 0.15s ease;
}

.profile-input-group button:hover {
    background: #6d28d9;
}

.profile-id-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 800;
    font-family: 'Inter', monospace;
    color: #e9d5ff;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.25) 0%, rgba(124, 58, 237, 0.25) 100%);
    border: 1px solid rgba(168, 85, 247, 0.5);
    border-radius: 6px;
    padding: 3px 8px;
    margin-top: 3px;
    width: fit-content;
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.3);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.profile-id-badge:hover {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.4) 0%, rgba(124, 58, 237, 0.4) 100%);
    border-color: #c084fc;
    box-shadow: 0 0 14px rgba(168, 85, 247, 0.5);
    transform: translateY(-1px);
}

.profile-tg-bot-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(34, 158, 217, 0.08);
    border: 1px solid rgba(34, 158, 217, 0.25);
    border-radius: 10px;
    padding: 10px 14px;
    margin-top: 2px;
}

.tg-bot-card-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tg-bot-card-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
}

.tg-bot-status-text {
    font-size: 11px;
    color: var(--t2);
}

.tg-bot-status-text.connected {
    color: var(--gr);
    font-weight: 600;
}

.tg-bot-link-btn {
    background: #229ED9;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 2px 8px rgba(34, 158, 217, 0.3);
}

.tg-bot-link-btn:hover {
    background: #1c8adb;
    box-shadow: 0 4px 12px rgba(34, 158, 217, 0.5);
}

.profile-logout-section {
    padding-top: 10px;
    border-top: 1px solid var(--bd);
}

.profile-logout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(255, 69, 96, 0.1);
    border: 1px solid rgba(255, 69, 96, 0.25);
    color: #ff4560;
    border-radius: 8px;
    padding: 9px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.profile-logout-btn:hover {
    background: rgba(255, 69, 96, 0.2);
    border-color: #ff4560;
    color: #fff;
}

/* ── Auth Modal (Registration & Login) ── */
.auth-modal-content {
    max-width: 400px;
    width: 100%;
    background: var(--bg2);
    border: 1px solid var(--bd2);
    border-radius: 14px;
    padding: 24px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
}

.auth-tabs {
    display: flex;
    background: var(--bg3);
    border: 1px solid var(--bd);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
}

.auth-tab-btn {
    flex: 1;
    padding: 7px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--t2);
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
    text-align: center;
}

.auth-tab-btn.active {
    color: #fff;
    background: var(--ac);
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.4);
}

.auth-banner-error {
    background: rgba(255, 69, 96, 0.15);
    border: 1px solid var(--rd);
    color: #ff6b81;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 12px;
    line-height: 1.4;
}

.auth-banner-notice {
    background: rgba(124, 58, 237, 0.15);
    border: 1px solid rgba(168, 85, 247, 0.4);
    color: #d8b4fe;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 12px;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 8px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.auth-field label {
    font-size: 11px;
    font-weight: 600;
    color: var(--t2);
}

.auth-field input {
    background: var(--bg3);
    border: 1px solid var(--bd2);
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 13px;
    color: #fff;
    outline: none;
    transition: border-color 0.15s ease;
}

.auth-field input:focus {
    border-color: var(--ac);
    box-shadow: 0 0 8px rgba(124, 58, 237, 0.25);
}

.profile-referral-caption { margin: 7px 0 8px; color: var(--t2); font-size: 11px; }
.profile-referral-stats { margin-top: 10px; overflow: hidden; border: 1px solid var(--bd2); border-radius: 9px; background: rgba(255,255,255,.018); }
.profile-referral-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.profile-referral-cell { display: flex; min-width: 0; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 9px 2px; text-align: center; }
.profile-referral-cell + .profile-referral-cell { border-left: 1px solid var(--bd2); }
.profile-referral-cell span { max-width: 100%; overflow: hidden; color: var(--t3); font-size: 10px; white-space: nowrap; text-overflow: ellipsis; }
.profile-referral-cell strong { color: var(--t1); font-size: 16px; line-height: 1; font-variant-numeric: tabular-nums; }
.profile-referral-plans-title { padding: 6px 10px; border-top: 1px solid var(--bd2); border-bottom: 1px solid var(--bd2); color: var(--t3); background: rgba(255,255,255,.025); font-size: 10px; font-weight: 700; letter-spacing: .02em; }
.profile-referral-plans .profile-referral-cell { padding: 8px 2px; }
.profile-referral-plans .profile-referral-cell strong { font-size: 13px; color: #c4b5fd; }
.profile-referral-status { margin: 0; color: var(--t3); font-size: 10px; text-align: center; }
.profile-referral-status:not(:empty) { padding: 7px; border-top: 1px solid var(--bd2); }
.profile-referral-compact { position: relative; min-width: 0; border: 1px solid var(--bd2); border-radius: 9px; background: rgba(124,58,237,.055); }
.profile-referral-compact[open] { border-color: rgba(168,85,247,.35); }
.profile-referral-summary { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 5px 10px; cursor: pointer; list-style: none; }
.profile-referral-summary::-webkit-details-marker { display: none; }
.profile-referral-summary:focus-visible { outline: 2px solid var(--ac); outline-offset: 2px; border-radius: 8px; }
.profile-referral-summary-title { min-width: 0; overflow: hidden; color: var(--t1); font-size: 11px; font-weight: 700; white-space: nowrap; text-overflow: ellipsis; }
.profile-referral-summary-counts { margin-left: auto; color: var(--t2); font-size: 10px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.profile-referral-chevron { color: var(--t3); transition: transform .15s ease; }
.profile-referral-compact[open] .profile-referral-chevron { transform: rotate(180deg); }
.profile-referral-body { padding: 0 10px 10px; border-top: 1px solid var(--bd2); }
.profile-referral-rewards { margin-top: 10px; padding: 9px 10px; border: 1px solid rgba(168,85,247,.22); border-radius: 8px; background: rgba(124,58,237,.06); }
.profile-referral-rewards > strong { display: block; margin-bottom: 6px; color: var(--t1); font-size: 11px; }
.profile-referral-rewards > div { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; color: var(--t2); font-size: 10px; }
.profile-referral-rewards > div b { color: #c4b5fd; font-weight: 700; white-space: nowrap; }
.profile-referral-rewards .profile-referral-progress { margin-bottom: 5px; padding: 5px 7px; border-radius: 5px; background: rgba(124,58,237,.14); color: #c4b5fd; font-weight: 700; }
.profile-referral-rewards p { margin: 7px 0 0; color: var(--t3); font-size: 10px; line-height: 1.45; }
.profile-referral-rewards a { color: #7dd3fc; text-decoration: none; }
.profile-referral-rewards a:hover { text-decoration: underline; }
@media (max-width: 440px) {
    .profile-referral-summary-counts { font-size: 9px; }
    .profile-referral-summary-title { font-size: 10px; }
}

/* The compact trigger remains in the profile. On wide screens its details are
   a side popover, so opening referrals does not make the profile modal taller. */
@media (min-width: 900px) {
    .profile-referral-body {
        position: fixed;
        top: var(--referral-popover-top, 12px);
        left: var(--referral-popover-left, 12px);
        z-index: 100001;
        box-sizing: border-box;
        width: min(390px, calc(100vw - 24px));
        max-height: calc(100dvh - 24px);
        overflow-y: auto;
        padding: 10px;
        border: 1px solid rgba(168,85,247,.42);
        border-radius: 11px;
        background: #151322;
        box-shadow: 0 18px 48px rgba(0,0,0,.58), 0 0 26px rgba(124,58,237,.14);
    }
    .profile-referral-caption { margin-top: 0; }
}

@media (max-height: 900px) {
    #profile-modal .profile-modal-content { gap: 8px; padding-top: 10px; padding-bottom: 10px; }
    #profile-modal .profile-card { padding-top: 8px; padding-bottom: 8px; }
    #profile-modal .profile-stat-card { padding-top: 6px; padding-bottom: 6px; }
    #profile-modal .profile-referral-cell { padding-top: 6px; padding-bottom: 6px; }
    #profile-modal .profile-referral-plans-title { padding-top: 4px; padding-bottom: 4px; }
    #profile-modal .profile-bug-card { margin-top: 4px; margin-bottom: 4px; padding-top: 7px; padding-bottom: 7px; }
}

.profile-manager-link { display: flex; align-items: center; gap: 7px; min-height: 34px; padding: 5px 10px; border: 1px solid rgba(34,158,217,.22); border-radius: 8px; background: rgba(34,158,217,.045); color: var(--t1); text-decoration: none; font-size: 11px; transition: background .15s, border-color .15s; }
.profile-manager-link:hover { border-color: rgba(34,158,217,.5); background: rgba(34,158,217,.1); }
.profile-manager-icon { display: grid; width: 20px; height: 20px; flex: none; place-items: center; border-radius: 6px; background: rgba(34,158,217,.15); color: #4fb8e8; font-size: 12px; }
.profile-manager-name { min-width: 0; font-weight: 700; white-space: nowrap; }
.profile-manager-handle { margin-left: auto; color: var(--t2); white-space: nowrap; }
.profile-manager-arrow { color: #4fb8e8; font-size: 14px; }

#reg-code-field small {
    color: var(--t3);
    line-height: 1.45;
}

#reg-code {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-align: center;
}

.auth-code-link {
    align-self: flex-start;
    padding: 2px 0;
    background: none;
    border: 0;
    color: #ac8dff;
    font-size: 12px;
    cursor: pointer;
}

.auth-code-link:disabled { opacity: 0.5; cursor: wait; }
.auth-submit-btn:disabled { opacity: 0.6; cursor: wait; }

.auth-submit-btn {
    margin-top: 4px;
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.4);
}

.auth-submit-btn:hover {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    box-shadow: 0 6px 18px rgba(124, 58, 237, 0.6);
}

.auth-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--t3);
    font-size: 11px;
    margin: 2px 0;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--bd);
}

.auth-divider span {
    padding: 0 10px;
}

.telegram-auth-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #229ED9;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 4px 12px rgba(34, 158, 217, 0.35);
}

.telegram-auth-btn:hover {
    background: #1c8adb;
    box-shadow: 0 6px 16px rgba(34, 158, 217, 0.5);
}

.shortcuts-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 14px;
}

.shortcut-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    font-size: 12px;
    color: var(--t2);
}

.shortcut-item kbd {
    background: #202433;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    padding: 2px 7px;
    font-family: monospace;
    font-size: 11px;
    color: #f3f4f6;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}

/* Sticky screener table headers */
.screener-table th, .table-container th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg2);
    box-shadow: 0 1px 0 var(--bd);
}

/* ════════════════════════════════════════════════════════════════════════════
   TRADER MAKE MONEY STYLE TRADING JOURNAL (ДНЕВНИК ТРЕЙДЕРА)
   ════════════════════════════════════════════════════════════════════════════ */
#journal-view {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: calc(100vh - 44px);
    background: var(--bg);
    color: var(--t1);
    overflow-y: auto;
    padding: 16px 20px 40px 20px;
    gap: 16px;
}

.j-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg2);
    border: 1px solid var(--bd2);
    border-radius: 10px;
    padding: 12px 18px;
    gap: 16px;
    flex-wrap: wrap;
}

.j-title-group h1 {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.j-title-group p {
    font-size: 11px;
    color: var(--t2);
    margin-top: 2px;
}

.j-sub-tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--bd);
    border-radius: 8px;
    padding: 3px;
    gap: 4px;
}

.j-sub-tab {
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--t2);
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
    user-select: none;
}

.j-sub-tab:hover {
    color: var(--t1);
    background: var(--bgh);
}

.j-sub-tab.on {
    color: #fff;
    background: var(--ac);
    box-shadow: 0 2px 8px var(--acglow);
}

.j-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.j-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid var(--bd2);
    background: var(--bg3);
    color: var(--t1);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.j-btn:hover {
    background: var(--bgh2);
    border-color: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.j-btn-primary {
    background: var(--gr);
    color: #0d0f14;
    border-color: var(--gr);
    box-shadow: 0 2px 10px var(--grglow);
}

.j-btn-primary:hover {
    background: #2ee68c;
    border-color: #2ee68c;
    color: #0d0f14;
}

.j-btn-api {
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    color: #fff;
    border-color: #7c3aed;
    box-shadow: 0 2px 10px var(--acglow);
}

.j-btn-api:hover {
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
}

.j-select {
    background: var(--bg3);
    border: 1px solid var(--bd2);
    color: var(--t1);
    font-size: 12px;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: 6px;
    outline: none;
    cursor: pointer;
}

/* ── TMM Stats Widgets ── */
.j-widgets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
}

.j-stat-card {
    background: var(--bg2);
    border: 1px solid var(--bd2);
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.j-stat-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.j-stat-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--t2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.j-stat-val {
    font-size: 20px;
    font-weight: 800;
    color: #fff;
    margin-top: 4px;
}

.j-stat-sub {
    font-size: 11px;
    color: var(--t2);
    margin-top: 2px;
}

.j-stat-win { color: var(--gr); }
.j-stat-loss { color: var(--rd); }

/* ── Equity Curve Panel ── */
.j-card {
    background: var(--bg2);
    border: 1px solid var(--bd2);
    border-radius: 10px;
    padding: 16px;
}

.j-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.j-card-title {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.j-equity-wrap {
    width: 100%;
    height: 240px;
    position: relative;
}

.j-equity-wrap canvas {
    width: 100% !important;
    height: 100% !important;
    cursor: crosshair;
}

/* ── Filter Bar ── */
.j-filters-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg2);
    border: 1px solid var(--bd2);
    border-radius: 10px;
    padding: 10px 14px;
    flex-wrap: wrap;
}

.j-search-box {
    display: flex;
    align-items: center;
    background: var(--bg3);
    border: 1px solid var(--bd);
    border-radius: 6px;
    padding: 0 10px;
    height: 32px;
    min-width: 200px;
}

.j-search-box input {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 12px;
    width: 100%;
    outline: none;
}

/* ── Trades Table ── */
.j-table-wrap {
    background: var(--bg2);
    border: 1px solid var(--bd2);
    border-radius: 10px;
    overflow-x: auto;
}

.j-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    text-align: left;
}

.j-table th {
    background: rgba(0, 0, 0, 0.25);
    color: var(--t2);
    font-size: 11px;
    font-weight: 600;
    padding: 10px 14px;
    border-bottom: 1px solid var(--bd2);
    white-space: nowrap;
}

.j-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--bd);
    color: var(--t1);
}

.j-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.j-pnl-win { color: var(--gr); font-weight: 700; }
.j-pnl-loss { color: var(--rd); font-weight: 700; }

.j-side-badge {
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 700;
    border-radius: 4px;
    display: inline-block;
}

.j-side-long {
    background: rgba(38, 201, 122, 0.15);
    color: #26c97a;
    border: 1px solid rgba(38, 201, 122, 0.3);
}

.j-side-short {
    background: rgba(255, 69, 96, 0.15);
    color: #ff4560;
    border: 1px solid rgba(255, 69, 96, 0.3);
}

.j-tag-pill {
    display: inline-block;
    padding: 2px 7px;
    font-size: 10px;
    font-weight: 600;
    border-radius: 10px;
    margin-right: 4px;
    margin-bottom: 2px;
    white-space: nowrap;
}

.j-act-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--bd);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 11px;
    color: var(--t1);
    cursor: pointer;
    margin-left: 4px;
    transition: background-color 0.12s, color 0.12s;
}

.j-act-btn:hover {
    background: var(--bgh);
    color: #fff;
}

/* ── Calendar Heatmap View ── */
.j-calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.j-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.j-cal-head-day {
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--t2);
    padding: 6px 0;
    text-transform: uppercase;
}

.j-cal-day-cell {
    background: var(--bg3);
    border: 1px solid var(--bd2);
    border-radius: 8px;
    min-height: 80px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    transition: transform 0.12s, border-color 0.12s;
}

.j-cal-day-cell:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.2);
}

.j-cal-day-num {
    font-size: 12px;
    font-weight: 700;
    color: var(--t2);
}

.j-cal-day-pnl {
    font-size: 13px;
    font-weight: 800;
    margin-top: 4px;
}

.j-cal-day-count {
    font-size: 10px;
    color: var(--t2);
}

.j-cal-win { background: rgba(38, 201, 122, 0.12); border-color: rgba(38, 201, 122, 0.3); }
.j-cal-loss { background: rgba(255, 69, 96, 0.12); border-color: rgba(255, 69, 96, 0.3); }

/* ── Analytics View ── */
.j-analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
}

.j-chart-box {
    height: 220px;
    position: relative;
    margin-top: 10px;
}

/* ── Exchange API Settings & Toggles ── */
.j-api-head-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.j-api-gear-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
    color: var(--t2);
    cursor: pointer;
    transition: background-color 0.22s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.22s cubic-bezier(0.4, 0, 0.2, 1), color 0.22s cubic-bezier(0.4, 0, 0.2, 1), transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
}

.j-api-gear-btn:hover {
    background: rgba(108, 93, 211, 0.22);
    border-color: #6c5dd3;
    color: #fff;
    transform: rotate(45deg);
}

.j-api-gear-btn.active {
    background: rgba(108, 93, 211, 0.3);
    border-color: #a78bfa;
    color: #a78bfa;
}

.j-api-settings-panel {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 2px;
}

.j-api-settings-title {
    font-size: 10px;
    font-weight: 700;
    color: #a78bfa;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.j-api-setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.j-api-setting-row:last-child {
    border-bottom: none;
    padding-bottom: 2px;
}

.j-api-setting-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.j-api-setting-name {
    font-size: 11.5px;
    font-weight: 600;
    color: #f1f5f9;
}

.j-api-setting-hint {
    font-size: 10px;
    color: var(--t2);
    line-height: 1.3;
}

.j-toggle-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}

.j-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.j-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255, 255, 255, 0.14);
    border-radius: 20px;
    transition: background-color 0.22s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.j-toggle-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: #ffffff;
    border-radius: 50%;
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

.j-toggle-switch input:checked + .j-toggle-slider {
    background-color: #26c97a;
    border-color: rgba(38, 201, 122, 0.4);
}

.j-toggle-switch input:checked + .j-toggle-slider:before {
    transform: translateX(16px);
}

.j-chart-box canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ── API Keys Settings Grid ── */
.j-api-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.j-api-card {
    background: var(--bg2);
    border: 1px solid var(--bd2);
    border-radius: 10px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.j-api-card-head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.j-api-logo {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.j-api-name {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
}

.j-api-status {
    margin-left: auto;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
}

.j-api-status.connected { background: rgba(38, 201, 122, 0.2); color: #26c97a; }
.j-api-status.disconnected { background: rgba(255, 255, 255, 0.05); color: var(--t2); }

.j-api-input {
    background: var(--bg3);
    border: 1px solid var(--bd);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 11px;
    color: #fff;
    outline: none;
    width: 100%;
}

.j-api-input:focus {
    border-color: var(--ac);
}

/* ── Modals ── */
.j-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.j-modal-content {
    background: var(--bg2);
    border: 1px solid var(--bd2);
    border-radius: 12px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.j-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--bd);
    padding-bottom: 10px;
}

.j-modal-title {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
}

.j-modal-close {
    background: transparent;
    border: none;
    color: var(--t2);
    font-size: 20px;
    cursor: pointer;
}

.j-modal-close:hover { color: #fff; }

.j-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.j-form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.j-form-group.full {
    grid-column: 1 / -1;
}

.j-form-group label {
    font-size: 11px;
    font-weight: 600;
    color: var(--t2);
}

.j-form-group input, .j-form-group select, .j-form-group textarea {
    background: var(--bg3);
    border: 1px solid var(--bd2);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 12px;
    color: #fff;
    outline: none;
}

.j-form-group textarea {
    resize: vertical;
    min-height: 70px;
}

.j-modal-tag-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--bd);
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    user-select: none;
}

/* ── PnL Card Generator ── */
.j-pnl-card-preview {
    background: linear-gradient(135deg, #13151e 0%, #1a1d2d 100%);
    border: 1px solid var(--bd2);
    border-radius: 16px;
    padding: 24px;
    color: #fff;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.j-pnl-card-preview::before {
    content: "";
    position: absolute;
    top: -50px; right: -50px;
    width: 150px; height: 150px;
    background: var(--acglow);
    filter: blur(50px);
    border-radius: 50%;
}

.j-pnl-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.j-pnl-card-pct {
    font-size: 38px;
    font-weight: 900;
    margin: 10px 0;
    letter-spacing: -0.5px;
}

/* Sleek ultra-compact 28px icon button for drawings toggle */
.drawings-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: var(--bg3, #1e222d);
    border: 1px solid var(--bd, #2a2e39);
    border-radius: var(--radius, 6px);
    color: var(--t3, #64748b);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
    user-select: none;
    flex-shrink: 0;
    outline: none;
}

.drawings-toggle-btn svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    transition: stroke 0.15s ease, transform 0.15s ease;
}

.drawings-toggle-btn:hover {
    color: var(--t1, #f1f5f9);
    background: var(--bgh, #2a2e39);
    border-color: rgba(255, 255, 255, 0.2);
}

.drawings-toggle-btn:hover svg {
    transform: scale(1.1);
}

#btn-toggle-mc-drawings.on,
#btn-toggle-formations-drawings.on,
.drawings-toggle-btn.on {
    color: #c084fc !important;
    background: rgba(168, 85, 247, 0.25) !important;
    border: 1px solid #a855f7 !important;
    box-shadow: 0 0 14px rgba(168, 85, 247, 0.6) !important;
}

#btn-toggle-mc-drawings.on svg,
#btn-toggle-formations-drawings.on svg,
.drawings-toggle-btn.on svg {
    stroke: #c084fc !important;
}

#btn-toggle-mc-drawings.on:hover,
#btn-toggle-formations-drawings.on:hover,
.drawings-toggle-btn.on:hover {
    color: #e9d5ff !important;
    background: rgba(168, 85, 247, 0.38) !important;
    border-color: #c084fc !important;
    box-shadow: 0 0 18px rgba(168, 85, 247, 0.8) !important;
}

/* ── PRO Modal & Subscription Styles ── */
.profile-plan-upgrade-banner {
    display: flex;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 14px !important;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.22) 0%, rgba(168, 85, 247, 0.12) 100%) !important;
    border: 1px solid rgba(168, 85, 247, 0.5) !important;
    border-radius: 12px !important;
    padding: 14px 18px !important;
    margin: 16px 0 !important;
    box-shadow: 0 8px 25px rgba(124, 58, 237, 0.25), inset 0 1px 1px rgba(255, 255, 255, 0.15) !important;
    position: relative !important;
    overflow: hidden !important;
}

.profile-plan-upgrade-banner::before {
    content: "" !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 4px !important;
    height: 100% !important;
    background: linear-gradient(180deg, #a855f7 0%, #7c3aed 100%) !important;
    border-radius: 12px 0 0 12px !important;
}

.banner-left {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    flex: 1 !important;
    min-width: 0 !important;
}

.banner-icon-badge {
    font-size: 22px !important;
    width: 42px !important;
    height: 42px !important;
    border-radius: 10px !important;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.35) 0%, rgba(124, 58, 237, 0.15) 100%) !important;
    border: 1px solid rgba(192, 132, 252, 0.4) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    box-shadow: 0 0 14px rgba(168, 85, 247, 0.4) !important;
}

.banner-text {
    display: flex !important;
    flex-direction: column !important;
    gap: 3px !important;
    min-width: 0 !important;
}

.banner-title {
    font-size: 14.5px !important;
    font-weight: 800 !important;
    color: #ffffff !important;
    letter-spacing: 0.3px !important;
    background: linear-gradient(135deg, #ffffff 0%, #e9d5ff 100%) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}

.banner-sub {
    font-size: 11.5px !important;
    color: #c084fc !important;
    font-weight: 500 !important;
    line-height: 1.35 !important;
}

.pro-upgrade-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    background: linear-gradient(135deg, #8b5cf6 0%, #a855f7 100%) !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    font-size: 12.5px !important;
    padding: 10px 18px !important;
    border-radius: 8px !important;
    white-space: nowrap !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    box-shadow: 0 4px 18px rgba(139, 92, 246, 0.5) !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
    transition: background-color 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important, border-color 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important, box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
    text-decoration: none !important;
}

.pro-upgrade-btn:hover {
    transform: translateY(-1px) scale(1.02) !important;
    background: linear-gradient(135deg, #7c3aed 0%, #c084fc 100%) !important;
    box-shadow: 0 6px 25px rgba(168, 85, 247, 0.75) !important;
    border-color: rgba(255, 255, 255, 0.45) !important;
}

.pro-upgrade-btn:active {
    transform: translateY(0) scale(0.98) !important;
}

.pro-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(8, 10, 15, 0.75);
    backdrop-filter: blur(12px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* OBSIDIAN MODAL BACKDROP & OVERLAY */
.pro-modal-backdrop {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(4, 6, 12, 0.82) !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    z-index: 999999 !important;
    display: flex;
    align-items: center !important;
    justify-content: center !important;
    padding: 20px !important;
    box-sizing: border-box !important;
}

.pro-modal-content {
    position: relative !important;
    max-width: 480px !important;
    width: 100% !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
    background: #0d0b18 !important;
    border: 1px solid rgba(168, 85, 247, 0.45) !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85), 0 0 35px rgba(139, 92, 246, 0.35), inset 0 0 20px rgba(168, 85, 247, 0.08) !important;
    border-radius: 16px !important;
    padding: 24px 26px !important;
    color: #fff !important;
    display: flex;
    flex-direction: column;
    gap: 18px;
    animation: modalPopIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

@keyframes modalPopIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.pro-modal-close {
    position: absolute !important;
    top: 16px !important;
    right: 16px !important;
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #94a3b8 !important;
    width: 30px !important;
    height: 30px !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background-color 0.15s ease !important, border-color 0.15s ease !important, color 0.15s ease !important;
    padding: 0 !important;
}

.pro-modal-close:hover {
    background: rgba(239, 68, 68, 0.2) !important;
    color: #ef4444 !important;
    border-color: rgba(239, 68, 68, 0.4) !important;
}

.pro-modal-header {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding-top: 4px;
}

.pro-crown-icon {
    font-size: 34px;
    filter: drop-shadow(0 0 14px rgba(245, 158, 11, 0.7));
    line-height: 1;
    margin-bottom: 2px;
}

.pro-title-wrap h3 {
    font-size: 21px;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.3px;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    text-shadow: 0 0 16px rgba(168, 85, 247, 0.3);
}

.pro-badge-pill {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.8px;
    padding: 2px 8px;
    border-radius: 4px;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.35), rgba(124, 58, 237, 0.35));
    border: 1px solid rgba(192, 132, 252, 0.6);
    color: #e9d5ff;
    text-transform: uppercase;
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.4);
}

.pro-modal-subtitle {
    font-size: 12px;
    color: #a78bfa;
    font-weight: 500;
}

.pro-features-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(168, 85, 247, 0.18);
    border-radius: 12px;
    padding: 6px;
}

.pro-feature-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    transition: background 0.15s ease;
}

.pro-feature-item:hover {
    background: rgba(124, 58, 237, 0.08);
}

.pro-feature-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pro-feature-icon.icon-heatmap {
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.35);
    color: #38bdf8;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
}

.pro-feature-icon.icon-arbitrage {
    background: rgba(168, 85, 247, 0.12);
    border: 1px solid rgba(168, 85, 247, 0.35);
    color: #c084fc;
    box-shadow: 0 0 12px rgba(168, 85, 247, 0.25);
}

.pro-feature-icon.icon-detector {
    background: rgba(244, 63, 94, 0.12);
    border: 1px solid rgba(244, 63, 94, 0.35);
    color: #fb7185;
    box-shadow: 0 0 12px rgba(244, 63, 94, 0.25);
}

.pro-feature-icon.icon-backtest {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: #34d399;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.25);
}

.pro-feature-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pro-feature-info strong {
    font-size: 13.5px;
    font-weight: 600;
    color: #ffffff;
}

.pro-feature-info span {
    font-size: 11px;
    color: #a1a1aa;
    line-height: 1.35;
}

.pro-modal-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    margin-top: 4px;
}

.pro-modal-buy-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
    color: #ffffff;
    font-weight: 700;
    font-size: 14px;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.55), 0 0 15px rgba(168, 85, 247, 0.35);
    transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
    text-decoration: none;
}

.pro-modal-buy-btn:hover {
    background: linear-gradient(135deg, #6d28d9 0%, #9333ea 100%);
    box-shadow: 0 6px 26px rgba(124, 58, 237, 0.75), 0 0 20px rgba(168, 85, 247, 0.5);
    transform: translateY(-1px);
}

.pro-modal-details-btn {
    background: none;
    border: none;
    color: #c084fc;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 14px;
    transition: background-color 0.15s ease, color 0.15s ease;
    text-decoration: none;
    border-radius: 6px;
    text-shadow: 0 0 10px rgba(168, 85, 247, 0.4);
}

.pro-modal-details-btn:hover {
    color: #e9d5ff;
    background: rgba(168, 85, 247, 0.15);
}

/* PRO COMPARISON TABLE MODAL STYLES */
.pro-compare-box {
    max-width: 660px !important;
    width: 100% !important;
    padding: 26px 28px !important;
    background: #0d0b18 !important;
    border: 1px solid rgba(168, 85, 247, 0.45) !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85), 0 0 35px rgba(139, 92, 246, 0.35) !important;
}

.pro-compare-header {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-bottom: 6px;
}

.pro-compare-header h3 {
    font-size: 19px;
    font-weight: 700;
    color: #f8fafc;
    margin: 4px 0 0 0;
}

.pro-compare-sub {
    font-size: 12px;
    color: #64748b;
    margin: 0;
}

.pro-compare-table-wrapper {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.015);
    margin: 12px 0;
    max-height: 380px;
    overflow-y: auto;
}

.pro-compare-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 12px;
}

.pro-compare-table th {
    padding: 12px 14px;
    background: rgba(15, 23, 42, 0.6);
    color: #94a3b8;
    font-weight: 600;
    font-size: 11.5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    position: sticky;
    top: 0;
    z-index: 2;
}

.pro-compare-table th.col-feature {
    width: 44%;
}

.pro-compare-table th.col-free {
    width: 28%;
    text-align: center;
}

.pro-compare-table th.col-pro {
    width: 28%;
    text-align: center;
    color: #c084fc;
    background: rgba(124, 58, 237, 0.15);
}

.pro-compare-table td {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    vertical-align: middle;
}

.pro-compare-table tr.table-section-title td {
    background: rgba(255, 255, 255, 0.03);
    color: #a78bfa;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 8px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.pro-compare-table td.col-feature {
    color: #e2e8f0;
    font-weight: 500;
}

.pro-compare-table td.col-free {
    color: #94a3b8;
    text-align: center;
    font-size: 11.5px;
}

.pro-compare-table td.col-pro {
    color: #f8fafc;
    text-align: center;
    font-weight: 600;
    background: rgba(124, 58, 237, 0.04);
    font-size: 11.5px;
}

.badge-check {
    color: #10b981;
    font-weight: 800;
    margin-right: 4px;
}

.badge-cross {
    color: #64748b;
    font-weight: 700;
    margin-right: 4px;
}

.pro-compare-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.pro-compare-back-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #94a3b8;
    font-weight: 500;
    font-size: 12.5px;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.pro-compare-back-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.pro-compare-buy-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
    color: #ffffff;
    font-weight: 700;
    font-size: 13.5px;
    padding: 10px 20px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.4);
    transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.pro-compare-buy-btn:hover {
    background: linear-gradient(135deg, #6d28d9 0%, #9333ea 100%);
    box-shadow: 0 6px 18px rgba(124, 58, 237, 0.6);
    transform: translateY(-1px);
}

/* OBSIDIAN PRO PAY MODAL STYLES */
.pay-modal-box {
    max-width: 580px !important;
    background: #0f0b1a !important;
    border: 1px solid rgba(124, 58, 237, 0.4) !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 40px rgba(124, 58, 237, 0.25) !important;
    border-radius: 20px !important;
    padding: 28px !important;
}

.pay-modal-header {
    text-align: center;
    margin-bottom: 22px;
}

.pay-modal-badge {
    display: inline-block;
    padding: 4px 12px;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.2), rgba(236, 72, 153, 0.2));
    border: 1px solid rgba(168, 85, 247, 0.4);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    color: #c084fc;
    letter-spacing: 0.8px;
    margin-bottom: 8px;
}

.pay-modal-header h3 {
    font-size: 22px;
    font-weight: 800;
    color: #fff;
    margin: 0 0 6px 0;
}

.pay-modal-sub {
    font-size: 13px;
    color: #94a3b8;
    margin: 0;
}

.pay-tariffs-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.pay-tariff-card {
    position: relative;
    background: rgba(255, 255, 255, 0.03);
    border: 1.5px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 14px;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.pay-tariff-card:hover {
    border-color: rgba(168, 85, 247, 0.5);
    background: rgba(124, 58, 237, 0.08);
}

.pay-tariff-card.selected {
    border-color: #a855f7 !important;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.15), rgba(168, 85, 247, 0.08)) !important;
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.3) !important;
}

.pay-t-badge {
    position: absolute;
    top: -9px;
    right: 10px;
    background: #3b82f6;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
}

.pay-t-badge.pop {
    background: linear-gradient(135deg, #a855f7, #ec4899);
}

.pay-t-badge.gold {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
}

.pay-t-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.pay-t-title {
    font-size: 13px;
    font-weight: 700;
    color: #e2e8f0;
}

.pay-t-price {
    font-size: 18px;
    font-weight: 900;
    color: #26c97a;
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
}

.pay-t-old-price {
    font-size: 13px;
    color: #64748b;
    text-decoration: line-through;
    font-weight: 600;
}

.pay-t-new-price {
    color: #26c97a;
    font-weight: 900;
}

.pay-t-desc {
    font-size: 11px;
    color: #94a3b8;
    transition: color 0.2s ease;
}

.pay-t-desc-discounted {
    color: #38bdf8;
    font-weight: 600;
}

.pay-promo-box {
    margin-bottom: 16px;
}

.pay-promo-box > label {
    display: block;
    margin-bottom: 7px;
    color: #cbd5e1;
    font-size: 12px;
    font-weight: 650;
}

.pay-promo-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
}

.pay-promo-row input {
    min-width: 0;
    padding: 11px 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    outline: none;
    background: rgba(255, 255, 255, 0.035);
    color: #fff;
    font: 650 12px/1.2 inherit;
    text-transform: uppercase;
}

.pay-promo-row input:focus {
    border-color: #a855f7;
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.13);
}

.pay-promo-row button {
    padding: 0 14px;
    border: 1px solid rgba(168, 85, 247, 0.45);
    border-radius: 10px;
    background: rgba(124, 58, 237, 0.14);
    color: #d8b4fe;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.pay-promo-row button:disabled,
.pay-continue-btn:disabled {
    cursor: wait;
    opacity: 0.6;
}

.pay-promo-feedback {
    min-height: 16px;
    margin-top: 6px;
    color: #94a3b8;
    font-size: 11px;
}

.pay-promo-feedback.success,
.pay-invoice-promo {
    color: #26c97a;
}

.pay-promo-feedback.error {
    color: #fb7185;
}

.pay-invoice-promo {
    display: block;
    margin-top: 8px;
    font-size: 11px;
    font-weight: 700;
}

.pay-method-selector {
    margin-bottom: 20px;
}

.pay-method-title {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #cbd5e1;
    margin-bottom: 8px;
}

.pay-methods-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pay-method-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1.5px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 12px 14px;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    width: 100%;
}

.pay-method-btn:hover {
    border-color: rgba(168, 85, 247, 0.4);
}

.pay-method-btn.active {
    border-color: #26c97a !important;
    background: rgba(38, 201, 122, 0.08) !important;
}

.pay-method-icon {
    font-size: 20px;
}

.pay-method-info strong {
    display: block;
    font-size: 13px;
    color: #fff;
}

.pay-method-info span {
    font-size: 11px;
    color: #94a3b8;
}

.pay-continue-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #8b5cf6, #d946ef);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    box-shadow: 0 4px 20px rgba(217, 70, 239, 0.3);
}

.pay-continue-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 25px rgba(217, 70, 239, 0.5);
}

.pay-timer-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.3);
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 12px;
    color: #fbbf24;
    margin-bottom: 16px;
}

.pay-amount-box, .pay-address-box {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 14px;
}

.pay-box-label {
    display: block;
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 6px;
}

.pay-amount-display, .pay-address-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pay-amount-display strong {
    font-size: 20px;
    font-weight: 900;
    color: #26c97a;
}

.pay-address-display code {
    font-size: 13px;
    color: #c084fc;
    background: rgba(168, 85, 247, 0.15);
    padding: 4px 8px;
    border-radius: 6px;
    word-break: break-all;
}

.pay-copy-icon-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.pay-copy-icon-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.pay-box-sub-warn {
    display: block;
    font-size: 10px;
    color: #ef4444;
    margin-top: 6px;
}

.pay-status-checker {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px;
    background: rgba(124, 58, 237, 0.1);
    border: 1px dashed rgba(168, 85, 247, 0.4);
    border-radius: 10px;
    font-size: 12px;
    color: #d8b4fe;
}

.pay-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(168, 85, 247, 0.3);
    border-top-color: #a855f7;
    border-radius: 50%;
    animation: paySpin 0.8s linear infinite;
}

@keyframes paySpin {
    to { transform: rotate(360deg); }
}

.pay-cb-direct-btn {
    display: block;
    text-align: center;
    padding: 14px;
    background: linear-gradient(135deg, #0088cc, #229ed9);
    border-radius: 12px;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(0, 136, 204, 0.4);
}

.pay-back-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 12px;
    cursor: pointer;
    margin-top: 10px;
}

.pay-back-btn:hover {
    color: #fff;
}

/* ══ Density Extra Controls ══ */
.density-status-badge {
    font-size: 10px;
    font-weight: 500;
    color: var(--t2);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 4px;
}

.density-reset-btn {
    height: 26px;
    padding: 0 10px;
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.density-reset-btn:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: rgba(239, 68, 68, 0.5);
}

/* ══ Toast Container & Floating Alerts ══ */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 100000;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    max-width: 380px;
    pointer-events: none;
}

.toast-card {
    pointer-events: auto;
    background: rgba(18, 20, 26, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(139, 92, 246, 0.4);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 15px rgba(139, 92, 246, 0.2);
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--t1);
    font-size: 13px;
    animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    position: relative;
    overflow: hidden;
}

.toast-card.toast-success {
    border-color: rgba(38, 201, 122, 0.5);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 15px rgba(38, 201, 122, 0.2);
}

.toast-card.toast-error {
    border-color: rgba(239, 68, 68, 0.5);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 15px rgba(239, 68, 68, 0.2);
}

.toast-card.toast-info {
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 15px rgba(59, 130, 246, 0.2);
}

.toast-card.toast-price_alert {
    border-color: rgba(139, 92, 246, 0.5);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 15px rgba(139, 92, 246, 0.2);
}

.toast-card.clickable {
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.toast-card.clickable:hover {
    transform: translateY(-2px);
    border-color: rgba(167, 139, 250, 0.9) !important;
    box-shadow: 0 14px 35px rgba(0, 0, 0, 0.7), 0 0 22px rgba(139, 92, 246, 0.45) !important;
}

.toast-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    font-size: 13px;
    color: #fff;
}

.toast-header span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.toast-close {
    background: transparent;
    border: none;
    color: var(--t3);
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
    padding: 0 2px;
}
.toast-close:hover { color: #fff; }

.toast-body {
    font-size: 12px;
    color: var(--t2);
    line-height: 1.4;
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--ac);
    width: 100%;
    /* `transform` instead of `width`: animating width invalidates layout on every
       frame for the whole 8 s default toast lifetime. */
    transform-origin: left center;
    animation: toastProgress 5s linear forwards;
    will-change: transform;
}

.toast-card.toast-success .toast-progress {
    background: #26c97a;
}

.toast-card.toast-error .toast-progress {
    background: #ef4444;
}

.toast-card.toast-info .toast-progress {
    background: #3b82f6;
}

.toast-card.toast-price_alert .toast-progress {
    background: #8b5cf6;
}

.toast-card.toast-bug_reward {
    background: linear-gradient(135deg, #130a26 0%, #1e113a 100%) !important;
    border: 1px solid rgba(168, 85, 247, 0.6) !important;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.85), 0 0 25px rgba(168, 85, 247, 0.4) !important;
}
.toast-card.toast-bug_reward .toast-header .toast-title {
    color: #e9d5ff !important;
    font-size: 13.5px !important;
    font-weight: 800 !important;
}
.toast-card.toast-bug_reward .toast-body {
    color: #cbd5e1 !important;
    font-size: 12px !important;
    line-height: 1.45 !important;
}
.toast-card.toast-bug_reward .toast-progress {
    background: linear-gradient(90deg, #a855f7 0%, #ec4899 100%) !important;
}

.toast-card.toast-bug_reject {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%) !important;
    border: 1px solid rgba(99, 102, 241, 0.5) !important;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.85), 0 0 20px rgba(99, 102, 241, 0.3) !important;
}
.toast-card.toast-bug_reject .toast-header .toast-title {
    color: #818cf8 !important;
    font-size: 13px !important;
    font-weight: 700 !important;
}
.toast-card.toast-bug_reject .toast-body {
    color: #94a3b8 !important;
    font-size: 11.5px !important;
    line-height: 1.4 !important;
}
.toast-card.toast-bug_reject .toast-progress {
    background: #6366f1 !important;
}

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastProgress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

/* ══ Price Alerts Settings List ══ */
.price-alert-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: var(--bg2);
    border: 1px solid var(--b1);
    border-radius: 6px;
    font-size: 12px;
}

.price-alert-item strong {
    color: #fff;
    font-weight: 600;
}

.price-alert-item .alert-del-btn {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: none;
    border-radius: 4px;
    padding: 2px 8px;
    cursor: pointer;
    font-size: 11px;
}
.price-alert-item .alert-del-btn:hover {
    background: rgba(239, 68, 68, 0.3);
}

/* ══ Profile Bug Report Card & Modal ══ */
.profile-bug-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.12) 0%, rgba(168, 85, 247, 0.12) 100%);
    border: 1px solid rgba(244, 63, 94, 0.35);
    border-radius: 10px;
    padding: 10px 14px;
    margin: 12px 0 16px 0;
    cursor: pointer;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out, transform 0.15s ease-in-out;
}
.profile-bug-card:hover {
    border-color: rgba(244, 63, 94, 0.6);
    box-shadow: 0 4px 16px rgba(244, 63, 94, 0.2);
    transform: translateY(-1px);
}
.bug-card-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.bug-card-icon-box {
    font-size: 20px;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(244, 63, 94, 0.18);
    border: 1px solid rgba(244, 63, 94, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.bug-card-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.bug-card-text strong {
    font-size: 13px;
    font-weight: 700;
    color: #fff;
}
.bug-card-text span {
    font-size: 11px;
    color: #f472b6;
    font-weight: 500;
}
.bug-card-action-btn {
    background: linear-gradient(135deg, #e11d48 0%, #be185d 100%);
    color: #ffffff;
    font-weight: 600;
    font-size: 11.5px;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: box-shadow 0.15s;
}
.bug-card-action-btn:hover {
    box-shadow: 0 0 12px rgba(225, 29, 72, 0.5);
}

/* Bug Report Modal Box */
.bug-modal-box {
    max-width: 480px !important;
    width: 100% !important;
    padding: 24px !important;
    background: #0d0b18 !important;
    border: 1px solid rgba(244, 63, 94, 0.45) !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9), 0 0 30px rgba(244, 63, 94, 0.25) !important;
}

.bug-modal-header {
    text-align: center;
    margin-bottom: 16px;
}
.bug-modal-crown {
    font-size: 32px;
    margin-bottom: 4px;
}
.bug-modal-header h3 {
    font-size: 18px;
    font-weight: 800;
    color: #ffffff;
    margin: 0 0 4px 0;
}
.bug-modal-sub {
    font-size: 12px;
    color: #94a3b8;
    margin: 0;
}

.bug-modal-gift-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.15) 0%, rgba(244, 63, 94, 0.1) 100%);
    border: 1px solid rgba(234, 179, 8, 0.35);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 16px;
}
.bug-modal-gift-banner .gift-icon {
    font-size: 24px;
    flex-shrink: 0;
}
.bug-modal-gift-banner .gift-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 11.5px;
    color: #fef08a;
}
.bug-modal-gift-banner .gift-info strong {
    color: #ffffff;
    font-weight: 700;
}

.bug-form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}
.bug-form-field label {
    font-size: 12px;
    font-weight: 600;
    color: #cbd5e1;
}
.bug-form-field textarea {
    width: 100%;
    background: #161226;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 12.5px;
    color: #ffffff;
    font-family: inherit;
    resize: vertical;
    outline: none;
    transition: border-color 0.15s;
}
.bug-form-field textarea:focus {
    border-color: #a855f7;
    box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.2);
}

.bug-report-msg {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    margin-bottom: 14px;
}
.bug-report-msg.success {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.4);
    color: #4ade80;
}
.bug-report-msg.error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #f87171;
}

.bug-modal-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}
.bug-modal-cancel {
    background: rgba(255, 255, 255, 0.06);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}
.bug-modal-cancel:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}
.bug-modal-submit {
    background: linear-gradient(135deg, #8b5cf6 0%, #a855f7 100%);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 8px 18px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.4);
    transition: box-shadow 0.15s;
}
.bug-modal-submit:hover {
    box-shadow: 0 4px 20px rgba(168, 85, 247, 0.6);
}

/* Bug Report Screenshot Dropzone & Paste Preview */
.bug-screenshot-dropzone {
    width: 100%;
    background: #161226;
    border: 1.5px dashed rgba(168, 85, 247, 0.4);
    border-radius: 8px;
    padding: 10px;
    transition: background-color 0.15s ease-in-out, border-color 0.15s ease-in-out;
}
.bug-screenshot-dropzone:hover, .bug-screenshot-dropzone.dragover {
    border-color: #a855f7;
    background: rgba(168, 85, 247, 0.08);
}
.bug-dropzone-prompt {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 4px;
    text-align: center;
}
.bug-dropzone-prompt span {
    font-size: 11.5px;
    color: #cbd5e1;
}
.bug-dropzone-prompt span b {
    color: #c084fc;
}
.bug-screenshot-preview {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-height: 160px;
    border-radius: 6px;
    overflow: hidden;
    background: #000;
}
.bug-screenshot-preview img {
    max-width: 100%;
    max-height: 160px;
    object-fit: contain;
    border-radius: 6px;
}
.bug-remove-img-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.85);
    color: #ffffff;
    border: none;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    transition: background 0.15s;
}
.bug-remove-img-btn:hover {
    background: #ef4444;
}

/* ══ Density Blacklist UI ══ */
.density-blacklist-btn {
    height: 26px;
    padding: 0 10px;
    background: rgba(30, 41, 59, 0.7);
    color: #94a3b8;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.density-blacklist-btn:hover {
    background: rgba(51, 65, 85, 0.85);
    color: #f1f5f9;
    border-color: rgba(255, 255, 255, 0.2);
}
.density-blacklist-btn.has-items {
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.12);
}
.density-blacklist-count {
    background: rgba(255, 255, 255, 0.1);
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 700;
}
.density-blacklist-btn.has-items .density-blacklist-count {
    background: rgba(239, 68, 68, 0.3);
    color: #fee2e2;
}

/* ══ Density Blacklist Modal ══ */
.density-blacklist-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(5, 7, 12, 0.82);
    backdrop-filter: blur(8px);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
}
.density-blacklist-modal.open {
    display: flex;
}
.density-blacklist-content {
    background: #10141f;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    width: 90%;
    max-width: 620px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    animation: modalScaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.density-bl-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.density-bl-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: #f1f5f9;
    display: flex;
    align-items: center;
    gap: 8px;
}
.density-bl-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.15s, color 0.15s;
}
.density-bl-close:hover {
    color: #f87171;
    background: rgba(239, 68, 68, 0.1);
}
.density-bl-body {
    padding: 16px 18px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.density-bl-input-row {
    display: flex;
    gap: 8px;
}
.density-bl-input {
    flex: 1;
    height: 34px;
    background: #090c13;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    color: #f8fafc;
    font-size: 12px;
    font-weight: 600;
    padding: 0 12px;
    outline: none;
    text-transform: uppercase;
    transition: border-color 0.2s;
}
.density-bl-input:focus {
    border-color: #3b82f6;
}
.density-bl-add-btn {
    height: 34px;
    padding: 0 16px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.density-bl-add-btn:hover {
    background: #1d4ed8;
}
.density-bl-tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
    padding: 10px;
    background: #090c13;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
}
.density-bl-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #181d2a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
    letter-spacing: 0.3px;
    user-select: none;
    transition: background-color 0.15s, border-color 0.15s;
}
.density-bl-tag:hover {
    border-color: rgba(255, 255, 255, 0.22);
    background: #232a3d;
}
.density-bl-remove {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s;
}
.density-bl-remove:hover {
    color: #ef4444;
}
.density-bl-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: #0c0f17;
}
.density-bl-hint {
    font-size: 11px;
    color: #64748b;
}
.density-bl-actions {
    display: flex;
    gap: 8px;
}
.density-bl-btn-sec {
    height: 28px;
    padding: 0 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}
.density-bl-btn-sec:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #f1f5f9;
}

/* ═══ Formation Alert Settings Modal (Deep Matte Black & Muted Dark Violet) ═══ */
.formation-alerts-modal {
    width: 1080px;
    max-width: 95vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    background: #08090d;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.95);
    overflow: hidden;
    animation: modalScaleIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.fmt-modal-header {
    flex-shrink: 0;
    gap: 12px;
    padding: 14px 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #0c0d12;
}

.fmt-modal-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.22);
    color: #c4b5fd;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
}

.fmt-modal-title {
    font-size: 14px;
    font-weight: 600;
    color: #f1f5f9;
    letter-spacing: -0.1px;
}

.fmt-modal-subtitle {
    font-size: 11px;
    color: #64748b;
    margin-top: 2px;
}

.fmt-modal-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: #64748b;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 5px;
    transition: background-color 0.15s, color 0.15s;
}

.fmt-modal-close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
}

.fmt-modal-content {
    padding: 16px 20px;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
    background: #08090d;
}

.fmt-modal-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

@media (max-width: 860px) {
    .fmt-modal-grid {
        grid-template-columns: 1fr;
    }
    .formation-alerts-modal {
        width: 96vw;
    }
}

.fmt-grid-col {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.fmt-card {
    min-width: 0;
    background: #0f1016;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 14px 16px;
    transition: border-color 0.2s ease;
}

.fmt-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.fmt-card.active {
    border-color: rgba(139, 92, 246, 0.28);
    background: #11121a;
}

.fmt-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.fmt-card-title-group {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 9px;
}

.fmt-card-icon {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
}

.fmt-card-title {
    font-size: 12.5px;
    font-weight: 600;
    color: #e2e8f0;
}

.fmt-card-sub {
    font-size: 10.5px;
    color: #555e6d;
    margin-top: 1px;
}

.fmt-card-body {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.fmt-setting-row {
    display: grid;
    grid-template-columns: minmax(0, 0.7fr) minmax(0, 1.8fr);
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 28px;
}

.fmt-setting-label {
    font-size: 11.5px;
    color: #717a8a;
    font-weight: 500;
    line-height: 1.45;
    overflow-wrap: anywhere;
    min-width: 0;
    flex-wrap: wrap;
}

.fmt-setting-row > :last-child {
    min-width: 0;
    max-width: 100%;
    justify-self: end;
}

.fmt-card-header .switch { flex-shrink: 0; }
.fmt-card-title-group > div:last-child { min-width: 0; }
.fmt-modal-heading { display: flex; align-items: center; gap: 12px; min-width: 0; }
.fmt-modal-heading > div:last-child { min-width: 0; }

.fmt-btn-group {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: #08090e;
    padding: 2.5px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    flex-wrap: wrap;
    justify-content: flex-end;
}

.fmt-btn {
    flex: 0 0 auto;
    padding: 3.5px 8px;
    background: transparent;
    border: 1px solid transparent;
    color: #717a8a;
    border-radius: 3.5px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease, color 0.12s ease;
    user-select: none;
    white-space: nowrap;
}

.fmt-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.fmt-btn.active {
    background: #251d38;
    border-color: #5b3aa3;
    color: #ede9fe;
    font-weight: 600;
    box-shadow: none;
}

.fmt-input {
    width: 48px;
    padding: 2.5px 5px;
    background: #08090e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    outline: none;
    transition: border-color 0.15s;
}

.fmt-input:focus {
    border-color: #6d28d9;
}

.fmt-modal-footer {
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #0c0d12;
}

.fmt-footer-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.fmt-footer-primary { margin-left: auto; }
.fmt-footer-actions button { white-space: normal; }

@media (max-width: 560px) {
    .formation-alerts-modal { max-height: 94vh; max-height: 94dvh; }
    .fmt-modal-header, .fmt-modal-footer { padding: 12px; }
    .fmt-modal-content { padding: 12px; }
    .fmt-card { padding: 12px; }
    .fmt-setting-row { grid-template-columns: minmax(0, 1fr); gap: 5px; }
    .fmt-setting-row > :last-child { justify-self: start; }
    .fmt-setting-row:has(> .switch) { grid-template-columns: minmax(0, 1fr) auto; }
    .fmt-btn-group { justify-content: flex-start; }
}

.formations-alert-btn {
    background: rgba(139, 92, 246, 0.1) !important;
    border: 1px solid rgba(139, 92, 246, 0.25) !important;
    color: #c4b5fd !important;
}

.formations-alert-btn:hover {
    background: rgba(139, 92, 246, 0.2) !important;
    border-color: rgba(139, 92, 246, 0.5) !important;
    color: #fff !important;
}

/* ════════════════════════════════════════════════════════════
   PUMP / DUMP SCANNER MODERN SETTINGS STYLES
   ════════════════════════════════════════════════════════════ */

/* Master Hero Card in Settings */
.pd-settings-hero {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.14) 0%, rgba(34, 197, 94, 0.08) 100%);
    border: 1px solid rgba(124, 58, 237, 0.28);
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
}

.pd-hero-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pd-hero-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: rgba(124, 58, 237, 0.2);
    border: 1px solid rgba(124, 58, 237, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.pd-hero-title {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.01em;
}

.pd-hero-sub {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 2px;
}

.pd-hero-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pd-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.pd-status-pill.active {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.35);
    color: #86efac;
}

.pd-status-pill .pd-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #64748b;
}

.pd-status-pill.active .pd-dot {
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.8);
    animation: pdStatusPulse 2s ease-in-out infinite;
}

/* Card Container */
.pd-section-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 12px;
    transition: border-color 0.15s ease;
}

.pd-section-card:hover {
    border-color: rgba(255, 255, 255, 0.1);
}

.pd-section-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.pd-section-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #e2e8f0;
}

.pd-section-sub {
    font-size: 10px;
    color: #64748b;
    margin-left: 2px;
}

/* Exchange Grid */
.pd-exchange-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 5px;
}

.pd-pill-btn {
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    transition: background-color 0.15s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.15s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.15s cubic-bezier(0.4, 0, 0.2, 1), color 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.pd-pill-btn:hover {
    background: rgba(255, 255, 255, 0.07);
    color: #f1f5f9;
    border-color: rgba(255, 255, 255, 0.15);
}

.pd-pill-btn.active {
    background: rgba(124, 58, 237, 0.2);
    border-color: #7c3aed;
    color: #e9d5ff;
    box-shadow: 0 0 8px rgba(124, 58, 237, 0.25);
}

/* Direction Segmented Bar */
.pd-dir-bar {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
}

.pd-dir-btn {
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 7px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
    user-select: none;
}

.pd-dir-btn * {
    pointer-events: none;
}

.pd-dir-btn:hover {
    background: rgba(255, 255, 255, 0.07);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.16);
}

.pd-dir-btn.active {
    background: rgba(124, 58, 237, 0.2);
    border-color: #7c3aed;
    color: #e9d5ff;
    box-shadow: 0 0 10px rgba(124, 58, 237, 0.3);
}

.pd-dir-btn.active[data-val="both"] {
    background: rgba(124, 58, 237, 0.2);
    border-color: #7c3aed;
    color: #e9d5ff;
    box-shadow: 0 0 10px rgba(124, 58, 237, 0.3);
}

.pd-dir-btn.active[data-val="pump"] {
    background: rgba(34, 197, 94, 0.15);
    border-color: #22c55e;
    color: #86efac;
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.25);
}

.pd-dir-btn.active[data-val="dump"] {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
    color: #fca5a5;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.25);
}

.pd-dir-btn.active[data-val="futures"] {
    background: rgba(168, 85, 247, 0.2);
    border-color: #a855f7;
    color: #f3e8ff;
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.35);
}

.pd-dir-btn.active[data-val="spot"] {
    background: rgba(56, 189, 248, 0.18);
    border-color: #38bdf8;
    color: #e0f2fe;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

/* Value Selection Row: Presets + Custom Input */
.pd-value-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.pd-presets {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    flex: 1;
}

.pd-custom-input-box {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    padding: 0 8px;
    height: 30px;
    width: 100px;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.pd-custom-input-box:focus-within {
    border-color: #7c3aed;
    box-shadow: 0 0 8px rgba(124, 58, 237, 0.35);
    background: rgba(0, 0, 0, 0.6);
}

.pd-custom-input-box input {
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    width: 100%;
    font-family: inherit;
}

.pd-custom-input-box input::placeholder {
    color: #475569;
    font-weight: 400;
    font-size: 10px;
}

.pd-custom-input-box .pd-suffix {
    font-size: 10px;
    color: #64748b;
    font-weight: 600;
    margin-left: 2px;
    user-select: none;
}

/* Two Columns Subgrid */
.pd-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

@media (max-width: 540px) {
    .pd-two-col {
        grid-template-columns: 1fr;
    }
}

/* Notification Channel Item */
.pd-channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 8px;
}

.pd-channel-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.pd-channel-card:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.12);
}

.pd-channel-left {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #cbd5e1;
    font-weight: 500;
}

/* Action Bar */
.pd-action-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.pd-btn-primary {
    flex: 1;
    padding: 10px 16px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 700;
    background: linear-gradient(135deg, #166534 0%, #15803d 100%);
    color: #dcfce7;
    border: 1px solid #22c55e;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(34, 197, 94, 0.2);
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.pd-btn-primary:hover {
    background: linear-gradient(135deg, #15803d 0%, #16a34a 100%);
    box-shadow: 0 4px 14px rgba(34, 197, 94, 0.35);
    transform: translateY(-1px);
}

.pd-btn-secondary {
    padding: 10px 14px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.pd-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #f1f5f9;
    border-color: rgba(255, 255, 255, 0.2);
}

.pd-reset-link {
    font-size: 11px;
    color: #64748b;
    background: transparent;
    border: none;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.15s ease;
    padding: 0 4px;
}

.pd-reset-link:hover {
    color: #94a3b8;
}

@keyframes pdStatusPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ── Alert Badge ─────────────────────────────────────────── */
.pd-alert-badge {
    position: absolute; top: -2px; right: -2px;
    min-width: 16px; height: 16px;
    background: #ef4444; border-radius: 8px;
    font-size: 9px; font-weight: 700; color: #fff;
    display: flex; align-items: center; justify-content: center;
    padding: 0 3px; border: 1.5px solid #0d0f14;
    pointer-events: none;
    animation: pdBadgePop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pdBadgePop { from { transform: scale(0); } to { transform: scale(1); } }

/* ── Slide-out Alerts Panel ───────────────────────────────── */
.pd-alerts-panel {
    position: fixed; top: 0; right: -420px;
    width: 400px; height: 100vh;
    z-index: 9000;
    transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}
.pd-alerts-panel.open { right: 0; pointer-events: all; }
.pd-alerts-inner {
    position: absolute; top: 0; right: 0; bottom: 0; width: 100%;
    background: #0f111a;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    display: flex; flex-direction: column;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.6);
}
.pd-alerts-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}
.pd-alerts-title { font-size: 13px; font-weight: 700; color: #e2e8f0; letter-spacing: 0.02em; }
.pd-clear-btn {
    padding: 4px 10px; font-size: 11px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #6b7280; border-radius: 5px; cursor: pointer; transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.pd-clear-btn:hover { background: rgba(239,68,68,.1); border-color: rgba(239,68,68,.3); color: #f87171; }
.pd-close-btn {
    width: 26px; height: 26px; border-radius: 5px;
    background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08);
    color: #6b7280; font-size: 16px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: background-color 0.15s, color 0.15s;
}
.pd-close-btn:hover { background: rgba(239,68,68,.1); color: #f87171; }
.pd-alerts-list {
    flex: 1; overflow-y: auto; padding: 8px;
    display: flex; flex-direction: column; gap: 6px;
}
.pd-alerts-list::-webkit-scrollbar { width: 4px; }
.pd-alerts-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }
.pd-alert-card {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px; border-radius: 8px; cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease; border: 1px solid transparent;
    animation: pdCardSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pdCardSlideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.pd-alert-card.pd-pump { background: rgba(34,197,94,.06); border-color: rgba(34,197,94,.15); }
.pd-alert-card.pd-dump { background: rgba(239,68,68,.06); border-color: rgba(239,68,68,.15); }
.pd-alert-card.pd-pump:hover { background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.3); transform: translateX(-2px); }
.pd-alert-card.pd-dump:hover { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.3); transform: translateX(-2px); }
.pd-card-left { display: flex; align-items: center; gap: 10px; }
.pd-card-icon-badge {
    width: 32px; height: 32px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.pd-badge-pump {
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.25);
    color: #22c55e;
}
.pd-badge-dump {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #ef4444;
}
.pd-card-info { display: flex; flex-direction: column; gap: 2px; }
.pd-card-sym { font-size: 13px; font-weight: 700; color: #e2e8f0; display: flex; align-items: center; gap: 6px; }
.pd-card-ex { font-size: 10px; font-weight: 500; color: #6b7280; background: rgba(255,255,255,.05); padding: 1px 5px; border-radius: 3px; }
.pd-card-meta { font-size: 10px; color: #4b5563; }
.pd-card-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.pd-card-pct { font-size: 15px; font-weight: 800; letter-spacing: -0.02em; }
.pd-card-pct.pd-up { color: #22c55e; }
.pd-card-pct.pd-down { color: #ef4444; }
.pd-card-price { font-size: 10px; color: #6b7280; font-family: monospace; }
.pd-empty { padding: 32px 20px; text-align: center; color: #4b5563; font-size: 13px; line-height: 1.6; }

/* Complete appearance palettes. Preview colors come from the same catalogue. */
[data-appearance-theme] .settings-modal { width: 760px; height: 650px; background: var(--bg2); }
[data-appearance-theme] .settings-sidebar,
[data-appearance-theme] .settings-footer { background: var(--bg); }
[data-appearance-theme] .theme-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
[data-appearance-theme] .theme-opt { min-width: 0; padding: 0 0 8px; overflow: hidden; text-align: left; border-radius: 8px; background: var(--bg3); color: var(--t1); }
[data-appearance-theme] .theme-opt svg { display: block; width: 100%; height: 72px; border-bottom: 1px solid var(--bd); }
[data-appearance-theme] .theme-opt.active { outline: 2px solid var(--ac); outline-offset: 2px; background: var(--bg3); color: var(--t1); }
[data-appearance-theme] .theme-opt:focus-visible { outline: 3px solid var(--ac); outline-offset: 2px; }
.theme-name { display: block; padding: 7px 9px 2px; font-weight: 700; font-size: 11px; }
.theme-description { display: block; overflow: hidden; padding: 0 9px; font-size: 9px; line-height: 1.35; color: var(--t2); text-overflow: ellipsis; white-space: nowrap; }
[data-appearance-theme] :is(#bt-trade-panel, #bt-chart-head, .bt-indicators-menu, .bt-result, .color-dropdown, .bt-exchange-select) { background: var(--bg2); color: var(--t1); }
[data-appearance-theme] :is(.bt-field input, .bt-field textarea, #bt-draw-tools) { background: var(--bg3); color: var(--t1); }
[data-appearance-theme] .bt-loader { background: color-mix(in srgb, var(--bg) 85%, transparent); }
[data-appearance-theme] :is(.settings-tab.active, .settings-apply-btn, .bt-primary, .bt-reveal, .bt-tf.on, .bt-speeds button.on, .bt-chip.on, .bt-stage-row span.on, .bt-commit-plan, .bt-module-icon, .bt-level-input button, .nav-tab.active) { background: var(--ac); color: var(--on-accent); box-shadow: none; }
[data-appearance-theme] #bt-plan-state { color: var(--ac); background: var(--bg3); border-color: var(--bd); }
[data-appearance-theme] .settings-pane h2 { color: var(--t1); }
[data-appearance-theme] .ntab.on { color: var(--on-accent); }
[data-appearance-theme] .exc-menu { background: var(--bg2) !important; }
[data-appearance-theme] #bt-draw-tools .dt-btn.on { background: var(--ac); color: var(--on-accent); box-shadow: none; }
[data-appearance-theme] #bt-long { color: var(--t1); background: var(--bg3); border-color: var(--bd2); }
[data-appearance-theme] #bt-short { color: var(--rd); background: var(--bg3); border-color: var(--bd2); }
[data-appearance-theme] #bt-long.on, [data-appearance-theme] #bt-short.on { background: var(--bgh); border-color: var(--ac); }
@media (max-width: 600px) {
    [data-appearance-theme] .settings-content { padding: 16px; }
    [data-appearance-theme] .theme-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    [data-appearance-theme] .theme-opt svg { height: 78px; }
}




/* Theme-aware surfaces for workspaces that previously kept fixed dark colors. */
[data-appearance-theme] #density-view { background: var(--map-bg, var(--bg)); }
[data-appearance-theme] #density-canvas-wrap { background: var(--map-bg, var(--bg)); }
[data-appearance-theme] #density-toolbar,
[data-appearance-theme] .density-select { background: var(--map-panel, var(--bg2)); }
[data-appearance-theme] #density-view { color: var(--map-text, var(--t1)); }
[data-appearance-theme] :is(#density-toolbar, .density-select) { color: var(--map-text, var(--t1)); }
[data-appearance-theme] #density-view :is(.density-sub, .density-stat-label, .density-legend, .density-toolbar label) { color: var(--map-muted, var(--t2)); }
[data-appearance-theme] #density-view .density-count { background: color-mix(in srgb, var(--ac) 15%, transparent); color: var(--ac); }

[data-appearance-theme] #formations-view { background: var(--formations-bg, var(--bg)); }
[data-appearance-theme] #formations-grid { background: var(--formations-bg, var(--bg)); }
[data-appearance-theme] :is(#formations-toolbar, #formations-pagination, .formation-chart-card, .formation-mini-canvas) { background: var(--formations-panel, var(--bg2)); border-color: var(--bd); }
[data-appearance-theme] #formations-toolbar { background: color-mix(in srgb, var(--formations-panel, var(--bg2)) 88%, transparent); }
[data-appearance-theme] .formations-background-status { color: var(--formations-muted, var(--t2)); }
[data-appearance-theme] .formations-background-status strong { color: var(--gr); }
[data-appearance-theme] :is(.fc-overlay-info, .fc-overlay-footer) { background: color-mix(in srgb, var(--formations-panel, var(--bg2)) 88%, transparent); border-color: var(--bd); }
[data-appearance-theme] #formations-view .grid-cell { background: var(--formations-panel); border-color: var(--bd); }
[data-appearance-theme] #formations-view .cell-header { background: var(--formations-panel); border-color: var(--bd); }
[data-appearance-theme] #formations-view :is(.cell-sym, .cell-price) { color: var(--formations-text, var(--t1)); }
[data-appearance-theme] #formations-view .cell-tf { background: var(--bgh); color: var(--formations-muted, var(--t2)); }
[data-appearance-theme] #formations-view .cell-fs-btn:hover { background: var(--bgh); color: var(--formations-text, var(--t1)); }
[data-appearance-theme] #formations-view :is(.formations-count, .fc-badge) { background: color-mix(in srgb, var(--ac) 15%, transparent); border-color: color-mix(in srgb, var(--ac) 32%, transparent); color: var(--ac); }

[data-appearance-theme] #arbitrage-view { background: var(--arbitrage-bg); color: var(--arbitrage-text, var(--t1)); }
[data-appearance-theme] #arbitrage-view .arb-hero { background: radial-gradient(700px 180px at 8% 0, var(--acglow), transparent 70%), var(--arbitrage-panel); border-color: var(--bd); }
[data-appearance-theme] #arbitrage-view :is(.arb-kpis article, .arb-filters, .arb-results, .arb-filterbar, .arb-exchange-bar, .arb-table th) { background: var(--arbitrage-panel); border-color: var(--bd); }
[data-appearance-theme] #arbitrage-view :is(.arb-search, .arb-field-row input, .arb-field-row select, .arb-tools select, .arb-tools button, .arb-compact-field input, .arb-compact-field select, .arb-reset-btn, .arb-refresh-btn, .arb-exchange) { background: var(--arbitrage-bg); border-color: var(--bd); color: var(--arbitrage-text, var(--t1)); }
[data-appearance-theme] #arbitrage-view :is(.arb-modebar, .arb-table-top, .arb-exchange-bar, .arb-table th, .arb-table td, .arb-route-leg:first-child, .arb-table-foot) { border-color: var(--bd); }
[data-appearance-theme] #arbitrage-view :is(.arb-page-head h1, .arb-kpis strong, .arb-table-top strong, .arb-filter-head strong, .arb-pair strong, .arb-leg strong, .arb-route-leg strong, .arb-route-leg b) { color: var(--arbitrage-text, var(--t1)); }
[data-appearance-theme] #arbitrage-view :is(.arb-page-head p, .arb-feed-state span, .arb-feed-state strong, .arb-kpis span, .arb-kpis small, .arb-table-top span, .arb-table th, .arb-table td, .arb-muted, .arb-route-leg small, .arb-transfer-mini > span, .arb-table-foot) { color: var(--arbitrage-muted, var(--t2)); }
[data-appearance-theme] #arbitrage-view .arb-table tbody tr:nth-child(even) { background: color-mix(in srgb, var(--arbitrage-panel) 76%, var(--arbitrage-bg)); }
[data-appearance-theme] #arbitrage-view .arb-table tbody tr:hover { background: var(--bgh); }
[data-appearance-theme] #arbitrage-view .arb-modes button.on { color: var(--arbitrage-text, var(--t1)); border-color: var(--ac); }
[data-appearance-theme] #arbitrage-view :is(.arb-page-head h1 em, .arb-eyebrow, .arb-filter-head button, .arb-filter-label button, .arb-exchange-bar > button) { color: var(--ac); }
[data-appearance-theme] #arbitrage-view .arb-modes button.on b { background: color-mix(in srgb, var(--ac) 20%, transparent); color: var(--ac); }
[data-appearance-theme] #arbitrage-view .arb-check input:checked + i { background: var(--ac); }
[data-appearance-theme] #arbitrage-view .arb-coin { background: var(--bg3); color: var(--ac); }
[data-appearance-theme] #arbitrage-view .arb-score-ring { background: conic-gradient(var(--ac) calc(var(--score) * 1%), var(--bd) 0); }
[data-appearance-theme] #arbitrage-view .arb-score-ring::before { background: var(--arbitrage-panel); }
[data-appearance-theme] :is(.arb-drawer, .arb-detail-score, .arb-detail-chart, .arb-detail-leg) { background: var(--arbitrage-panel); border-color: var(--bd); color: var(--arbitrage-text, var(--t1)); }
[data-appearance-theme] .arb-drawer :is(h2, strong, .arb-breakdown b) { color: var(--arbitrage-text, var(--t1)); }
[data-appearance-theme] .arb-drawer :is(p, span, .arb-breakdown div) { color: var(--arbitrage-muted, var(--t2)); }
[data-appearance-theme] .arb-drawer :is(.arb-breakdown, .arb-drawer > header) { border-color: var(--bd); }
