/* ╔══════════════════════════════════════════════════════════╗ */
/* ║  APP.CSS — Scalpboard AI Dashboard Styles               ║ */
/* ╚══════════════════════════════════════════════════════════╝ */

:root {
    --bg-dark: #0B0B0F;
    --bg-panel: #111216;
    --card-bg: rgba(22, 23, 28, 0.8);
    --card-border: rgba(255, 255, 255, 0.08);
    --primary: #00E676;
    --primary-rgb: 0, 230, 118;
    --primary-deep: #00c853;
    --primary-soft: #69f0ae;
    --accent: #FF3366;
    --warn: #FFBD2E;
    --warn-rgb: 255, 189, 46;
    --text-main: #FFFFFF;
    --text-muted: #8E9BAE;
    --text-dim: #555B6A;
    --font-sans: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --sidebar-w: 320px;
    --panel-w: 360px;
    --topbar-h: 52px;
}

html[data-theme="light"] {
    --bg-dark: #ffffff;
    --bg-panel: #ffffff;
    --card-bg: #f8fafc;
    --card-border: rgba(15, 23, 42, 0.12);
    /* Яркий «премиум» акцент: изумруд + насыщенный rose, хорошо читается на белом */
    --primary: #10b981;
    --primary-rgb: 16, 185, 129;
    --primary-deep: #059669;
    --primary-soft: #34d399;
    /* Rose-500: ярче rose-600, всё ещё «премиум» к изумруду и янтарю */
    --accent: #f43f5e;
    /* Янтарь ярче чем amber-600, но без «лимонного» перегиба; читается на белом */
    --warn: #f59e0b;
    --warn-rgb: 245, 158, 11;
    --text-main: #0f172a;
    --text-muted: #475569;
    --text-dim: #64748b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}

body {
    background: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-sans);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: opacity 140ms ease;
}

html.app-boot-pending:not([data-postpay="1"]) body{
    opacity: 0 !important;
    pointer-events: none !important;
}

/* === POST-PAY VERIFICATION OVERLAY === */
.payment-check-overlay{
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 5000;
}
.payment-check-card{
    width: min(520px, 100%);
    background: rgba(16, 16, 24, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.10);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
    border-radius: 16px;
    padding: 18px 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: center;
}
.payment-check-title{
    font-weight: 800;
    letter-spacing: 0.01em;
}
.payment-check-subtitle{
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.25rem;
}
.payment-check-spinner{
    width: 40px;
    height: 40px;
    border-radius: 999px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: rgba(var(--primary-rgb), 0.95);
    margin: 0 auto 6px;
    animation: paymentSpin 0.9s linear infinite;
}
@keyframes paymentSpin{
    to { transform: rotate(360deg); }
}
html[data-theme="light"] .payment-check-overlay{
    background: rgba(15, 23, 42, 0.55);
}
html[data-theme="light"] .payment-check-card{
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(15, 23, 42, 0.10);
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.18);
}

/* When returning from payment, show overlay instantly (before JS) */
html[data-postpay="1"] #payment-check-overlay{
    display: flex !important;
}

/* === DEMO EXPIRED OVERLAY === */
.demo-expired-overlay{
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.62);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 5200;
}
.demo-expired-card{
    width: min(560px, 100%);
    background: rgba(16, 16, 24, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.10);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
    border-radius: 16px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: center;
}
.demo-expired-title{
    font-weight: 900;
    font-size: 1.05rem;
    letter-spacing: 0.01em;
}
.demo-expired-subtitle{
    color: var(--text-muted);
    line-height: 1.25rem;
}
.demo-expired-actions{
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 4px;
}
.demo-expired-buy{
    padding: 10px 16px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--primary-deep));
    color: #0B0B0F;
    text-decoration: none;
    font-weight: 800;
    letter-spacing: 0.02em;
    box-shadow: 0 0 18px rgba(var(--primary-rgb), 0.22);
}
.demo-expired-home{
    padding: 10px 16px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.10);
    color: rgba(255, 255, 255, 0.88);
    text-decoration: none;
    font-weight: 700;
}
html[data-theme="light"] .demo-expired-overlay{
    background: rgba(15, 23, 42, 0.55);
}
html[data-theme="light"] .demo-expired-card{
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(15, 23, 42, 0.10);
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.18);
}
html[data-theme="light"] .demo-expired-home{
    background: rgba(15, 23, 42, 0.04);
    border-color: rgba(15, 23, 42, 0.12);
    color: #0f172a;
}

/* === DEMO TIMER BANNER (app.html) === */
.demo-timer-banner {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 8px 16px;
    background: linear-gradient(90deg, rgba(var(--primary-rgb), 0.12), rgba(var(--primary-rgb), 0.04));
    border-bottom: 1px solid rgba(var(--primary-rgb), 0.22);
    font-size: 0.85rem;
    font-family: var(--font-mono);
    color: var(--text-main);
    position: relative;
    z-index: 1000;
}
.demo-timer-label { color: var(--text-muted); }
.demo-timer-value {
    font-weight: 700;
    color: var(--primary);
    min-width: 3ch;
}
.demo-timer-buy {
    margin-left: 8px;
    padding: 6px 18px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), var(--primary-deep));
    color: #0B0B0F;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 700;
    font-family: var(--font-sans);
    letter-spacing: 0.03em;
    border: none;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 0 12px rgba(var(--primary-rgb), 0.3);
    text-transform: uppercase;
}
.demo-timer-buy:hover {
    background: linear-gradient(135deg, var(--primary-soft), var(--primary));
    box-shadow: 0 0 20px rgba(var(--primary-rgb), 0.5);
    transform: translateY(-1px);
}

.topbar-logo {
    text-decoration: none;
    color: inherit;
}
a.topbar-logo:hover { opacity: 0.9; }

/* === TOP BAR === */
.topbar {
    flex: 0 0 var(--topbar-h);
    background: var(--bg-panel);
    border-bottom: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 16px;
    z-index: 500;
    position: relative;
}

.topbar-logo {
    font-size: 1.1rem;
    font-weight: 700;
    white-space: nowrap;
    margin-right: 8px;
    cursor: pointer;
}

.topbar-logo span {
    color: var(--primary);
}

.topbar-tabs {
    display: flex;
    gap: 0;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 999px;
    padding: 4px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.topbar-tabs::before {
    content: '';
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    width: calc((100% - 8px) / 2);
    box-sizing: border-box;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.10);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transform: translateX(0%);
    transition: transform 360ms cubic-bezier(0.2, 0.9, 0.2, 1);
    pointer-events: none;
}
.topbar-tabs.theme-light::before { transform: translateX(0%); }
.topbar-tabs.theme-dark::before { transform: translateX(100%); }

@media (max-width: 900px) {
    .topbar-tabs {
        justify-content: center;
        width: 100%;
    }
}

.topbar-tab {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    padding: 7px 12px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
    border: none;
    background: none;
    white-space: nowrap;
    position: relative;
    z-index: 1;
}

.topbar-tab.active {
    background: transparent;
    color: rgba(255, 255, 255, 0.92);
}

.topbar-tab:hover:not(.active) {
    color: rgba(255, 255, 255, 0.85);
}

html[data-theme="light"] .topbar-tab {
    color: var(--text-muted);
}
html[data-theme="light"] .topbar-tab.active {
    color: #0f172a;
}
html[data-theme="light"] .topbar-tab:hover:not(.active) {
    color: #334155;
}

/* Match landing light theme for theme toggle + icon buttons */
html[data-theme="light"] .topbar-tabs{
    background: rgba(15, 23, 42, 0.06);
    border-color: rgba(15, 23, 42, 0.10);
}
html[data-theme="light"] .topbar-tabs::before{
    background: #ffffff;
    border-color: rgba(15, 23, 42, 0.10);
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
}
html[data-theme="light"] .topbar-sound-btn,
html[data-theme="light"] .topbar-lang-btn,
html[data-theme="light"] .topbar-user-btn{
    background: #ffffff;
    border-color: var(--card-border);
    color: var(--text-muted);
}
html[data-theme="light"] .topbar-sound-btn:hover,
html[data-theme="light"] .topbar-lang-btn:hover,
html[data-theme="light"] .topbar-user-btn:hover,
html[data-theme="light"] .topbar-lang-wrap.dropdown-open .topbar-lang-btn{
    background: rgba(15, 23, 42, 0.07);
    border-color: rgba(15, 23, 42, 0.12);
    color: #0f172a;
}

.theme-tab-icon {
    display: block;
    width: 18px;
    height: 18px;
    margin: 0 auto;
    vertical-align: middle;
}

.topbar-search {
    flex: 0 1 220px;
    position: relative;
}

.topbar-search input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 6px 12px 6px 32px;
    color: var(--text-main);
    font-size: 0.8rem;
    font-family: var(--font-sans);
    outline: none;
    transition: border-color 0.2s;
}

.topbar-search input:focus {
    border-color: rgba(var(--primary-rgb), 0.4);
}

.topbar-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-dim);
    pointer-events: none;
}
.topbar-search:focus-within .topbar-search-icon {
    color: var(--primary);
}

.topbar-spacer {
    flex: 1;
}

.topbar-watchlist-btn {
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid rgba(var(--warn-rgb), 0.3);
    background: rgba(var(--warn-rgb), 0.08);
    color: var(--warn);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.topbar-watchlist-btn:hover {
    background: rgba(var(--warn-rgb), 0.15);
}

.topbar-demo-balance {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--card-border);
    white-space: nowrap;
}

.topbar-emulator-btn {
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid rgba(var(--primary-rgb), 0.3);
    background: rgba(var(--primary-rgb), 0.08);
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.topbar-emulator-btn:hover {
    background: rgba(var(--primary-rgb), 0.15);
}

.topbar-emulator-btn.active {
    background: rgba(var(--primary-rgb), 0.2);
    box-shadow: 0 0 10px rgba(var(--primary-rgb), 0.2);
}

.topbar-sound-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.topbar-sound-icon {
    width: 18px;
    height: 18px;
    display: none;
}
.topbar-sound-btn .topbar-sound-icon-off { display: block; }
.topbar-sound-btn.active .topbar-sound-icon-off { display: none; }
.topbar-sound-btn.active .topbar-sound-icon-on { display: block; }

.topbar-sound-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border-color: rgba(255, 255, 255, 0.12);
}

.topbar-sound-btn.active {
    /* Active should look like normal button, only icon changes */
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    border-color: var(--card-border);
    box-shadow: none;
}

/* No glow/color forcing on active: keep hierarchy (grey idle, white on hover) */

/* On hover, sound button should light up white like other icon buttons */
.topbar-sound-btn.active:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border-color: rgba(255, 255, 255, 0.12);
}

.topbar-user-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.topbar-user-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border-color: rgba(255, 255, 255, 0.12);
}

.topbar-user-icon {
    width: 18px;
    height: 18px;
}

/* Кнопка языка (планетка) в топбаре */
.topbar-lang-wrap {
    position: relative;
}
.topbar-lang-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.topbar-lang-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border-color: rgba(255, 255, 255, 0.12);
}
.topbar-lang-wrap.dropdown-open .topbar-lang-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border-color: rgba(255, 255, 255, 0.12);
}
.topbar-lang-icon {
    width: 18px;
    height: 18px;
}
.topbar-lang-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 6px;
    min-width: 160px;
    background: var(--bg-panel);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
    padding: 8px 0;
    display: none;
    z-index: 660;
}
.topbar-lang-wrap.dropdown-open .topbar-lang-dropdown {
    display: block;
    animation: userMenuIn 0.8s ease;
}
.topbar-lang-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    padding: 6px 12px 8px;
    border-bottom: 1px solid var(--card-border);
    margin-bottom: 4px;
}
.topbar-lang-option {
    display: block;
    width: 100%;
    padding: 8px 12px;
    font-size: 0.88rem;
    color: var(--text-main);
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    font-family: var(--font-sans);
    transition: background 0.2s;
}
.topbar-lang-option:hover {
    background: rgba(255, 255, 255, 0.06);
}
.topbar-lang-option.active {
    color: var(--primary);
}

/* User menu popup */
.user-menu-overlay {
    display: none;
    position: fixed;
    /* don't block topbar clicks (lang/menu/etc.) */
    inset: var(--topbar-h) 0 0 0;
    z-index: 650;
}

.user-menu-overlay.visible {
    display: block;
}

.user-menu-popup {
    position: fixed;
    top: calc(var(--topbar-h) + 8px);
    right: 16px;
    width: 280px;
    background: var(--bg-panel);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    z-index: 651;
    padding: 0;
    display: none;
    overflow: hidden;
}

.user-menu-popup.visible {
    display: block;
    animation: userMenuIn 0.8s ease;
}

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

.user-menu-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--card-border);
}

.user-menu-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
    max-width: 260px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-menu-subtitle{
    display:block;
    margin-top: 4px;
    font-size: 0.92rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: rgba(235, 240, 247, 0.86);
    max-width: 260px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-menu-paid,
.user-menu-unpaid {
    padding: 12px 0;
}

.user-menu-status {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 0 16px 12px;
    margin: 0;
}
.user-menu-status-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--primary);
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 0.88rem;
    color: var(--text-main);
    text-decoration: none;
    transition: background 0.2s;
}
.user-menu-item-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--text-muted);
}
.user-menu-item:hover .user-menu-item-icon {
    color: var(--text-main);
}
.user-menu-item-logout {
    color: var(--text-main);
}
.user-menu-item-logout .user-menu-icon-exit {
    color: var(--text-main);
}
.user-menu-item-logout:hover {
    color: var(--accent);
}
.user-menu-item-logout:hover .user-menu-icon-exit {
    color: var(--accent);
}
.user-menu-btn-buy {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: calc(100% - 32px);
    margin: 0 16px 12px;
    padding: 12px 16px;
    background: rgba(var(--primary-rgb), 0.2);
    border: 1px solid rgba(var(--primary-rgb), 0.4);
    border-radius: 10px;
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-sans);
}
.user-menu-btn-buy-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}
.user-menu-btn-buy-text {
    display: inline-block;
    line-height: 1;
}

.user-menu-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.user-menu-download {
    color: var(--primary);
}

.user-menu-btn-buy:hover {
    background: rgba(var(--primary-rgb), 0.3);
    box-shadow: 0 0 20px rgba(var(--primary-rgb), 0.2);
}

/* === MAIN LAYOUT === */
.main-layout {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr var(--panel-w);
    min-height: 0;
    transition: grid-template-columns 0.3s ease;
}

.main-layout.sidebar-collapsed {
    grid-template-columns: 0px 1fr var(--panel-w);
}

/* === SIDEBAR (coin list) === */
.sidebar {
    background: var(--bg-panel);
    border-right: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    transition: width 0.3s ease;
}

.sidebar.collapsed {
    border-right: none;
}

/* Sidebar toggle button (now inside chart-area) */
.sidebar-toggle {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    z-index: 50;
    width: 14px;
    height: 48px;
    border: none;
    border-radius: 0 6px 6px 0;
    background: var(--bg-panel);
    border: 1px solid var(--card-border);
    border-left: none;
    color: var(--text-muted);
    font-size: 0.6rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
}

.sidebar-header {
    padding: 10px 12px;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    gap: 6px;
}

.sort-btn {
    flex: 1;
    padding: 4px;
    border-radius: 6px;
    border: 1px solid var(--card-border);
    background: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-sans);
}

.sort-btn.active {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
    border-color: rgba(var(--primary-rgb), 0.2);
}

.coin-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.coin-list::-webkit-scrollbar {
    width: 4px;
}

.coin-list::-webkit-scrollbar-track {
    background: transparent;
}

.coin-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.coin-item {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    cursor: pointer;
    transition: background 0.15s;
}

.coin-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.coin-item.active {
    background: rgba(var(--primary-rgb), 0.08);
    border-left: 2px solid var(--primary);
}

.coin-star {
    font-size: 0.8rem;
    cursor: pointer;
    opacity: 0.3;
    transition: opacity 0.2s;
}

.coin-star.watched {
    opacity: 1;
    color: var(--warn);
}

.coin-star:hover {
    opacity: 0.8;
}

.coin-name {
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.coin-name small {
    font-weight: 400;
    color: var(--text-dim);
    margin-left: 4px;
}

.coin-price {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-align: right;
    color: var(--text-muted);
}

.coin-change {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    min-width: 52px;
    text-align: right;
    padding: 2px 4px;
    border-radius: 4px;
}

.coin-change.up {
    color: var(--primary);
    background: rgba(var(--primary-rgb), 0.08);
}

.coin-change.down {
    color: var(--accent);
    background: rgba(255, 51, 102, 0.08);
}

.sidebar-count {
    padding: 6px 12px;
    border-top: 1px solid var(--card-border);
    font-size: 0.7rem;
    color: var(--text-dim);
    text-align: center;
}

/* === CENTER (chart) === */
.chart-area {
    position: relative;
    overflow: hidden;
}

.chart-area iframe,
.chart-area .tradingview-widget-container {
    width: 100%;
    height: 100%;
}

.chart-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    z-index: 5;
    transition: opacity 0.3s;
}

.chart-loading.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Multi-TF toggle button */
.mtf-toggle {
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    flex-shrink: 0;
}

.mtf-toggle:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-main);
}

.mtf-toggle.active {
    background: rgba(var(--primary-rgb), 0.12);
    border-color: rgba(var(--primary-rgb), 0.3);
    color: var(--primary);
}

/* Multi-TF 2x2 grid */
.mtf-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 2px;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.04);
}

.mtf-panel {
    position: relative;
    overflow: hidden;
    background: var(--bg-dark);
}

.mtf-label {
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    padding: 2px 10px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(var(--primary-rgb), 0.25);
    color: var(--primary);
    font-size: 0.72rem;
    font-weight: 700;
    font-family: var(--font-mono);
    letter-spacing: 1px;
    pointer-events: none;
}

/* === EMULATOR PANEL === */
.emulator-panel {
    position: absolute;
    top: 60px;
    left: 20px;
    width: 300px;
    max-height: calc(100vh - var(--topbar-h) - 80px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    background: rgba(22, 23, 28, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    z-index: 600;
    display: none;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    transition: opacity 0.2s, transform 0.2s;
}

.emulator-panel::-webkit-scrollbar {
    width: 4px;
}

.emulator-panel::-webkit-scrollbar-track {
    background: transparent;
}

.emulator-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 4px;
}

.emulator-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.emulator-panel.visible {
    display: flex;
    animation: slideInDown 0.3s ease-out forwards;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.emu-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px 12px 0 0;
}

.emu-header h4 {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
}

.emu-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.2s;
}

.emu-close:hover {
    color: var(--text-main);
}

.emu-coin-info {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
}

.emu-coin {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: 700;
}

.emu-price {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-muted);
}

.emu-controls {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.emu-input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.emu-label-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.emu-label-row span {
    font-family: var(--font-mono);
    color: var(--primary);
    font-weight: 600;
}

.emu-input-group input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
}

.emu-input-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 0 5px rgba(var(--primary-rgb), 0.5);
}

.emu-input-group input[type="number"] {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    padding: 10px;
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.emu-input-group input[type="number"]:focus {
    border-color: rgba(var(--primary-rgb), 0.4);
}

.emu-summary {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.emu-summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-dim);
}

.emu-summary-row span:last-child {
    font-family: var(--font-mono);
    color: var(--text-muted);
}

.emu-actions {
    padding: 0 16px 16px 16px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.emu-btn {
    padding: 12px;
    border-radius: 8px;
    border: none;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: filter 0.2s, transform 0.1s;
    font-family: var(--font-sans);
}

.emu-btn:active {
    transform: scale(0.97);
}

.emu-btn:hover {
    filter: brightness(1.15);
}

.btn-long {
    background: rgba(var(--primary-rgb), 0.15);
    color: var(--primary);
    border: 1px solid rgba(var(--primary-rgb), 0.3);
}

.btn-short {
    background: rgba(255, 51, 102, 0.15);
    color: var(--accent);
    border: 1px solid rgba(255, 51, 102, 0.3);
}

.emu-footer {
    padding: 12px;
    border-top: 1px solid var(--card-border);
    text-align: center;
}

.emu-history-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: color 0.2s;
}

.emu-history-btn-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--text-dim);
    transition: color 0.2s;
}

.emu-history-btn:hover {
    color: var(--text-main);
    text-decoration: underline;
}

.emu-history-btn:hover .emu-history-btn-icon {
    color: var(--text-main);
}

/* === TP/SL SECTION === */
.emu-tpsl-section {
    border-top: 1px solid var(--card-border);
    margin-top: 4px;
}

.emu-tpsl-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    cursor: pointer;
    user-select: none;
}

.emu-tpsl-toggle-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
}

.emu-tpsl-toggle-label svg {
    color: var(--warn);
}

/* Toggle switch */
.emu-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}

.emu-switch input { opacity: 0; width: 0; height: 0; }

.emu-switch-slider {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.3s;
}

.emu-switch-slider::before {
    content: "";
    position: absolute;
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: transform 0.3s, background 0.3s;
}

.emu-switch input:checked + .emu-switch-slider {
    background: rgba(var(--primary-rgb), 0.3);
}

.emu-switch input:checked + .emu-switch-slider::before {
    transform: translateX(16px);
    background: var(--primary);
    box-shadow: 0 0 6px rgba(var(--primary-rgb), 0.5);
}

/* TP/SL fields */
.emu-tpsl-fields {
    padding-bottom: 4px;
    animation: tpslExpand 0.25s ease-out;
}

@keyframes tpslExpand {
    from { opacity: 0; max-height: 0; }
    to { opacity: 1; max-height: 300px; }
}

.emu-tpsl-row {
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.emu-tpsl-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.tpsl-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.tp-dot { background: var(--primary); box-shadow: 0 0 4px rgba(var(--primary-rgb), 0.5); }
.sl-dot { background: var(--accent); box-shadow: 0 0 4px rgba(255, 51, 102, 0.5); }

.emu-tpsl-input-wrap {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.emu-tpsl-input-wrap:focus-within {
    border-color: rgba(var(--primary-rgb), 0.4);
}

.emu-tpsl-row.sl .emu-tpsl-input-wrap:focus-within {
    border-color: rgba(255, 51, 102, 0.4);
}

.emu-tpsl-input-wrap input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 8px 10px;
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    outline: none;
    min-width: 0;
}

.emu-tpsl-input-wrap input::placeholder {
    color: rgba(255, 255, 255, 0.2);
    font-size: 0.75rem;
}

.emu-tpsl-unit {
    padding: 8px 10px;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-dim);
    background: rgba(255, 255, 255, 0.03);
    border-left: 1px solid var(--card-border);
    font-family: var(--font-mono);
    white-space: nowrap;
}

.emu-tpsl-pnl {
    font-size: 0.68rem;
    font-family: var(--font-mono);
    color: var(--text-dim);
    margin-top: 4px;
    padding-left: 12px;
}

.emu-tpsl-pnl.positive { color: var(--primary); }
.emu-tpsl-pnl.negative { color: var(--accent); }

.emu-tpsl-hint {
    font-size: 0.65rem;
    color: var(--text-dim);
    padding: 6px 0 2px;
    opacity: 0.7;
    line-height: 1.4;
}

/* === RIGHT PANEL (AI Overlay) === */
.ai-panel {
    background: var(--bg-panel);
    border-left: 1px solid var(--card-border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.ai-panel::-webkit-scrollbar {
    width: 4px;
}

.ai-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.ai-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-header-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-header h3 {
    font-size: 0.9rem;
    font-weight: 700;
    margin: 0;
}

.ai-header .pulsing-dot {
    width: 8px;
    height: 8px;
    flex-shrink: 0;
    background: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--primary);
    animation: pulse-dot 2s infinite;
}

.ai-panel-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background 0.2s;
}

.ai-panel-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.ai-panel-close.mobile-only {
    display: none;
}

.ai-symbol-bar {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--card-border);
}

.ai-symbol {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 700;
}

.ai-price-display {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.08);
    padding: 3px 8px;
    border-radius: 6px;
}

.ai-direction {
    padding: 16px;
    text-align: center;
    border-bottom: 1px solid var(--card-border);
}

.ai-direction-label {
    font-size: 1.6rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 6px;
}

.ai-direction.up .ai-direction-label {
    color: var(--primary);
    text-shadow: 0 0 8px var(--primary), 0 0 20px rgba(var(--primary-rgb), 0.3);
}

.ai-direction.down .ai-direction-label {
    color: var(--accent);
    text-shadow: 0 0 8px var(--accent), 0 0 20px rgba(255, 82, 82, 0.3);
}

.ai-direction.sideways .ai-direction-label {
    color: var(--warn);
    text-shadow: 0 0 8px var(--warn), 0 0 20px rgba(var(--warn-rgb), 0.35);
}

/* Neon glow SVG icons for direction */
.dir-icon {
    vertical-align: middle;
    margin-right: 4px;
    animation: neonPulse 2s ease-in-out infinite;
}

.neon-up {
    filter: drop-shadow(0 0 4px var(--primary)) drop-shadow(0 0 10px rgba(var(--primary-rgb), 0.5));
}

.neon-down {
    filter: drop-shadow(0 0 4px var(--accent)) drop-shadow(0 0 10px rgba(255, 82, 82, 0.5));
}

.neon-side {
    filter: drop-shadow(0 0 4px var(--warn)) drop-shadow(0 0 10px rgba(var(--warn-rgb), 0.55));
}

@keyframes neonPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Early Warning (Pre-reversal) */
.early-warning {
    margin: 12px 16px 0;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(var(--warn-rgb), 0.1);
    border: 1px solid rgba(var(--warn-rgb), 0.28);
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--text-main);
    animation: fadeIn 0.3s ease;
}

.early-warning.ew-up {
    background: rgba(var(--primary-rgb), 0.1);
    border-color: rgba(var(--primary-rgb), 0.3);
}

.early-warning.ew-down {
    background: rgba(255, 82, 82, 0.1);
    border-color: rgba(255, 82, 82, 0.3);
}

.early-warning-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.early-warning-header strong {
    color: var(--warn);
}

.early-warning.ew-up .early-warning-header strong {
    color: var(--primary);
}

.early-warning.ew-down .early-warning-header strong {
    color: var(--accent);
}

.early-warning-score {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.8rem;
    background: rgba(0,0,0,0.2);
    padding: 2px 6px;
    border-radius: 4px;
}

#early-warning-reasons {
    color: var(--text-dim);
    font-size: 0.7rem;
}

/* Forecast section inline SVG icons */
.fc-icon {
    vertical-align: middle;
    margin-right: 6px;
    flex-shrink: 0;
}

.ai-confidence {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.ai-confidence strong {
    color: var(--text-main);
}

/* Watch button */
.ai-watch-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 12px 16px;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-sans);
}

.ai-watch-btn:hover {
    background: rgba(var(--warn-rgb), 0.1);
    color: var(--warn);
    border-color: rgba(var(--warn-rgb), 0.3);
}

.ai-watch-btn.watched {
    background: rgba(var(--warn-rgb), 0.08);
    color: var(--warn);
    border-color: rgba(var(--warn-rgb), 0.3);
}

.ai-watch-btn.watched:hover {
    background: rgba(var(--warn-rgb), 0.15);
    color: var(--warn);
    border-color: rgba(var(--warn-rgb), 0.35);
}

/* Horizons */
.ai-horizons {
    padding: 12px 16px;
    border-bottom: 1px solid var(--card-border);
}

.ai-horizons-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.horizon-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
}

.horizon-item {
    text-align: center;
    padding: 8px 4px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    transition: all 0.3s;
}

.horizon-item .hz-label {
    font-size: 0.65rem;
    color: var(--text-dim);
    margin-bottom: 4px;
}

.horizon-item .hz-arrow {
    font-size: 1.1rem;
}

.horizon-item .hz-str {
    font-size: 0.6rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    margin-top: 2px;
}

.horizon-item.up {
    border-color: rgba(var(--primary-rgb), 0.2);
    background: rgba(var(--primary-rgb), 0.05);
}

.horizon-item.up .hz-arrow {
    color: var(--primary);
}

.horizon-item.down {
    border-color: rgba(255, 51, 102, 0.2);
    background: rgba(255, 51, 102, 0.05);
}

.horizon-item.down .hz-arrow {
    color: var(--accent);
}

.horizon-item.sideways .hz-arrow {
    color: var(--warn);
}

/* Long-term forecast (4ч, 1д, 1нед) */
.ai-longterm {
    padding: 12px 16px;
    margin: 14px 12px 0 16px;
    border-bottom: 1px solid var(--card-border);
    background: linear-gradient(180deg, rgba(var(--primary-rgb), 0.03) 0%, transparent 100%);
    border-radius: 8px;
}

.ai-longterm-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.longterm-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.longterm-item {
    text-align: center;
    padding: 10px 6px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    transition: all 0.25s ease;
}

.longterm-item:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateY(-1px);
}

.longterm-item .lt-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-family: var(--font-mono);
    letter-spacing: 0.5px;
}

.longterm-item .lt-arrow {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 2px 0;
}

.longterm-item .lt-str {
    font-size: 0.68rem;
    font-family: var(--font-mono);
    color: var(--text-dim);
}

.longterm-item .lt-rsi {
    font-size: 0.6rem;
    color: var(--text-dim);
    margin-top: 2px;
}

.longterm-item.up {
    border-color: rgba(var(--primary-rgb), 0.25);
    background: rgba(var(--primary-rgb), 0.06);
    box-shadow: 0 0 12px rgba(var(--primary-rgb), 0.08);
}

.longterm-item.up .lt-arrow {
    color: var(--primary);
    text-shadow: 0 0 6px rgba(var(--primary-rgb), 0.4);
}

.longterm-item.down {
    border-color: rgba(255, 51, 102, 0.25);
    background: rgba(255, 51, 102, 0.06);
    box-shadow: 0 0 12px rgba(255, 51, 102, 0.08);
}

.longterm-item.down .lt-arrow {
    color: var(--accent);
    text-shadow: 0 0 6px rgba(255, 51, 102, 0.4);
}

.longterm-item.sideways .lt-arrow {
    color: var(--warn);
}

/* Indicators */
.ai-indicators {
    padding: 12px 16px;
    border-bottom: 1px solid var(--card-border);
}

.ai-indicators-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.indicator-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
}

.indicator-chip {
    text-align: center;
    padding: 5px 4px;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 600;
    font-family: var(--font-mono);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--card-border);
}

.indicator-chip.bull {
    color: var(--primary);
    border-color: rgba(var(--primary-rgb), 0.2);
    background: rgba(var(--primary-rgb), 0.06);
}

.indicator-chip.bear {
    color: var(--accent);
    border-color: rgba(255, 51, 102, 0.2);
    background: rgba(255, 51, 102, 0.06);
}

.indicator-chip.flat {
    color: var(--warn);
    border-color: rgba(var(--warn-rgb), 0.22);
}

/* Reasoning */
.ai-reasoning {
    flex: 1;
    padding: 12px 16px;
}

.ai-reasoning-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.reasoning-item {
    font-size: 0.76rem;
    color: var(--text-muted);
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    line-height: 1.4;
}

/* Detailed AI Forecast */
.ai-forecast {
    padding: 14px 16px;
    border-top: 1px solid var(--card-border);
}

.forecast-question {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.forecast-section {
    margin-bottom: 10px;
}

.forecast-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.forecast-section-title.short-term {
    color: #60a5fa;
}

.forecast-section-title.bull {
    color: var(--primary);
}

.forecast-section-title.bear {
    color: var(--accent);
}

.forecast-section-title.realistic {
    color: var(--warn);
}

.forecast-section-title.recs {
    color: #a78bfa;
}

.forecast-section-title.advice {
    color: #94a3b8;
}

.forecast-text {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.55;
    margin-bottom: 6px;
}

.forecast-text strong {
    color: var(--text-main);
    font-weight: 600;
}

.forecast-text .price-tag {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    background: rgba(255, 255, 255, 0.06);
    padding: 1px 5px;
    border-radius: 4px;
    color: var(--text-main);
}

.forecast-rec-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    margin-top: 6px;
}

/* === HISTORY & POSITIONS MODAL === */
.history-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.history-modal-overlay.visible {
    display: flex;
    animation: fadeIn 0.2s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.history-modal {
    width: 900px;
    max-width: 95vw;
    height: 600px;
    max-height: 90vh;
    background: var(--bg-panel);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    overflow: hidden;
    transform: scale(0.98);
    transition: transform 0.2s;
}

.history-modal-overlay.visible .history-modal {
    transform: scale(1);
}

.hm-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
}

.hm-header h3 {
    font-size: 1.1rem;
    color: var(--text-main);
}

.hm-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
}

.hm-close:hover {
    color: var(--text-main);
}

.hm-tabs {
    display: flex;
    border-bottom: 1px solid var(--card-border);
    padding: 0 20px;
    gap: 20px;
    align-items: center;
}

.hm-tab {
    padding: 16px 0;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    position: relative;
}

.hm-tab:hover {
    color: var(--text-main);
}

.hm-tab.active {
    color: var(--primary);
}

.hm-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
}

.hm-balance-info {
    margin-left: auto;
    font-size: 0.9rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 10px;
}

.hm-balance-info strong {
    font-family: var(--font-mono);
    color: var(--text-main);
    font-size: 1rem;
}

.hm-reset-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    color: var(--text-muted);
    border-radius: 4px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.hm-reset-btn:hover {
    background: rgba(255, 51, 102, 0.1);
    color: var(--accent);
    border-color: rgba(255, 51, 102, 0.3);
}

.hm-content {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.hm-table-container {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    padding: 0;
}

.hm-table-container::-webkit-scrollbar {
    width: 6px;
}

.hm-table-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.hm-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.hm-table th {
    position: sticky;
    top: 0;
    background: #15161A;
    padding: 12px 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    z-index: 10;
    border-bottom: 1px solid var(--card-border);
}

.hm-table td {
    padding: 14px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 0.85rem;
    color: var(--text-main);
    font-family: var(--font-mono);
}

.hm-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.hm-pill {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
}

.hm-pill.long {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
}

.hm-pill.short {
    background: rgba(255, 51, 102, 0.1);
    color: var(--accent);
}

.hm-pnl.positive {
    color: var(--primary);
}

.hm-pnl.negative {
    color: var(--accent);
}

.hm-close-btn {
    background: rgba(255, 51, 102, 0.1);
    border: 1px solid rgba(255, 51, 102, 0.3);
    color: var(--accent);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-sans);
}

.hm-close-btn:hover {
    background: rgba(255, 51, 102, 0.2);
}

.hm-empty {
    text-align: center;
    padding: 40px;
    color: var(--text-dim);
    font-size: 0.9rem;
}

.forecast-rec {
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.7rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.forecast-rec.long-rec {
    background: rgba(var(--primary-rgb), 0.06);
    border: 1px solid rgba(var(--primary-rgb), 0.15);
}

.forecast-rec.short-rec {
    background: rgba(255, 51, 102, 0.06);
    border: 1px solid rgba(255, 51, 102, 0.15);
}

.forecast-rec .rec-label {
    font-weight: 700;
    font-size: 0.72rem;
    display: block;
    margin-bottom: 3px;
}

.forecast-rec.long-rec .rec-label {
    color: var(--primary);
}

.forecast-rec.short-rec .rec-label {
    color: var(--accent);
}

.forecast-rec .rec-detail {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    color: var(--text-dim);
}

.forecast-advice {
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(148, 163, 184, 0.06);
    border: 1px solid rgba(148, 163, 184, 0.12);
    font-size: 0.7rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.forecast-timestamp {
    font-size: 0.62rem;
    color: var(--text-dim);
    font-family: var(--font-mono);
    margin-top: 10px;
    text-align: right;
}

/* Reversal warning */
.reversal-warning {
    margin: 0 16px 8px;
    padding: 8px 10px;
    background: rgba(var(--warn-rgb), 0.08);
    border: 1px solid rgba(var(--warn-rgb), 0.22);
    border-radius: 8px;
    font-size: 0.75rem;
    color: var(--warn);
}

.reversal-warning strong {
    display: block;
    margin-bottom: 4px;
}

/* Volatility warning (BB squeeze — electric movement expected) */
.volatility-warning {
    margin: 0 16px 8px;
    padding: 8px 10px;
    background: rgba(96, 165, 250, 0.08);
    border: 1px solid rgba(96, 165, 250, 0.2);
    border-radius: 8px;
    font-size: 0.75rem;
    color: #60a5fa;
}

.volatility-warning strong {
    display: block;
    margin-bottom: 4px;
}

/* AI Loading */
.ai-loading {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    font-size: 0.85rem;
}

/* === WATCHLIST PANEL (bottom overlay) === */
.watchlist-panel {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-w);
    right: var(--panel-w);
    background: var(--bg-panel);
    border-top: 1px solid rgba(var(--warn-rgb), 0.22);
    z-index: 50;
    max-height: 180px;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.3s ease, left 0.3s ease;
}

body.sidebar-collapsed .watchlist-panel {
    left: 0;
}

.watchlist-panel.visible {
    transform: translateY(0);
}

.watchlist-header {
    padding: 8px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--card-border);
    position: sticky;
    top: 0;
    background: var(--bg-panel);
}

.watchlist-header h4 {
    font-size: 0.8rem;
    color: var(--warn);
}

.watchlist-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
}

.watchlist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 4px;
    padding: 8px;
}

.watchlist-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.75rem;
}

.watchlist-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.wl-symbol {
    font-weight: 600;
    font-family: var(--font-mono);
}

.wl-dir {
    font-weight: 700;
}

.wl-dir.up {
    color: var(--primary);
}

.wl-dir.down {
    color: var(--accent);
}

.wl-dir.sideways {
    color: var(--warn);
}

/* === ANIMATIONS === */
@keyframes pulse-dot {
    0% {
        transform: scale(0.95);
        opacity: 0.5;
        box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0.7);
    }

    70% {
        transform: scale(1);
        opacity: 1;
        box-shadow: 0 0 0 6px rgba(var(--primary-rgb), 0);
    }

    100% {
        transform: scale(0.95);
        opacity: 0.5;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* === RESPONSIVE === */
@media (max-width: 1100px) {
    :root {
        --panel-w: 300px;
        --sidebar-w: 280px;
    }
}

@media (max-width: 900px) {
    /* Верхний блок: 3 ряда (лого+тема, поиск, Эмулятор/звук/баланс). Высота под контент. */
    :root {
        --topbar-h: 128px;
    }
    /* Первый ряд: Watchboard.io слева, переключатель темы справа */
    .topbar {
        height: auto;
        min-height: var(--topbar-h);
        flex-wrap: wrap;
        gap: 8px;
        padding-bottom: 12px;
        align-content: flex-start;
    }
    .topbar .topbar-logo { order: 1; }
    .topbar .topbar-spacer { order: 2; flex: 1; min-width: 12px; }
    .topbar .topbar-tabs {
        order: 3;
        flex: 0 0 auto;
        width: auto;
        margin: 0;
        margin-top: 0;
        padding-top: 0;
        border-top: none;
    }
    .topbar .topbar-search {
        order: 4;
        flex: 1 1 100%;
        width: 100%;
        max-width: 100%;
    }
    .topbar .mtf-toggle { order: 5; }
    .topbar .topbar-watchlist-btn { order: 6; }
    .topbar .topbar-emulator-btn { order: 7; }
    .topbar .topbar-demo-balance { order: 8; }
    .topbar .topbar-sound-btn { order: 9; }
    .topbar .topbar-user-btn { order: 10; }

    /* Основной контент: сверху график, снизу окно анализа (колонка) */
    .main-layout {
        display: flex;
        flex-direction: column;
        grid-template-columns: unset;
        height: calc(100vh - var(--topbar-h));
        position: relative;
        z-index: 1;
    }
    .main-layout.sidebar-collapsed {
        grid-template-columns: unset;
    }

    /* Слева выезжающая панель монет (оверлей) */
    .sidebar {
        position: fixed;
        left: 0;
        top: var(--topbar-h);
        bottom: 0;
        width: min(320px, 85vw);
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    }
    .sidebar:not(.collapsed) {
        transform: translateX(0);
    }
    .sidebar.collapsed {
        pointer-events: none;
    }

    /* График всегда под рядом с Эмулятор/звук/баланс, с отступом */
    .chart-area {
        flex: 0 0 42%;
        min-height: 220px;
        max-height: 50vh;
        margin-top: 6px;
        position: relative;
        z-index: 2;
    }

    /* Окно анализа всегда снизу, скролл внутри */
    .ai-panel {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        border-left: none;
        border-top: 1px solid var(--card-border);
        position: relative;
        transform: none;
        width: 100%;
        box-shadow: none;
    }
    .ai-panel.mobile-open {
        transform: none;
    }

    /* На мобиле показываем крестик закрытия AI-панели */
    .ai-panel .ai-panel-close.mobile-only {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }

    .watchlist-panel {
        left: 0;
        right: 0;
    }
}

/* === MOBILE / CAPACITOR APP === */
body.capacitor-app {
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
    min-height: 100vh;
    min-height: 100dvh;
}

.capacitor-app .topbar {
    padding-left: calc(16px + env(safe-area-inset-left));
    padding-right: calc(16px + env(safe-area-inset-right));
    min-height: 48px;
    flex-wrap: wrap;
    gap: 8px;
}

.capacitor-app .main-layout {
    height: calc(100vh - var(--topbar-h) - env(safe-area-inset-top));
    height: calc(100dvh - var(--topbar-h) - env(safe-area-inset-top));
}

@media (max-width: 900px) {
    body.capacitor-app {
        display: flex;
        flex-direction: column;
    }
    .capacitor-app .topbar {
        flex-shrink: 0;
    }
    .capacitor-app .main-layout {
        flex: 1;
        min-height: 0;
        height: auto;
    }
}

@media (max-width: 768px) {
    .capacitor-app .topbar-tabs .topbar-tab {
        padding: 8px 10px;
        font-size: 0.75rem;
    }
    .capacitor-app .topbar-search {
        flex: 1 1 100%;
        order: 3;
        max-width: 100%;
    }
    .capacitor-app .topbar-demo-balance {
        font-size: 0.75rem;
        padding: 6px 8px;
    }
    .capacitor-app .topbar-watchlist-btn,
    .capacitor-app .topbar-emulator-btn {
        padding: 6px 10px;
        font-size: 0.72rem;
    }
    .capacitor-app .emulator-panel {
        top: 12px;
        left: 8px;
        right: 8px;
        width: auto;
        max-height: 82vh;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        z-index: 700;
    }
    .capacitor-app .history-modal {
        max-height: 90vh;
        margin: env(safe-area-inset-top) 8px 8px;
    }
    .capacitor-app .hm-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .capacitor-app .hm-table {
        min-width: 640px;
    }
}

/* Touch-friendly tap targets */
@media (hover: none) and (pointer: coarse) {
    .capacitor-app .coin-item {
        min-height: 44px;
        padding: 10px 12px;
    }
    .capacitor-app .topbar-tab,
    .capacitor-app .topbar-watchlist-btn,
    .capacitor-app .topbar-emulator-btn,
    .capacitor-app .topbar-sound-btn {
        min-height: 40px;
        min-width: 44px;
    }
    .capacitor-app .emu-btn {
        min-height: 48px;
    }
    .capacitor-app .sidebar-toggle,
    .capacitor-app .mtf-toggle {
        min-width: 44px;
        min-height: 44px;
    }
}

/* === Светлая тема: эмулятор, оверлеи, AI без неона, зона графика === */
html[data-theme="light"] .demo-timer-buy {
    color: #ffffff;
}

html[data-theme="light"] .emulator-panel {
    background: #ffffff;
    border: 1px solid var(--card-border);
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.12);
}

html[data-theme="light"] .emu-header {
    background: #f8fafc;
}

html[data-theme="light"] .emu-coin-info {
    border-bottom-color: rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .emu-input-group input[type="range"] {
    background: rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .emu-input-group input[type="number"] {
    background: #f1f5f9;
    color: var(--text-main);
    border-color: var(--card-border);
}

html[data-theme="light"] .emu-summary {
    background: #f1f5f9;
}

html[data-theme="light"] .emu-switch-slider {
    background: #e2e8f0;
}

html[data-theme="light"] .emu-tpsl-input-wrap input {
    background: #ffffff;
    color: var(--text-main);
}

html[data-theme="light"] .emulator-panel::-webkit-scrollbar-thumb {
    background: rgba(15, 23, 42, 0.15);
}

html[data-theme="light"] .emulator-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(15, 23, 42, 0.28);
}

html[data-theme="light"] .mtf-grid {
    background: rgba(15, 23, 42, 0.05);
}

html[data-theme="light"] .mtf-toggle {
    background: #f1f5f9;
    border-color: var(--card-border);
    color: var(--text-muted);
}

html[data-theme="light"] .mtf-toggle:hover {
    background: #e2e8f0;
    color: var(--text-main);
}

html[data-theme="light"] .history-modal {
    box-shadow: 0 16px 48px rgba(15, 23, 42, 0.12);
}

html[data-theme="light"] .history-modal-overlay {
    background: rgba(15, 23, 42, 0.35);
}

html[data-theme="light"] .hm-header {
    background: #f8fafc;
}

html[data-theme="light"] .hm-table th {
    background: #eef1f6;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(15, 23, 42, 0.1);
}

html[data-theme="light"] .hm-table-container::-webkit-scrollbar-thumb {
    background: rgba(15, 23, 42, 0.12);
}

html[data-theme="light"] .ai-direction.up .ai-direction-label,
html[data-theme="light"] .ai-direction.down .ai-direction-label,
html[data-theme="light"] .ai-direction.sideways .ai-direction-label {
    text-shadow: none;
}

html[data-theme="light"] .neon-up,
html[data-theme="light"] .neon-down,
html[data-theme="light"] .neon-side {
    filter: none;
}

html[data-theme="light"] .ai-longterm {
    background: linear-gradient(180deg, rgba(var(--primary-rgb), 0.06) 0%, transparent 100%);
}

html[data-theme="light"] .horizon-item,
html[data-theme="light"] .longterm-item {
    background: #f8fafc;
}

html[data-theme="light"] .ai-panel-close {
    background: #f1f5f9;
}

html[data-theme="light"] .ai-panel-close:hover {
    background: #e2e8f0;
}

html[data-theme="light"] .ai-price-display {
    background: #f1f5f9;
    color: var(--text-main);
}

html[data-theme="light"] .ai-watch-btn {
    background: #f8fafc;
}

html[data-theme="light"] .ai-watch-btn.watched {
    background: rgba(var(--warn-rgb), 0.08);
    color: var(--warn);
    border-color: rgba(var(--warn-rgb), 0.3);
}

html[data-theme="light"] .ai-watch-btn.watched:hover {
    background: rgba(var(--warn-rgb), 0.15);
}

html[data-theme="light"] #tradingview-container {
    background: #ffffff !important;
}

html[data-theme="light"] .user-menu-popup {
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.12);
}

html[data-theme="light"] .user-menu-subtitle {
    color: var(--text-muted);
}