/* ============================================
   TradingChart — Design System
   Dark theme, glassmorphism, premium feel
   ============================================ */

:root {
    /* Colors */
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-card-hover: rgba(17, 24, 39, 0.9);
    --bg-input: rgba(17, 24, 39, 0.5);
    --bg-sidebar: #0d1117;

    --border-color: rgba(75, 85, 99, 0.3);
    --border-focus: rgba(99, 102, 241, 0.5);

    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --text-hint: #4b5563;

    --accent-primary: #6366f1;
    /* Indigo */
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.15);

    --green: #10b981;
    --green-bg: rgba(16, 185, 129, 0.1);
    --red: #ef4444;
    --red-bg: rgba(239, 68, 68, 0.1);
    --blue: #3b82f6;
    --blue-bg: rgba(59, 130, 246, 0.1);
    --orange: #f59e0b;
    --orange-bg: rgba(245, 158, 11, 0.1);
    --purple: #8b5cf6;
    --purple-bg: rgba(139, 92, 246, 0.1);
    --yellow: #eab308;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Spacing */
    --sidebar-width: 260px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-smooth: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   Reset & Base
   ============================================ */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(75, 85, 99, 0.4);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(75, 85, 99, 0.7);
}

/* ============================================
   Layout
   ============================================ */
#app {
    display: flex;
    min-height: 100vh;
}

/* ============================================
   Sidebar
   ============================================ */
#sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transition: width var(--transition-smooth), transform var(--transition-smooth);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent-primary), #a78bfa);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.brand-icon svg {
    width: 20px;
    height: 20px;
    color: white;
}

.brand-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.brand-version {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.nav-section {
    padding: 16px 12px 8px;
}

.nav-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-hint);
    padding: 0 8px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    margin-bottom: 2px;
    cursor: pointer;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.nav-item:hover {
    background: rgba(99, 102, 241, 0.08);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent-hover);
    box-shadow: inset 3px 0 0 var(--accent-primary);
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.online {
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
    animation: pulse-green 2s infinite;
}

.status-dot.offline {
    background: var(--text-hint);
}

.status-dot.warning {
    background: var(--orange);
    box-shadow: 0 0 6px var(--orange);
}

@keyframes pulse-green {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ============================================
   Sidebar Collapse Mode & Toggle
   ============================================ */
.sidebar-toggle-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    transition: all var(--transition-fast);
}

.sidebar-toggle-btn:hover {
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.4);
}

.sidebar-toggle-btn svg {
    width: 14px;
    height: 14px;
    transition: transform var(--transition-smooth);
}

/* Collapsed sidebar layout (Desktop only) */
:root {
    --sidebar-collapsed-width: 68px;
}

@media (min-width: 769px) {
    body.sidebar-collapsed #sidebar {
        width: var(--sidebar-collapsed-width);
    }

    body.sidebar-collapsed #sidebar .brand-text,
    body.sidebar-collapsed #sidebar .nav-label,
    body.sidebar-collapsed #sidebar .nav-item span,
    body.sidebar-collapsed #sidebar .status-indicator span {
        display: none !important;
    }

    body.sidebar-collapsed #sidebar .sidebar-brand {
        flex-direction: column;
        justify-content: center;
        padding: 20px 10px 16px;
        gap: 8px;
    }

    body.sidebar-collapsed #sidebar .sidebar-brand .sidebar-toggle-btn {
        margin-left: 0;
    }

    body.sidebar-collapsed #sidebar .sidebar-brand .sidebar-toggle-btn svg {
        transform: rotate(180deg);
    }

    body.sidebar-collapsed #sidebar .nav-item {
        justify-content: center;
        padding: 12px;
    }

    body.sidebar-collapsed #sidebar .sidebar-footer {
        padding: 16px 10px;
        display: flex;
        justify-content: center;
    }

    body.sidebar-collapsed #mainContent {
        margin-left: var(--sidebar-collapsed-width);
    }
}

/* ============================================
   Main Content
   ============================================ */
#mainContent {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px 40px;
    max-width: 1200px;
    transition: margin-left var(--transition-smooth);
}

.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

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

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

.page-header {
    margin-bottom: 28px;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ============================================
   Stats Grid (Dashboard)
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    backdrop-filter: blur(12px);
    transition: all var(--transition-normal);
}

.stat-card:hover {
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg {
    width: 22px;
    height: 22px;
}

.stat-icon.green {
    background: var(--green-bg);
    color: var(--green);
}

.stat-icon.blue {
    background: var(--blue-bg);
    color: var(--blue);
}

.stat-icon.purple {
    background: var(--purple-bg);
    color: var(--purple);
}

.stat-icon.orange {
    background: var(--orange-bg);
    color: var(--orange);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: var(--font-mono);
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ============================================
   Cards
   ============================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(12px);
    margin-bottom: 20px;
    transition: border-color var(--transition-normal);
}

.card:hover {
    border-color: rgba(99, 102, 241, 0.2);
}

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

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.card-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-icon {
    width: 20px;
    height: 20px;
    color: var(--accent-hover);
}

.card-body {
    padding: 24px;
}

.badge {
    background: var(--accent-glow);
    color: var(--accent-hover);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    font-family: var(--font-mono);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state p {
    font-size: 0.95rem;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.empty-hint {
    font-size: 0.8rem;
    color: var(--text-hint);
}

/* ============================================
   Forms & Inputs
   ============================================ */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="number"],
textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    transition: all var(--transition-fast);
    outline: none;
}

input:focus,
textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-hint);
    font-family: var(--font-sans);
}

textarea {
    resize: vertical;
    line-height: 1.8;
}

.form-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-hint);
    margin-top: 4px;
}

.form-hint.success {
    color: var(--green);
}

.input-with-action {
    display: flex;
    gap: 8px;
}

.input-with-action input {
    flex: 1;
}

.form-row {
    margin-bottom: 20px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.settings-grid .form-group {
    margin-bottom: 4px;
}

/* Toggle Switch */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-primary);
}

.toggle-label input[type="checkbox"] {
    display: none;
}

.toggle-switch {
    width: 44px;
    height: 24px;
    background: var(--text-hint);
    border-radius: 12px;
    position: relative;
    transition: background var(--transition-fast);
    flex-shrink: 0;
}

.toggle-switch::after {
    content: '';
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 3px;
    left: 3px;
    transition: transform var(--transition-fast);
}

input:checked+.toggle-switch {
    background: var(--accent-primary);
}

input:checked+.toggle-switch::after {
    transform: translateX(20px);
}

.checkbox-group .form-hint {
    margin-left: 56px;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    outline: none;
}

.btn svg {
    width: 16px;
    height: 16px;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-outline:hover {
    border-color: var(--accent-primary);
    color: var(--accent-hover);
    background: var(--accent-glow);
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 9px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
}

.btn-icon:hover {
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* Spinner */
.btn .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   Connection Badge & Result
   ============================================ */
.connection-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.connection-badge.connected {
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--green);
}

.connection-badge.connected .status-dot {
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
}

.connection-result {
    margin-top: 16px;
    padding: 16px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    animation: fadeIn 0.3s ease;
}

.connection-result.success {
    background: var(--green-bg);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--green);
}

.connection-result.error {
    background: var(--red-bg);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--red);
}

.connection-result .result-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.connection-result .result-detail {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    opacity: 0.85;
}

/* ============================================
   Alert Banner
   ============================================ */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 0.875rem;
    animation: fadeIn 0.3s ease;
}

.alert-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.alert-warning {
    background: var(--orange-bg);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--orange);
}

.alert-success {
    background: var(--green-bg);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--green);
}

.alert-error {
    background: var(--red-bg);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--red);
}

/* ============================================
   Toast Notifications
   ============================================ */
#toastContainer {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    min-width: 300px;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s ease;
    transition: all 0.3s ease;
}

.toast.success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--green);
}

.toast.error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--red);
}

.toast.info {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--blue);
}

.toast.fadeOut {
    opacity: 0;
    transform: translateX(100px);
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }

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

/* ============================================
   Settings Card specific
   ============================================ */
.settings-card {
    transition: all var(--transition-normal);
}

.settings-card:hover {
    box-shadow: var(--shadow-md);
}

/* ============================================
   Settings Section Headers
   ============================================ */
.settings-section-header {
    margin: 32px 0 16px;
}

.section-label-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.section-title {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.section-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

.section-tag {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 3px 9px;
    border-radius: 4px;
    font-family: var(--font-mono);
}

.section-tag.read-only {
    background: rgba(59, 130, 246, 0.12);
    color: var(--blue);
    border: 1px solid rgba(59, 130, 246, 0.25);
}

.section-tag.trading {
    background: rgba(16, 185, 129, 0.12);
    color: var(--green);
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.section-tag.risk {
    background: rgba(245, 158, 11, 0.12);
    color: var(--orange);
    border: 1px solid rgba(245, 158, 11, 0.25);
}

/* ============================================
   Mode Badge (LIVE / TESTNET)
   ============================================ */
.mode-badge {
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    padding: 3px 10px;
    border-radius: 4px;
    font-family: var(--font-mono);
}

.mode-badge.mode-live {
    background: rgba(16, 185, 129, 0.12);
    color: var(--green);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.mode-badge.mode-testnet {
    background: rgba(245, 158, 11, 0.12);
    color: var(--orange);
    border: 1px solid rgba(245, 158, 11, 0.3);
    animation: pulse-orange 2s infinite;
}

@keyframes pulse-orange {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* ============================================
   Testnet Toggle Hints
   ============================================ */
.testnet-toggle-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.testnet-hint-live,
.testnet-hint-testnet {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.testnet-hint-live svg,
.testnet-hint-testnet svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.testnet-hint-live {
    background: rgba(16, 185, 129, 0.08);
    color: var(--green);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.testnet-hint-testnet {
    background: rgba(245, 158, 11, 0.1);
    color: var(--orange);
    border: 1px solid rgba(245, 158, 11, 0.25);
}

/* ============================================
   Inline Form Row
   ============================================ */
.form-row-inline {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 20px;
}

.form-row-inline .form-group {
    margin-bottom: 0;
}

.flex-1 {
    flex: 1;
}

/* ============================================
   URL Preview Bar
   ============================================ */
.url-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(99, 102, 241, 0.05);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.78rem;
}

.url-label {
    color: var(--text-muted);
    font-weight: 600;
    flex-shrink: 0;
}

.url-value {
    font-family: var(--font-mono);
    color: var(--accent-hover);
    word-break: break-all;
}

/* ============================================
   Select Input
   ============================================ */
.select-input {
    width: 100%;
    padding: 10px 36px 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
    transition: all var(--transition-fast);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.select-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.select-input option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* ============================================
   Card Header Right
   ============================================ */
.card-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.settings-language-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    max-width: 360px;
}

.settings-language-toolbar label {
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
}

.settings-language-toolbar select {
    min-width: 160px;
}

/* ============================================
   Account Cards
   ============================================ */
.account-card .card-header {
    flex-wrap: wrap;
    gap: 12px;
}

.account-toggle {
    display: flex;
    align-items: center;
}

.account-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.account-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.account-key-badge {
    font-size: 0.72rem;
    font-family: var(--font-mono);
    padding: 3px 10px;
    border-radius: 4px;
}

.account-key-badge.key-set {
    background: rgba(16, 185, 129, 0.1);
    color: var(--green);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.account-key-badge.key-missing {
    background: rgba(245, 158, 11, 0.1);
    color: var(--orange);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.test-result-inline {
    padding: 10px 24px;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-top: 1px solid var(--border-color);
    animation: fadeIn 0.3s ease;
}

.test-result-inline.success {
    background: rgba(16, 185, 129, 0.05);
    color: var(--green);
}

.test-result-inline.error {
    background: rgba(239, 68, 68, 0.05);
    color: var(--red);
}

.result-balance {
    font-family: var(--font-mono);
    color: var(--text-secondary);
    font-size: 0.78rem;
}

/* ============================================
   Add Account Card
   ============================================ */
.add-account-card {
    border-style: dashed;
    border-color: rgba(99, 102, 241, 0.2);
}

.add-account-card:hover {
    border-color: rgba(99, 102, 241, 0.4);
}

/* ============================================
   Small Buttons + Danger Button
   ============================================ */
.btn-sm {
    padding: 6px 12px;
    font-size: 0.78rem;
}

.btn-sm svg {
    width: 13px;
    height: 13px;
}

.btn-danger-outline {
    background: transparent;
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger-outline:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--red);
}

/* ============================================
   Label optional hint
   ============================================ */
.label-optional {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* ============================================
   Connection badge states
   ============================================ */
.connection-badge.configured {
    border-color: rgba(245, 158, 11, 0.3);
    color: var(--orange);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    #sidebar {
        transform: translateX(-100%);
    }

    #mainContent {
        margin-left: 0;
        padding: 20px 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .settings-grid {
        grid-template-columns: 1fr 1fr;
    }

    .form-row-inline {
        flex-direction: column;
    }

    .settings-language-toolbar {
        align-items: stretch;
        flex-direction: column;
        max-width: none;
    }

    .card-header-right {
        gap: 6px;
    }
}

/* ============================================
   Charts Page — Full Width Layout
   ============================================ */
body.full-width-mode {
    overflow: hidden !important;
    /* Prevent page scrolling in full width mode */
}

body.full-width-mode #mainContent {
    padding: 0 !important;
    max-width: none !important;
    height: 100vh;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.page-fullwidth {
    padding: 0 !important;
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.page-fullwidth.active {
    display: flex;
}

#page-charts.active {
    display: flex;
}

/* Toolbar */
.chart-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: #131722;
    border-bottom: 1px solid #2a2e39;
    flex-shrink: 0;
    gap: 12px;
    flex-wrap: wrap;
}

.chart-toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.chart-toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chart-add-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-sym-select {
    width: 180px;
    min-width: 0;
    font-size: 0.85rem;
    padding: 7px 10px 7px 28px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.chart-tf-select {
    width: 70px;
    font-size: 0.85rem;
    padding: 7px 26px 7px 10px;
}

.chart-sym-quick {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.sym-btn {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.sym-btn:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.sym-state {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* WS Status */
.ws-status-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.ws-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.ws-dot.online {
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
    animation: pulse-green 2s infinite;
}

.ws-dot.offline {
    background: var(--text-hint);
}

.ws-dot.degraded {
    background: var(--orange);
    box-shadow: 0 0 6px var(--orange);
    animation: pulse-orange 2s infinite;
}

@keyframes pulse-orange {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.ws-label {
    font-size: 0.75rem;
}

/* Widget Grid Wrapper */
.chart-grid-wrapper {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    width: 100%;
}

/* Widget Grid */
.chart-grid {
    padding: 8px;
    background: var(--bg-primary);
    /* gridstack.js handles the layout, gap and sizing */
}

/* ── Chart Widget ──────────────────────────────────────────── */
.chart-widget {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    /* Gridstack cell content handles sizing */
    width: 100%;
    height: 100%;
}

.chart-widget:hover {
    border-color: rgba(99, 102, 241, 0.25);
}

.chart-widget.flash-event {
    border-color: var(--accent-primary);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.2);
    animation: flash-border 1.5s ease;
}

@keyframes flash-border {
    0% {
        border-color: var(--accent-primary);
        box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
    }

    100% {
        border-color: var(--border-color);
        box-shadow: none;
    }
}

/* Widget Header — 2-column layout: left=coin+auto(80%), right=View+Pro(20%) */
.widget-header {
    display: flex;
    align-items: stretch;
    padding: 0;
    background: rgba(17, 24, 39, 0.95);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    min-height: 48px;
}

.widget-header-left {
    flex: 1 1 80%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 6px 10px 6px 10px;
    min-width: 0;
    overflow: hidden;
}

.widget-title-col {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex: 1;
    line-height: 1;
}

.widget-badges-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
}

.widget-header-bottom-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
}

.widget-header-right {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: space-between;
    gap: 5px;
    padding: 6px 6px 6px 0;
}

/* Bottom row inside right side: [Auto -+] + [Pro] inline */
.widget-right-bottom-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
}

/* Top row inside right side: [View] + [X] inline */
.widget-right-top-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

/* Close (X) button — square red, always visible, next to View */
.widget-btn-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 22px;
    padding: 0;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: 5px;
    color: #f87171;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.widget-btn-close svg {
    width: 11px;
    height: 11px;
    pointer-events: none;
}

.widget-btn-close:hover {
    background: #ef4444 !important;
    border-color: #ef4444 !important;
    color: #fff !important;
}

.widget-btn-close:active {
    background: #dc2626 !important;
    transform: scale(0.92);
}

/* Precision control in header bottom row */
.precision-controls {
    display: flex;
    align-items: center;
    gap: 1px;
    background: rgba(31, 41, 55, 0.6);
    border: 1px solid rgba(75, 85, 99, 0.25);
    border-radius: 4px;
    padding: 1px 2px;
}

.prec-btn {
    padding: 1px 5px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    border-radius: 2px;
    line-height: 1.4;
    transition: color 0.15s;
}

.prec-btn:hover {
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.15);
}

.prec-label {
    color: #9ca3af;
    font-size: 10px;
    min-width: 28px;
    text-align: center;
    cursor: pointer;
    font-family: var(--font-mono);
    user-select: none;
}

.prec-label:hover {
    color: var(--accent-hover);
}

/* View button — indigo tone, same family as Pro */
.widget-btn-view {
    background: rgba(99, 102, 241, 0.15) !important;
    border: 1px solid rgba(99, 102, 241, 0.35) !important;
    color: #818cf8 !important;
    margin-right: 0 !important;
}

.widget-btn-view:hover {
    background: rgba(99, 102, 241, 0.28) !important;
    color: #a5b4fc !important;
    box-shadow: none !important;
    transform: none !important;
}

/* Pro button — violet tone */
.widget-btn-pro {
    background: rgba(139, 92, 246, 0.12) !important;
    border: 1px solid rgba(139, 92, 246, 0.3) !important;
    color: #a78bfa !important;
    margin-right: 0 !important;
}

.widget-btn-pro:hover {
    background: rgba(139, 92, 246, 0.25) !important;
    color: #c4b5fd !important;
    box-shadow: none !important;
    transform: none !important;
}

/* Delete (X) button — round red, shown via JS on header hover */
.widget-delete-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    min-width: 20px;
    padding: 0;
    background: #ef4444;
    border: 2px solid rgba(255,255,255,0.15);
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    opacity: 0;
    transform: scale(0.4);
    transition: opacity 0.16s ease, transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.5);
    margin-left: 4px;
    pointer-events: none;
}

.widget-delete-btn.visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.widget-delete-btn svg {
    width: 10px;
    height: 10px;
    flex-shrink: 0;
    pointer-events: none;
}

.widget-delete-btn:hover {
    background: #dc2626 !important;
    transform: scale(1.18) !important;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.8) !important;
}

.widget-delete-btn:active {
    transform: scale(0.88) !important;
}

.widget-drag-handle {
    cursor: move;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    user-select: none;
    -webkit-user-select: none;
}

.widget-drag-handle:active {
    cursor: grabbing;
}

.widget-drag-handle svg {
    width: 14px;
    height: 14px;
}

.widget-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.widget-symbol {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.widget-quote {
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-muted);
}

.widget-state-badge {
    font-size: 0.62rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 3px;
    border: 1px solid transparent;
    background: rgba(107, 114, 128, 0.15);
    color: var(--text-muted);
    font-family: var(--font-mono);
    letter-spacing: 0.05em;
}

@keyframes pulse-stale {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

.widget-stale-badge {
    font-family: var(--font-mono);
}

.widget-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    flex-wrap: wrap;
}

/* TF buttons */
.tf-buttons {
    display: flex;
    gap: 2px;
}

.tf-btn {
    padding: 3px 7px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 3px;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tf-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-color);
}

.tf-btn.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-hover);
    border-color: rgba(99, 102, 241, 0.3);
}

/* Indicator toggle buttons */
.indicator-toggles {
    display: flex;
    gap: 2px;
}

.ind-btn {
    padding: 3px 8px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    color: var(--text-muted);
    font-size: 0.7rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.ind-btn:hover {
    color: var(--text-primary);
}

.ind-btn.active {
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent-hover);
    border-color: rgba(99, 102, 241, 0.25);
}

/* Close button */
.widget-close-btn {
    background: transparent;
    border: none;
    color: var(--text-hint);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    transition: all var(--transition-fast);
    line-height: 1;
}

.widget-close-btn:hover {
    color: var(--red);
    background: var(--red-bg);
}

/* Expand button — neutral dark base; .widget-btn-view/.widget-btn-pro override colors */
.widget-expand-btn {
    background: rgba(51, 65, 85, 0.5);
    border: 1px solid rgba(99, 102, 241, 0.2);
    color: #94a3b8;
    cursor: pointer;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    line-height: 1;
    margin-right: 6px;
    box-shadow: none;
}

.widget-expand-btn:hover {
    background: rgba(71, 85, 105, 0.6);
    color: #cbd5e1;
    border-color: rgba(99, 102, 241, 0.35);
}

.widget-expand-btn:active {
    transform: translateY(0);
}

/* Override for stacked layout in widget-header-right */
.widget-header-right .widget-expand-btn {
    margin-right: 0;
    padding: 3px 6px;
    font-size: 0.7rem;
    justify-content: center;
    box-shadow: none;
    white-space: nowrap;
    flex: 1;
}


/* Price row */
.widget-price-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    background: rgba(17, 24, 39, 0.5);
    border-bottom: 1px solid rgba(75, 85, 99, 0.15);
    flex-shrink: 0;
    font-family: var(--font-mono);
}

.widget-close-price {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.widget-change {
    font-size: 0.75rem;
    font-weight: 600;
}

.widget-change.positive { color: var(--green); }
.widget-change.negative { color: var(--red); }

.widget-ohlc {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-left: auto;
}

/* Chart areas */
.widget-chart-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.widget-main-chart {
    position: relative;
    min-height: 0;
}

.widget-rsi-chart,
.widget-macd-chart {
    position: relative;
    box-shadow: inset 0 1px 0 rgba(75, 85, 99, 0.2);
    overflow: hidden;
}

/* Resize handle */
.widget-resize-handle {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 14px;
    height: 14px;
    cursor: nwse-resize;
    color: var(--text-hint);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.chart-widget:hover .widget-resize-handle {
    opacity: 1;
}

.widget-resize-handle svg {
    width: 14px;
    height: 14px;
}

/* Loading state */
.chart-widget.loading .widget-chart-area::after {
    content: 'Loading...';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 14, 23, 0.7);
    color: var(--text-muted);
    font-size: 0.8rem;
    letter-spacing: 0.05em;
}

.chart-widget .widget-status-message {
    position: absolute;
    inset: 0;
    z-index: 8;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 18px;
    background: rgba(10, 14, 23, 0.82);
    color: #e5e7eb;
    text-align: center;
    pointer-events: none;
}

.chart-widget.has-status-message .widget-status-message {
    display: flex;
}

.chart-widget.has-status-message.loading .widget-chart-area::after {
    display: none;
}

.chart-widget .widget-status-title {
    color: #f8fafc;
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1.3;
}

.chart-widget .widget-status-detail {
    color: var(--text-muted);
    font-size: 0.76rem;
    line-height: 1.35;
}

/* ── Bot Event Log ──────────────────────────────────────────── */
.bot-event-panel {
    flex-shrink: 0;
    border-top: 1px solid var(--border-color);
    background: rgba(13, 17, 23, 0.95);
    max-height: 140px;
    display: flex;
    flex-direction: column;
    transition: max-height var(--transition-normal);
}

.bot-event-panel.collapsed {
    max-height: 36px;
    overflow: hidden;
}

.event-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 14px;
    border-bottom: 1px solid rgba(75, 85, 99, 0.2);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    flex-shrink: 0;
}

.event-log-scroll {
    overflow-y: auto;
    flex: 1;
    padding: 4px 0;
}

.event-log-entry {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 14px;
    font-size: 0.76rem;
    border-bottom: 1px solid rgba(75, 85, 99, 0.08);
    animation: fadeIn 0.3s ease;
    transition: background var(--transition-fast);
}

.event-log-entry:hover {
    background: rgba(99, 102, 241, 0.05);
}

.event-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.event-time {
    color: var(--text-hint);
    font-family: var(--font-mono);
    flex-shrink: 0;
}

.event-sym {
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    flex-shrink: 0;
    min-width: 40px;
}

.event-text {
    color: var(--text-primary);
    flex: 1;
}

/* Fullwidth page doesn't need mainContent padding */
#mainContent:has(.page-fullwidth.active) {
    padding: 0;
    max-width: 100%;
}

/* ── Market Analyzer ───────────────────────────────────────────────────── */

.analyzer-widget {
    position: relative;
}

@keyframes analyzerFlash {
    0% {
        background: rgba(16, 185, 129, 0.25);
    }

    50% {
        background: rgba(16, 185, 129, 0.05);
    }

    100% {
        background: rgba(16, 185, 129, 0.25);
    }
}

.analyzer-flash {
    animation: analyzerFlash 0.6s ease-in-out 2;
}

/* Signal cell tooltip */
.signal-cell {
    position: relative;
}

.signal-cell:hover::after {
    content: attr(title);
    position: absolute;
    right: 0;
    top: 100%;
    z-index: 200;
    background: #1e293b;
    border: 1px solid #374151;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 10px;
    line-height: 1.6;
    color: #e5e7eb;
    white-space: pre-line;
    min-width: 220px;
    max-width: 280px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    text-align: left;
}

/* Hide native title tooltip when CSS tooltip is shown */
.signal-cell[title]:hover {
    cursor: help;
}

/* ── Indicators toggle button + dropdown ───────────────────────────────────── */

.ind-panel-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: rgba(31, 41, 55, 0.7);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 5px;
    color: #94a3b8;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
    user-select: none;
    -webkit-user-select: none;
}
.ind-panel-toggle:hover {
    background: rgba(99, 102, 241, 0.12);
    color: #c7d2fe;
    border-color: rgba(99, 102, 241, 0.5);
}

.indicator-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 5px;
    margin-left: 3px;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.85);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    user-select: none;
    pointer-events: none;
    cursor: default;
}

.ind-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 300;
    background: #1e293b;
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 8px;
    padding: 6px;
    gap: 4px;
    flex-direction: row;
    flex-wrap: wrap;
    min-width: 200px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.ind-dropdown.open {
    display: flex;
}

/* ── Global Indicator Toggle Buttons ──────────────────────────────────────── */

.ind-global-btn {
    padding: 3px 8px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    color: #848e9c;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.15s ease;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ind-global-btn:hover {
    color: #f0f3fa;
    background: rgba(255, 255, 255, 0.08);
}

.ind-global-btn.active {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    border-color: rgba(99, 102, 241, 0.3);
}

/* Indicator count badge on toolbar button */
.ind-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #6366f1;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    margin-left: 4px;
    line-height: 1;
}

.ind-global-btn.has-indicators {
    background: rgba(99, 102, 241, 0.12);
    color: #a5b4fc;
    border-color: rgba(99, 102, 241, 0.25);
}

/* ── Zoom Range Buttons ───────────────────────────────────────────────────── */

.zoom-btn {
    padding: 3.5px 8px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    color: #848e9c;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.15s ease;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.zoom-btn:hover {
    color: #f0f3fa;
    background: rgba(255, 255, 255, 0.08);
}

.zoom-btn.active {
    background: #2a2e39;
    color: #f0f3fa;
    border-color: transparent;
}

/* ── Custom Premium Buttons ────────────────────────────────────────────────── */

.btn-analyzer {
    background: rgba(99, 102, 241, 0.1) !important;
    color: #818cf8 !important;
    border: 1px solid rgba(99, 102, 241, 0.3) !important;
    transition: all var(--transition-fast) !important;
}

.btn-analyzer:hover {
    background: rgba(99, 102, 241, 0.2) !important;
    color: #a5b4fc !important;
    border-color: rgba(99, 102, 241, 0.5) !important;
}

.btn-analyzer.active {
    background: #4f46e5 !important;
    color: #ffffff !important;
    border-color: #4f46e5 !important;
}

/* Lucide Icon Utility inside buttons */
svg.btn-svg-icon,
.ind-global-btn svg,
.zoom-btn svg,
[data-lucide] {
    width: 14px;
    height: 14px;
    stroke-dasharray: none;
    stroke-width: 2.2px;
    stroke: currentColor;
    fill: none;
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}

/* ── Symbol Search Dropdown ───────────────────────────────────────────────── */

#chartSearchResults .search-result-item,
#proChartSearchResults .search-result-item {
    padding: 6px 10px;
    color: #e5e7eb;
    font-size: 11px;
    cursor: pointer;
    border-bottom: 1px solid rgba(55, 65, 81, 0.3);
    transition: background 0.1s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
}

#chartSearchResults .search-result-item:hover,
#proChartSearchResults .search-result-item:hover {
    background: rgba(99, 102, 241, 0.15);
}

#chartSearchResults .search-result-item .sr-symbol,
#proChartSearchResults .search-result-item .sr-symbol {
    font-weight: 600;
    color: #f9fafb;
    flex: 1;
}

#chartSearchResults .search-result-item .sr-badges,
#proChartSearchResults .search-result-item .sr-badges {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

#chartSearchResults .search-result-item .sr-exch,
#proChartSearchResults .search-result-item .sr-exch {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.3px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 16px;
    box-sizing: border-box;
}

#chartSearchResults .search-result-item .sr-mkt,
#proChartSearchResults .search-result-item .sr-mkt {
    font-size: 9px;
    padding: 1px 4px;
    border-radius: 3px;
    background: rgba(107, 114, 128, 0.25);
    color: #9ca3af;
    font-weight: 600;
}

#chartSearchResults .search-result-item .sr-state,
#proChartSearchResults .search-result-item .sr-state {
    font-size: 9px;
    padding: 1px 4px;
    border-radius: 2px;
    background: rgba(107, 114, 128, 0.2);
}

#singleChartSearchResults .search-result-item {
    padding: 6px 10px;
    color: #e5e7eb;
    font-size: 11px;
    cursor: pointer;
    border-bottom: 1px solid rgba(55, 65, 81, 0.3);
    transition: background 0.1s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
}

#singleChartSearchResults .search-result-item:hover {
    background: rgba(99, 102, 241, 0.15);
}

#singleChartSearchResults .search-result-item .sr-symbol {
    font-weight: 600;
    color: #f9fafb;
    flex: 1;
}

#singleChartSearchResults .search-result-item .sr-badges {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

#singleChartSearchResults .search-result-item .sr-exch {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.3px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 16px;
    box-sizing: border-box;
}

#singleChartSearchResults .search-result-item .sr-mkt {
    font-size: 9px;
    padding: 1px 4px;
    border-radius: 3px;
    background: rgba(107, 114, 128, 0.25);
    color: #9ca3af;
    font-weight: 600;
}

/* Widget header exchange + market badges */
.widget-exch-badge {
    font-size: 8px;
    font-weight: 800;
    padding: 0 4px;
    border-radius: 3px;
    letter-spacing: 0.5px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 16px;
    box-sizing: border-box;
}

.widget-market-badge {
    font-size: 8px;
    font-weight: 600;
    padding: 0 4px;
    border-radius: 3px;
    background: rgba(107, 114, 128, 0.2);
    color: #6b7280;
    border: 1px solid rgba(107, 114, 128, 0.2);
    letter-spacing: 0.3px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 16px;
    box-sizing: border-box;
}

/* ============================================
   Capital Flow Monitor — Page Styles
   ============================================ */

/* Overview Grid */
.cf-overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    align-items: center;
}

.cf-overview-item {
    text-align: center;
}

.cf-overview-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.cf-overview-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}

.cf-overview-delta {
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 2px;
    font-family: 'JetBrains Mono', monospace;
}

.cf-overview-delta.positive {
    color: var(--green);
}

.cf-overview-delta.negative {
    color: var(--red);
}

/* Status Badge */
.cf-status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cf-status-badge.strong-inflow {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.cf-status-badge.inflow {
    background: rgba(52, 211, 153, 0.15);
    color: #34d399;
    border: 1px solid rgba(52, 211, 153, 0.2);
}

.cf-status-badge.neutral {
    background: rgba(156, 163, 175, 0.15);
    color: #9ca3af;
    border: 1px solid rgba(156, 163, 175, 0.2);
}

.cf-status-badge.outflow {
    background: rgba(251, 146, 60, 0.15);
    color: #fb923c;
    border: 1px solid rgba(251, 146, 60, 0.2);
}

.cf-status-badge.strong-outflow {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Sector Table */
.cf-sector-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.cf-sector-table thead th {
    padding: 10px 14px;
    text-align: left;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    background: rgba(17, 24, 39, 0.5);
    white-space: nowrap;
}

.cf-sector-table tbody tr {
    border-bottom: 1px solid rgba(75, 85, 99, 0.15);
    cursor: pointer;
    transition: background 0.15s;
}

.cf-sector-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.06);
}

.cf-sector-table tbody td {
    padding: 10px 14px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    white-space: nowrap;
}

.cf-sector-table tbody td:first-child {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
}

/* VFS bar inside table */
.cf-vfs-bar {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.cf-vfs-bar-fill {
    height: 6px;
    border-radius: 3px;
    min-width: 4px;
    max-width: 80px;
    transition: width 0.3s;
}

.cf-vfs-bar-fill.positive {
    background: linear-gradient(90deg, #10b981, #34d399);
}

.cf-vfs-bar-fill.negative {
    background: linear-gradient(90deg, #f87171, #ef4444);
}

/* Insights */
.cf-insights {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cf-insight-item {
    padding: 8px 12px;
    border-radius: 6px;
    background: rgba(99, 102, 241, 0.05);
    border-left: 3px solid var(--accent-primary);
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

/* Period buttons */
.cf-period-btn.active {
    background: var(--accent-primary);
    color: #fff;
}

/* Coin table in drill-down */
.cf-coin-table tbody td {
    font-size: 0.78rem;
}

/* Color helpers */
.color-green {
    color: var(--green) !important;
}

.color-red {
    color: var(--red) !important;
}

.color-orange {
    color: #fb923c !important;
}

/* Hide TradingView Watermark Logo globally for cleaner AI vision */
#tv-attr-logo,
.tv-lightweight-charts-watermark,
a[href*="tradingview.com"] {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    z-index: -9999 !important;
}

/* ── Single Chart Page layout container ── */
.single-chart-layout {
    display: flex;
    flex: 1;
    width: 100%;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

#page-mtf-chart,
#page-pro-chart {
    height: 100vh;
    flex-direction: column;
}

#page-mtf-chart.active,
#page-pro-chart.active {
    display: flex;
}

@media (min-width: 769px) {
    body:not([data-mobile-build]) .pro-chart-primary-row {
        display: grid;
        grid-template-areas:
            "symbol candle"
            "quote quote";
        grid-template-columns: max-content max-content;
        align-items: baseline;
        column-gap: 12px;
        white-space: nowrap;
    }

    body:not([data-mobile-build]) .pro-chart-symbol {
        grid-area: symbol;
    }

    body:not([data-mobile-build]) .pro-chart-quote-row {
        grid-area: quote;
    }

    body:not([data-mobile-build]) .pro-chart-candle-info {
        grid-area: candle;
    }
}

#page-mtf-chart .chart-toolbar {
    flex-shrink: 0;
}

.analyzer-side-panel {
    width: 320px;
    flex-shrink: 0;
    border-left: 1px solid var(--border-color);
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    transition: width var(--transition-smooth);
    overflow: hidden;
    position: relative;
}

.analyzer-side-panel.collapsed {
    width: 48px;
}

.analyzer-side-panel.collapsed .side-panel-title,
.analyzer-side-panel.collapsed .side-panel-content,
.analyzer-side-panel.collapsed #singleChartSideScanBtn,
.analyzer-side-panel.collapsed .side-btn-help {
    display: none !important;
}

.analyzer-side-panel.collapsed .side-panel-header {
    justify-content: center;
    padding: 10px 0;
}

.analyzer-side-panel.collapsed .side-panel-toggle-btn svg {
    transform: rotate(180deg);
}

.side-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(17, 24, 39, 0.9);
    flex-shrink: 0;
    height: 43px;
}

.side-panel-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-sans);
}

.side-panel-toggle-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.side-panel-toggle-btn:hover {
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.4);
}

.side-panel-toggle-btn svg {
    width: 14px;
    height: 14px;
    transition: transform var(--transition-smooth);
}

.side-panel-content {
    flex: 1;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Remove default widget card styling inside side panel */
.analyzer-side-panel .chart-widget {
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
}

.analyzer-side-panel .widget-header {
    display: none !important;
    /* Hide widget header because we have side-panel-header */
}

/* Let the inner list fill the remaining height in the sidebar analyzer widget */
.analyzer-side-panel [id^="az-list-"] {
    flex: 1 !important;
    height: auto !important;
    overflow-y: auto !important;
}

/* ============================================
   Layout Selection Dropdown Styling
   ============================================ */
.layout-dropdown-wrap {
    position: relative;
    display: inline-block;
}

.layout-dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 6px;
    background: #1e293b;
    border: 1px solid #374151;
    border-radius: 6px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
    z-index: 250;
    min-width: 175px;
    padding: 6px 0;
    backdrop-filter: blur(12px);
}

.layout-dropdown-menu.show {
    display: block !important;
}

.layout-menu-item {
    display: flex;
    align-items: center;
    padding: 8px 14px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-decoration: none;
    transition: background var(--transition-fast), color var(--transition-fast);
    cursor: pointer;
    line-height: 1.4;
}

.layout-menu-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.layout-menu-item.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-hover);
    font-weight: 500;
}

.draw-tool-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s;
}

.draw-tool-btn:hover {
    background: #1e293b;
    color: #f8fafc;
}

.draw-tool-btn.active {
    background: #2563eb;
    color: #ffffff;
}

.ind-menu-item {
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 500;
    color: #cbd5e1;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
}

.ind-menu-item:hover {
    background: #334155;
}

.ind-menu-item.active {
    color: #38bdf8;
}

/* ── Indicator Modal Popup ─────────────────────────────────── */
.ind-modal-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.65);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(3px);
}

.ind-modal-backdrop.open {
    display: flex;
}

.ind-modal {
    background: #1e222d;
    border: 1px solid #2b2b43;
    border-radius: 12px;
    width: 620px;
    max-width: 92vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    animation: indModalIn 0.2s ease-out;
}

@keyframes indModalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

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

.ind-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 16px;
    border-bottom: 1px solid #2b2b43;
    flex-shrink: 0;
}

.ind-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #f0f3fa;
}

.ind-modal-close {
    background: none;
    border: none;
    color: #787b86;
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    border-radius: 6px;
    transition: all 0.15s;
}

.ind-modal-close:hover {
    color: #f0f3fa;
    background: rgba(255, 255, 255, 0.08);
}

.ind-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px 24px;
}

.indicator-panel h3 {
    font-size: 14px;
    font-weight: 600;
    color: #f0f3fa;
    margin-bottom: 16px;
}

#indicator-search {
    width: 100%;
    padding: 8px 12px;
    background-color: #2a2e39;
    border: 1px solid #363a45;
    border-radius: 4px;
    color: #d1d4dc;
    font-size: 13px;
    margin-bottom: 12px;
}

#indicator-search:focus {
    outline: none;
    border-color: #2962FF;
}

#indicator-search::placeholder {
    color: #787b86;
}

.group-section {
    margin-bottom: 8px;
}

.group-header {
    display: flex;
    align-items: center;
    padding: 8px 8px;
    font-size: 13px;
    font-weight: 700;
    color: #f0f3fa;
    cursor: pointer;
    user-select: none;
    border-radius: 4px;
    border-bottom: 1px solid #2b2b43;
}

.group-header:hover {
    background-color: #2a2e39;
}

.group-header::before {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #d1d4dc;
    margin-right: 8px;
    transition: transform 0.15s;
}

.group-header.collapsed::before {
    transform: rotate(-90deg);
}

.group-count {
    margin-left: auto;
    font-size: 11px;
    font-weight: 400;
    color: #787b86;
}

.group-items.collapsed {
    display: none;
}

.category-group {
    margin-bottom: 4px;
}

.category-header {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    font-size: 12px;
    font-weight: 600;
    color: #787b86;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    user-select: none;
    border-radius: 4px;
}

.category-header:hover {
    background-color: #2a2e39;
}

.category-header::before {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #787b86;
    margin-right: 8px;
    transition: transform 0.15s;
}

.category-header.collapsed::before {
    transform: rotate(-90deg);
}

.category-count {
    margin-left: auto;
    font-size: 11px;
    font-weight: 400;
    color: #555;
}

.category-items.collapsed {
    display: none;
}

.indicator-item {
    padding: 5px 8px 5px 24px;
    font-size: 13px;
    cursor: pointer;
    border-radius: 4px;
    border-left: 3px solid transparent;
}

.indicator-item:hover {
    background-color: #2a2e39;
}

.indicator-item.active {
    border-left-color: #2962FF;
    background-color: rgba(41, 98, 255, 0.1);
    color: #f0f3fa;
}

.indicator-item.hidden {
    display: none;
}

.category-group.hidden {
    display: none;
}

.group-section.hidden {
    display: none;
}

.indicator-inputs h4 {
    font-size: 13px;
    font-weight: 500;
    color: #f0f3fa;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #2b2b43;
}

.input-group {
    margin-bottom: 12px;
}

.input-group label {
    display: block;
    font-size: 12px;
    color: #787b86;
    margin-bottom: 4px;
}

.input-group input[type="number"],
.input-group input[type="text"],
.input-group select {
    width: 100%;
    padding: 8px 12px;
    background-color: #2a2e39;
    border: 1px solid #363a45;
    border-radius: 4px;
    color: #d1d4dc;
    font-size: 13px;
}

.input-group input[type="number"]:hover,
.input-group input[type="text"]:hover,
.input-group select:hover {
    border-color: #4b5563;
}

.input-group input[type="number"]:focus,
.input-group input[type="text"]:focus,
.input-group select:focus {
    outline: none;
    border-color: #2962FF;
}

.input-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.loading,
.error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 14px;
}

#indicator-search:focus {
    outline: none;
    border-color: #2962FF;
}

#indicator-search::placeholder {
    color: #787b86;
}

.group-section {
    margin-bottom: 8px;
}

.group-header {
    display: flex;
    align-items: center;
    padding: 8px 8px;
    font-size: 13px;
    font-weight: 700;
    color: #f0f3fa;
    cursor: pointer;
    user-select: none;
    border-radius: 4px;
    border-bottom: 1px solid #2b2b43;
}

.group-header:hover {
    background-color: #2a2e39;
}

.group-header::before {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #d1d4dc;
    margin-right: 8px;
    transition: transform 0.15s;
}

.group-header.collapsed::before {
    transform: rotate(-90deg);
}

.group-count {
    margin-left: auto;
    font-size: 11px;
    font-weight: 400;
    color: #787b86;
}

.group-items.collapsed {
    display: none;
}

.category-group {
    margin-bottom: 4px;
}

.category-header {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    font-size: 12px;
    font-weight: 600;
    color: #787b86;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    user-select: none;
    border-radius: 4px;
}

.category-header:hover {
    background-color: #2a2e39;
}

.category-header::before {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #787b86;
    margin-right: 8px;
    transition: transform 0.15s;
}

.category-header.collapsed::before {
    transform: rotate(-90deg);
}

.category-count {
    margin-left: auto;
    font-size: 11px;
    font-weight: 400;
    color: #555;
}

.category-items.collapsed {
    display: none;
}

.indicator-item {
    padding: 5px 8px 5px 24px;
    font-size: 13px;
    cursor: pointer;
    border-radius: 4px;
    border-left: 3px solid transparent;
}

.indicator-item:hover {
    background-color: #2a2e39;
}

.indicator-item.active {
    border-left-color: #2962FF;
    background-color: rgba(41, 98, 255, 0.1);
    color: #f0f3fa;
}

.indicator-item.hidden {
    display: none;
}

.category-group.hidden {
    display: none;
}

.group-section.hidden {
    display: none;
}

.indicator-inputs h4 {
    font-size: 13px;
    font-weight: 500;
    color: #f0f3fa;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #2b2b43;
}

.input-group {
    margin-bottom: 12px;
}

.input-group label {
    display: block;
    font-size: 12px;
    color: #787b86;
    margin-bottom: 4px;
}

.input-group input[type="number"],
.input-group input[type="text"],
.input-group select {
    width: 100%;
    padding: 8px 12px;
    background-color: #2a2e39;
    border: 1px solid #363a45;
    border-radius: 4px;
    color: #d1d4dc;
    font-size: 13px;
}

.input-group input[type="number"]:hover,
.input-group input[type="text"]:hover,
.input-group select:hover {
    border-color: #4b5563;
}

.input-group input[type="number"]:focus,
.input-group input[type="text"]:focus,
.input-group select:focus {
    outline: none;
    border-color: #2962FF;
}

.input-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.loading,
.error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 14px;
}

.error {
    color: #ef5350;
}

/* Remove spinner from number inputs */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

/* Timeframe Dropdown Custom Style */
.tf-dropdown-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 0;
    font-size: 11px;
    font-weight: 600;
    color: #cbd5e1;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.tf-dropdown-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.15);
}

.tf-dropdown-item.active {
    background: rgba(99, 102, 241, 0.2) !important;
    color: #818cf8 !important;
    border-color: rgba(99, 102, 241, 0.4) !important;
}

.tf-dropdown-section-title {
    user-select: none;
}

/* ── Drawing Tools Panel ─────────────────────────────────────── */
.pro-drawing-panel {
    width: 200px;
    min-width: 200px;
    background: #1e222d;
    border-right: 1px solid #2a2e39;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    flex-shrink: 0;
}

.drw-panel-header {
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: #787b86;
    border-bottom: 1px solid #2a2e39;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.drw-clear-btn {
    background: transparent;
    border: none;
    color: #787b86;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 3px;
    line-height: 1;
}

.drw-clear-btn:hover {
    background: #f23645;
    color: #fff;
}

.drw-category {
    border-bottom: 1px solid #2a2e39;
}

.drw-category-header {
    padding: 9px 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: #787b86;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    transition: background 0.15s;
}

.drw-category-header:hover {
    background: #2a2e39;
}

.drw-arrow {
    font-size: 9px;
    transition: transform 0.2s;
}

.drw-category.collapsed .drw-arrow {
    transform: rotate(-90deg);
}

.drw-category.collapsed .drw-subcategory {
    display: none;
}

.drw-subcategory {
    padding: 2px 0;
}

.drw-subheader {
    padding: 5px 12px 4px 20px;
    font-size: 10px;
    color: #4a4e59;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.drw-tool-item {
    padding: 6px 12px 6px 28px;
    font-size: 13px;
    color: #d1d4dc;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: all 0.12s;
    user-select: none;
}

.drw-tool-item:hover {
    background: #2a2e39;
}

.drw-tool-item.active {
    background: #2962ff;
    color: #fff;
}

/* Sprint 1 — New tools (badge style) */
.drw-tool-new {
    background: rgba(156, 163, 175, 0.10);
    border-left: 2px solid #4b5563;
}

.drw-tool-new:hover {
    background: rgba(156, 163, 175, 0.18) !important;
}

.drw-tool-new::after {
    content: 'NEW';
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #6b7280;
    background: rgba(107, 114, 128, 0.25);
    border-radius: 3px;
    padding: 1px 4px;
    margin-left: auto;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Tool count badge in panel header */
#drw-tool-count {
    font-size: 9px;
    font-weight: 700;
    color: #4b5563;
    background: rgba(75, 85, 99, 0.20);
    border-radius: 8px;
    padding: 1px 6px;
    margin-left: 6px;
    letter-spacing: 0.3px;
}

/* Scroll hint shadow at bottom of panel */
.pro-drawing-panel {
    scroll-behavior: smooth;
}

/* Text Editor Modal */
.text-editor-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.text-editor-overlay.active {
    display: flex;
}

.text-editor-modal {
    background: #1e222d;
    border: 1px solid #2a2e39;
    border-radius: 8px;
    padding: 20px;
    min-width: 300px;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.text-editor-modal h3 {
    margin: 0 0 16px 0;
    font-size: 14px;
    font-weight: 500;
    color: #fff;
}

.text-editor-modal textarea {
    width: 100%;
    min-height: 80px;
    padding: 10px;
    background: #131722;
    border: 1px solid #2a2e39;
    border-radius: 4px;
    color: #d1d4dc;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    box-sizing: border-box;
}

.text-editor-modal textarea:focus {
    outline: none;
    border-color: #2962ff;
}

.text-editor-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

.text-editor-actions button {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.text-editor-actions .btn-cancel {
    background: #363a45;
    color: #d1d4dc;
}

.text-editor-actions .btn-cancel:hover {
    background: #4a4e59;
}

.text-editor-actions .btn-save {
    background: #2962ff;
    color: #fff;
}

.text-editor-actions .btn-save:hover {
    background: #1e53e4;
}

.text-editor-hint {
    font-size: 11px;
    color: #787b86;
    margin-top: 8px;
}
.widget-exch-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.widget-exch-logo {
    display: flex;
    align-items: center;
    justify-content: center;
}
.widget-exch-text {
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.widget-symbol-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.widget-header-right-single {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-right: 10px;
}
.new-pill {
    display: inline-flex;
    align-items: center;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    padding: 2px 6px;
    gap: 4px;
}
.new-pill .prec-btn, .new-pill .prec-label {
    background: transparent;
    border: none;
    color: #94a3b8;
    box-shadow: none;
    padding: 2px 4px;
}
.new-pill .prec-btn:hover, .new-pill .prec-label:hover {
    color: #fff;
}
.widget-btn-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s;
}
.widget-btn-circle:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}
.widget-header-right-single .widget-expand-btn {
    background: rgba(79, 70, 229, 0.15);
    border: 1px solid rgba(79, 70, 229, 0.3);
    color: #c7d2fe;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    margin-right: 0;
    flex: 0 0 auto;
}
.widget-header-right-single .widget-expand-btn:hover {
    background: rgba(79, 70, 229, 0.25);
    color: #fff;
}
.widget-close-price {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 2.2rem;
    font-weight: 400;
    line-height: 1;
    color: #fff;
    letter-spacing: -0.5px;
}
.widget-price-row {
    margin-top: 10px;
    margin-bottom: 5px;
    padding-left: 10px;
}
.widget-change {
    font-size: 1.1rem;
    font-weight: 700;
}
.widget-ohlc {
    display: none;
}
.widget-symbol {
    font-size: 1.15rem !important;
    font-weight: 700 !important;
    color: #fff !important;
    font-family: var(--font-sans, sans-serif) !important;
}
.widget-quote {
    color: #94a3b8 !important;
    font-size: 1rem !important;
    font-weight: 500 !important;
}
.widget-close-price {
    font-family: var(--font-sans, sans-serif) !important;
    font-size: 1.6rem !important;
    font-weight: 700 !important;
    letter-spacing: 0 !important;
}
.widget-btn-close.widget-btn-circle {
    background: rgba(239, 68, 68, 0.1) !important;
    border: 1px solid rgba(239, 68, 68, 0.3) !important;
    color: #ef4444 !important;
}
.widget-btn-close.widget-btn-circle:hover {
    background: rgba(239, 68, 68, 0.2) !important;
    color: #f87171 !important;
}
.widget-symbol {
    font-size: 1.15rem !important;
    font-weight: 700 !important;
}
.widget-exch-logo {
    flex-shrink: 0 !important;
    min-width: 20px !important;
}
.widget-btn-circle {
    flex-shrink: 0 !important;
    min-width: 26px !important;
    width: 26px !important;
    height: 26px !important;
}
.widget-close-price {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif !important;
    font-size: 1.35rem !important;
    font-weight: 500 !important;
    letter-spacing: -0.2px !important;
}
.widget-change {
    font-size: 0.95rem !important;
    font-weight: 500 !important;
}
.widget-symbol {
    font-size: 1.05rem !important;
    font-weight: 600 !important;
}
.widget-price-row {
    flex-shrink: 1 !important;
    min-width: 0 !important;
    white-space: nowrap !important;
    display: flex !important;
    align-items: baseline !important;
    gap: 6px !important;
}
.widget-exch-text {
    font-size: 0.8rem !important;
}
.widget-symbol {
    font-size: 0.92rem !important;
}
.widget-header {
    min-height: unset !important;
}
.widget-symbol-row {
    margin-bottom: 0px !important;
}
.widget-expand-btn {
    padding: 2px 8px !important;
}
.prec-btn, .prec-label {
    padding-top: 1px !important;
    padding-bottom: 1px !important;
}
.widget-btn-circle {
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
}

/* Adaptive chart widget header.
   Uses each widget's own width, so dense layouts can compact independently. */
.chart-widget {
    container-type: inline-size;
    --widget-action-btn-width: 102px;
    --widget-precision-width: 56px;
}

.chart-widget .widget-top-bar {
    min-width: 0;
}

.chart-widget .widget-tool-group {
    min-width: 0;
    flex-wrap: nowrap;
    overflow: hidden;
}

.chart-widget .widget-timeframe-control {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
    height: 24px;
    min-width: 0;
    padding: 0 5px;
    border: 1px solid rgba(99, 102, 241, 0.28);
    border-radius: 5px;
    background: rgba(15, 23, 42, 0.78);
}

.chart-widget .widget-timeframe-label {
    color: var(--text-muted);
    font-size: 0.58rem;
    font-weight: 700;
    line-height: 1;
}

.chart-widget .widget-tf-select {
    width: 48px;
    min-width: 0;
    height: 20px;
    padding: 0 16px 0 4px;
    border: 0;
    border-radius: 4px;
    background: rgba(99, 102, 241, 0.2);
    color: #f8fafc;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
    color-scheme: dark;
    cursor: pointer;
    outline: none;
}

.chart-widget .widget-tf-select:focus {
    box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.65);
}

.chart-widget .widget-tf-select option {
    background: #111827;
    color: #e5e7eb;
}

.chart-widget .widget-expand-btn {
    min-width: 0;
    white-space: nowrap;
    align-items: center;
    line-height: 1;
}

.chart-widget .widget-btn-view,
.chart-widget .widget-btn-pro {
    width: var(--widget-action-btn-width);
    justify-content: center;
    overflow: hidden;
}

.chart-widget .widget-action-label {
    display: inline-flex;
    align-items: center;
    line-height: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chart-widget .new-pill {
    width: var(--widget-precision-width);
    justify-content: center;
    overflow: hidden;
    gap: 0 !important;
}

.chart-widget .new-pill .prec-btn {
    padding-left: 2px !important;
    padding-right: 2px !important;
}

.chart-widget .new-pill .prec-label {
    min-width: 30px !important;
}

.chart-widget .widget-expand-btn .btn-svg-icon {
    flex: 0 0 auto;
    display: block;
}

.chart-widget .widget-action-label,
.chart-widget .widget-symbol,
.chart-widget .widget-quote,
.chart-widget .widget-exch-text,
.chart-widget .widget-close-price,
.chart-widget .widget-change {
    letter-spacing: 0 !important;
}

@container (max-width: 280px) {
    .chart-widget .widget-header {
        --widget-action-btn-width: 98px;
        --widget-precision-width: 42px;
    }

    .chart-widget .widget-header {
        padding: 3px 6px !important;
        gap: 1px !important;
    }

    .chart-widget .widget-top-bar {
        gap: 5px !important;
    }

    .chart-widget .widget-tool-group {
        gap: 4px !important;
        padding-right: 20px;
    }

    .chart-widget .widget-expand-btn {
        padding: 2px 5px !important;
        gap: 3px !important;
        font-size: 0.66rem !important;
        border-radius: 5px !important;
    }

    .chart-widget .widget-timeframe-control {
        height: 22px;
        gap: 2px;
        padding: 0 3px;
    }

    .chart-widget .widget-timeframe-label {
        display: none;
    }

    .chart-widget .widget-tf-select {
        width: 45px;
        height: 19px;
        padding-left: 3px;
        font-size: 0.62rem;
    }

    .chart-widget .new-pill {
        padding: 1px 2px !important;
        gap: 0 !important;
    }

    .chart-widget .prec-btn,
    .chart-widget .prec-label {
        font-size: 0.62rem !important;
        padding: 1px 1px !important;
    }

    .chart-widget .prec-label {
        min-width: 24px !important;
    }

    .chart-widget .widget-btn-close.widget-btn-circle {
        position: absolute;
        top: 4px;
        right: 4px;
        z-index: 4;
        width: 18px !important;
        height: 18px !important;
        min-width: 18px !important;
        background: rgba(239, 68, 68, 0.16) !important;
    }

    .chart-widget .widget-btn-close.widget-btn-circle svg {
        width: 10px !important;
        height: 10px !important;
    }

    .chart-widget .widget-ticker-bar {
        gap: 4px !important;
    }

    .chart-widget .widget-exch-text {
        font-size: 0.66rem !important;
    }

    .chart-widget .widget-market-badge {
        font-size: 0.48rem !important;
        padding: 1px 3px !important;
    }

    .chart-widget .widget-symbol {
        font-size: 0.82rem !important;
    }

    .chart-widget .widget-quote {
        font-size: 0.72rem !important;
    }

    .chart-widget .widget-close-price {
        font-size: 1.02rem !important;
    }

    .chart-widget .widget-change {
        font-size: 0.7rem !important;
    }
}

@container (max-width: 240px) {
    .chart-widget .widget-header {
        --widget-action-btn-width: 46px;
        --widget-precision-width: 46px;
    }

    .chart-widget .widget-btn-view .widget-action-label {
        font-size: 0;
    }

    .chart-widget .widget-btn-view .widget-action-label::after {
        content: "MTF";
        font-size: 0.66rem;
    }

    .chart-widget .widget-btn-pro .widget-action-label {
        font-size: 0;
    }

    .chart-widget .widget-btn-pro .widget-action-label::after {
        content: "Pro";
        font-size: 0.66rem;
    }
}

@container (max-width: 200px) {
    .chart-widget .widget-header {
        --widget-action-btn-width: 24px;
    }

    .chart-widget .widget-header {
        padding: 3px 5px !important;
    }

    .chart-widget .widget-tool-group {
        gap: 3px !important;
        padding-right: 18px;
    }

    .chart-widget .widget-expand-btn {
        height: 22px;
        padding: 0 !important;
        justify-content: center;
    }

    .chart-widget .widget-expand-btn .widget-action-label,
    .chart-widget .widget-expand-btn .widget-action-label::after {
        display: none;
    }

    .chart-widget .widget-expand-btn .btn-svg-icon {
        width: 13px !important;
        height: 13px !important;
        margin: 0 !important;
    }

    .chart-widget .new-pill {
        display: none !important;
        height: 22px;
        padding: 0 3px !important;
    }

    .chart-widget .widget-timeframe-control {
        display: none !important;
    }

    .chart-widget .prec-btn {
        padding: 0 2px !important;
    }

    .chart-widget .prec-label {
        min-width: 21px !important;
        max-width: 25px;
        overflow: hidden;
    }

    .chart-widget .widget-ticker-bar {
        gap: 2px !important;
    }

    .chart-widget .widget-market-badge,
    .chart-widget .widget-quote {
        display: none !important;
    }

    .chart-widget .widget-symbol {
        font-size: 0.74rem !important;
    }

    .chart-widget .widget-price-row {
        gap: 2px !important;
    }

    /* Keep both absolute and percentage change visible on narrow widgets. */
    .chart-widget .widget-change {
        display: inline !important;
        font-size: clamp(0.68rem, 5.2cqw, 0.82rem) !important;
        line-height: 1.1 !important;
        flex: 0 1 auto;
        min-width: 0;
    }

    .chart-widget .widget-price-row {
        column-gap: 3px !important;
        overflow: visible !important;
    }

    .chart-widget .widget-close-price {
        font-size: clamp(0.92rem, 7.2cqw, 1.12rem) !important;
    }
}

@container (max-width: 160px) {
    .chart-widget .widget-top-bar {
        gap: 2px !important;
    }

    .chart-widget .widget-tool-group {
        gap: 2px !important;
        padding-right: 16px;
    }

    /* Also hide exchange text label at very small sizes */
    .chart-widget .widget-exch-text {
        display: none !important;
    }

    /* At the smallest supported width, wrap instead of dropping market data. */
    .chart-widget .widget-price-row {
        flex-wrap: wrap !important;
        row-gap: 0 !important;
        align-items: flex-start !important;
    }

    .chart-widget .widget-change {
        flex-basis: 100%;
    }
}

/* ── Add Text Tooltip on Drawing Hover ──────────────────────────────────── */
.drw-add-text-tooltip {
    position: fixed;
    display: none;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: #1e222d;
    border: 1px solid #2a2e39;
    border-radius: 6px;
    color: #2962ff;
    font-size: 11px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    pointer-events: all;
    z-index: 9999;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    white-space: nowrap;
    animation: drwTooltipFadeIn 0.12s ease;
    user-select: none;
}
.drw-add-text-tooltip:hover {
    background: #2962ff;
    color: #fff;
    border-color: #2962ff;
}
@keyframes drwTooltipFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── TV-style Right Sidebar Column ────────────────────────────────────────── */
.tv-right-sidebar {
    width: 48px;
    background: #0f172a;
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 8px;
    flex-shrink: 0;
    z-index: 30;
}

/* Keep ProChart, watchlist and the reopen rail inside one bounded flex row.
   width:0 lets the chart consume only the remaining space instead of using
   the canvas' intrinsic width and pushing the drawer/rail outside the viewport. */
.pro-chart-main-container {
    flex: 1 1 0;
    width: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}
#page-pro-chart #pro-chart-container {
    flex: 1 1 0 !important;
    width: 0;
    min-width: 0;
}
.right-sidebar-btn {
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    border-radius: 6px;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    margin-bottom: 8px;
}
.right-sidebar-btn:hover {
    color: #cbd5e1;
    background: rgba(255, 255, 255, 0.05);
}
.right-sidebar-btn.active {
    color: #6366f1;
    background: rgba(99, 102, 241, 0.1);
}

/* ── TV-style Watchlist Drawer Panel ───────────────────────────────────────── */
.tv-watchlist-panel {
    width: 300px;
    background: #0f172a;
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s;
    z-index: 25;
    position: relative;
    overflow: hidden;
}
.tv-watchlist-panel.resizing {
    transition: none !important;
}
.tv-watchlist-panel.closed {
    width: 0 !important;
    border-left: none !important;
}

/* Vertical resize handle on the left edge of the panel */
.tv-watchlist-resizer {
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    cursor: col-resize;
    background: transparent;
    z-index: 30;
    transition: background 0.15s;
}
.tv-watchlist-resizer:hover,
.tv-watchlist-resizer.resizing {
    background: var(--accent-primary, #3b82f6);
}

.watchlist-panel-header {
    height: 48px;
    padding: 0 12px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.watchlist-dropdown-wrap {
    position: relative;
    display: inline-block;
}
.watchlist-dropdown-btn {
    background: none;
    border: none;
    color: #e2e8f0;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.15s;
}
.watchlist-dropdown-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.watchlist-menu-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 200px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    z-index: 100;
    margin-top: 4px;
    padding: 6px 0;
}
.wl-menu-section a {
    display: block;
    padding: 8px 14px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 12px;
    transition: color 0.15s, background 0.15s;
}
.wl-menu-section a:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}
.wl-menu-divider {
    height: 1px;
    background: #334155;
    margin: 4px 0;
}
.wl-menu-item-active {
    color: #6366f1 !important;
    font-weight: 600;
}

.watchlist-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}
.wl-header-btn {
    width: 28px;
    height: 28px;
    background: none;
    border: none;
    border-radius: 4px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}
.wl-header-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.watchlist-panel-body {
    flex: 1;
    overflow-y: auto;
}

.wl-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    table-layout: fixed;
}
.wl-table th {
    color: #64748b;
    font-weight: 500;
    padding: 10px 6px;
    border-bottom: 1px solid var(--border-color);
    font-size: 11px;
    user-select: none;
}
.wl-table td {
    padding: 10px 6px;
    color: #cbd5e1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.wl-table th:nth-child(1),
.wl-table td:nth-child(1) {
    width: 33%;
    padding-left: 10px;
    padding-right: 8px;
}
.wl-table th:nth-child(2),
.wl-table td:nth-child(2) {
    width: 24%;
}
.wl-table th:nth-child(3),
.wl-table td:nth-child(3) {
    width: 20%;
}
.wl-table th:nth-child(4),
.wl-table td:nth-child(4) {
    width: 17%;
    padding-left: 1px;
    padding-right: 1px;
}
.wl-table th:nth-child(5),
.wl-table td:nth-child(5) {
    width: 6%;
    padding-left: 0;
    padding-right: 0;
}
.wl-row:hover {
    background: rgba(255, 255, 255, 0.02);
}
.wl-row.active {
    background: rgba(99, 102, 241, 0.05);
    border-left: 2px solid #6366f1;
}

.wl-col-sym {
    font-weight: 600;
    color: #f1f5f9;
}
.wl-col-market-line {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 3px;
    width: 100%;
    padding-left: 13px;
    margin-top: 2px;
    line-height: 1.2;
}
.wl-col-exch {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.2px;
}
.wl-col-market {
    color: #64748b;
    font-size: 10px;
}
.wl-col-price {
    font-family: monospace;
    font-size: 11px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    transition: background-color 0.4s;
}
.wl-col-chg {
    font-family: monospace;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}
.wl-col-pct {
    font-family: monospace;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.wl-row-remove {
    opacity: 0;
    cursor: pointer;
    color: #64748b;
    background: none;
    border: none;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s, color 0.15s;
    width: 100%;
    height: 100%;
}
.wl-row:hover .wl-row-remove {
    opacity: 1;
}
.wl-row-remove:hover {
    color: #ef4444 !important;
}

/* Drag-and-drop reorder */
.wl-drag-handle {
    display: inline-flex;
    align-items: center;
    cursor: grab;
    color: #334155;
    font-size: 13px;
    margin-right: 6px;
    vertical-align: middle;
    transition: color 0.15s;
    user-select: none;
    letter-spacing: -1px;
}
.wl-row:hover .wl-drag-handle {
    color: #64748b;
}

/* Guests can inspect and use the shared default list, but personal list
   mutations become available only after authentication. */
.tv-watchlist-panel.watchlist-read-only .watchlist-header-actions,
.tv-watchlist-panel.watchlist-read-only .watchlist-menu-dropdown > .wl-menu-section:first-child,
.tv-watchlist-panel.watchlist-read-only .watchlist-menu-dropdown > .wl-menu-section:first-child + .wl-menu-divider,
.tv-watchlist-panel.watchlist-read-only .wl-row-remove,
.tv-watchlist-panel.watchlist-read-only .wl-drag-handle,
.tv-watchlist-panel.watchlist-read-only .wl-table th:last-child,
.tv-watchlist-panel.watchlist-read-only .wl-table td:last-child {
    display: none;
}
.wl-row-dragging {
    opacity: 0.4;
    background: rgba(99, 102, 241, 0.08) !important;
}
.wl-row-drag-over {
    border-top: 2px solid #6366f1 !important;
    background: rgba(99, 102, 241, 0.06) !important;
}
.wl-row-drag-over td {
    border-top: none;
}
.wl-table tbody.drag-active .wl-row {
    transition: none;
}

/* Price ticking color-flash keyframes */
@keyframes flash-green {
    0% { background-color: rgba(16, 185, 129, 0.25); }
    100% { background-color: transparent; }
}
@keyframes flash-red {
    0% { background-color: rgba(239, 68, 68, 0.25); }
    100% { background-color: transparent; }
}
.flash-green { animation: flash-green 0.5s ease-out; }
.flash-red { animation: flash-red 0.5s ease-out; }

.text-up { color: #10b981 !important; }
.text-down { color: #ef4444 !important; }
.text-flat { color: #64748b !important; }
.hidden { display: none !important; }

/* ═══════════════════════════════════════════════════════════════════════════
   AUTO-SCALING WIDGET TYPOGRAPHY
   Uses CSS clamp() + cqi (container query inline size) units so text
   proportionally shrinks as the widget narrows — no hard breakpoints, no
   ellipsis, no clipping. Works for watchlist panel, sidebar, any layout.
   These rules MUST come last to override all @container breakpoint rules above.
   Formula: clamp(min, preferred_cqi, max)
   Calibrated for typical widget range: 140px – 600px wide.
═══════════════════════════════════════════════════════════════════════════ */

/* Exchange name: BINANCE / BYBIT / OKX */
.chart-widget .widget-exch-text {
    font-size: clamp(0.48rem, 3.6cqi, 0.82rem) !important;
    white-space: nowrap !important;
    overflow: visible !important;
}

/* Market badge: SPOT / PERP */
.chart-widget .widget-market-badge {
    font-size: clamp(0.38rem, 2.8cqi, 0.72rem) !important;
    padding: 0 clamp(1px, 0.5cqi, 4px) !important;
    white-space: nowrap !important;
}

/* Coin symbol: BTC / ETH etc. */
.chart-widget .widget-symbol {
    font-size: clamp(0.58rem, 4.4cqi, 1.05rem) !important;
    white-space: nowrap !important;
}

/* Quote currency: /USDT */
.chart-widget .widget-quote {
    font-size: clamp(0.5rem, 3.8cqi, 0.95rem) !important;
}

/* Close price value */
.chart-widget .widget-close-price {
    font-size: clamp(0.62rem, 5.2cqi, 1.35rem) !important;
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: clip !important;
}

/* Change % and absolute change */
.chart-widget .widget-change {
    font-size: clamp(0.46rem, 3.4cqi, 0.95rem) !important;
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: clip !important;
}
