/* ============================================================================
   SMMA Dashboard Styles
   Mustard Analytics Theme
   ============================================================================ */

:root {
    /* Brand Colors - Mustard Analytics */
    --bg-primary: #1A1A1A;           /* Charcoal Black - primary bg */
    --bg-secondary: #1A1A1A;         /* Charcoal Black - same for consistency */
    --bg-tertiary: #252525;          /* Slightly lighter for layers */
    --text-primary: #FFFFFF;
    --text-secondary: #A0A0A0;
    --text-muted: #666666;
    --accent: #E4A700;               /* Mustard Yellow */
    --accent-hover: #FFB800;
    --accent-dim: rgba(228, 167, 0, 0.1);
    --success: #00C853;
    --danger: #FF5252;
    --border: #333333;
    --border-hover: #444444;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.2s ease;

    /* Chart Colors */
    --smma-line: #ffffff;            /* SMMA trendline color */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 20px;
}

/* ============================================================================
   Header
   ============================================================================ */

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 28px;
}

.logo h1 {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent) 0%, #FFD54F 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Auto Refresh Header Controls */
.auto-refresh-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-right: 8px;
}

/* Split Screen Mode Styles */
body.split-mode-active #fullscreenChartTitle {
    display: none;
}

body.split-mode-active .chart-fullscreen-header {
    padding: 8px 16px;
    min-height: 40px;
}

body.split-mode-active .fullscreen-header-actions .watchlist-dropdown-btn,
body.split-mode-active .fullscreen-header-actions .save-layout-btn,
body.split-mode-active .fullscreen-header-actions .split-screen-btn,
body.split-mode-active .fullscreen-header-actions .minimize-btn {
    font-size: 0.8rem;
    padding: 4px 8px;
}

body.split-mode-active .watchlist-dropdown-btn .star-icon {
    font-size: 14px;
}

body.split-mode-active .watchlist-dropdown-btn .count-badge {
    font-size: 10px;
    padding: 1px 4px;
}

/* Chart Countdown Overlay */
.chart-countdown {
    position: absolute;
    top: 10px;
    right: 60px; /* Positioned over the price scale area */
    z-index: 20;
    font-family: 'Roboto Mono', monospace;
    font-size: 12px;
    color: #fff;
    background: rgba(255, 82, 82, 0.8); /* Red background */
    padding: 2px 6px;
    border-radius: 4px;
    pointer-events: none;
    font-weight: bold;
}

.split-chart-wrapper {
    position: relative;
}

.toggle-compact {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
}

.toggle-compact input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

.toggle-compact:has(input:checked) span {
    color: var(--accent);
}

.interval-select {
    padding: 6px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
}

.interval-select:focus {
    outline: none;
    border-color: var(--accent);
}

.countdown-compact {
    display: none;
    padding: 4px 12px;
    background: var(--accent-dim);
    border: 1px solid var(--accent);
    border-radius: 4px;
}

.countdown-compact.active {
    display: block;
}

.countdown-compact span {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

/* ============================================================================
   Buttons
   ============================================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: var(--accent);
    color: var(--bg-primary);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.btn-icon {
    font-size: 16px;
}

/* ============================================================================
   Header Stats (Compact)
   ============================================================================ */

.header-stats {
    display: flex;
    align-items: center;
    gap: 24px;
    margin: 0 40px; /* Spacing from logo and actions */
    flex: 1; /* Take available space */
    justify-content: center;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.stat-value-sm {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.2;
}

.stat-label-sm {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-seperator {
    width: 1px;
    height: 24px;
    background: var(--border);
}

/* Responsive adjustment for header stats */
@media (max-width: 1024px) {
    .header-stats {
        margin: 0 20px;
        gap: 16px;
    }
}

/* ============================================================================
   Main Content Layout (Filters + Symbol Table)
   ============================================================================ */

.main-content {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

/* ============================================================================
   Bottom Section (Chart + SMMA Touches on row 1, Signal tables on row 2)
   ============================================================================ */

.bottom-section {
    display: grid;
    grid-template-columns: 2fr 1fr;
    grid-template-rows: auto auto;
    gap: 20px;
    margin-bottom: 20px;
}

/* Chart on left of first row */
.chart-panel {
    grid-column: 1;
    grid-row: 1;
}

/* SMMA Touches on right of first row */
.touches-panel {
    grid-column: 2;
    grid-row: 1;
}

/* Signal and Squeeze panels share second row */
.signal-touches-panel {
    grid-column: 1;
    grid-row: 2;
}

.squeeze-smma-panel {
    grid-column: 2;
    grid-row: 2;
}

/* Signal Touches Panel specific styles */
.signal-touches-panel .signal-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
}

.signal-badge.bull {
    background: rgba(0, 200, 83, 0.15);
    color: #00C853;
}

.signal-badge.bear {
    background: rgba(255, 82, 82, 0.15);
    color: #FF5252;
}

.signal-badge.c6 {
    background: rgba(0, 255, 0, 0.15);
    color: #00FF00;
}

.signal-badge.c2 {
    background: rgba(255, 0, 0, 0.15);
    color: #FF5252;
}

.signal-touches-view-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.signal-touches-view-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.signal-touches-view-btn.active {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

/* Squeeze/SMMA Signal Panel styles */
.squeeze-smma-panel .squeeze-dot-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
}

.squeeze-dot-badge.squeeze-green {
    background: rgba(0, 255, 0, 0.15);
    color: #00FF00;
}

.squeeze-dot-badge.squeeze-red {
    background: rgba(255, 0, 0, 0.15);
    color: #FF0000;
}

.squeeze-smma-view-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.squeeze-smma-view-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.squeeze-smma-view-btn.active {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

/* ============================================================================
   Filters Panel
   ============================================================================ */

.filters-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.filters-panel h3 {
    font-size: 16px;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.filter-group {
    margin-bottom: 16px;
}

.filter-group label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group input,
.filter-group select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    transition: var(--transition);
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Auto Refresh Section */
.filter-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.filter-section h4 {
    font-size: 14px;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.toggle-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

.toggle-text {
    font-size: 13px;
    color: var(--text-primary);
    text-transform: none;
    letter-spacing: 0;
}

.countdown-display {
    display: none;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    margin-top: 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.countdown-display.active {
    display: flex;
}

.countdown-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.countdown-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

/* ============================================================================
   Table Panel
   ============================================================================ */

.table-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

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

.table-header h3 {
    font-size: 16px;
}

.table-header h3 span {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 400;
}

.loading-indicator {
    display: none;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 13px;
}

.loading-indicator.active {
    display: flex;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.table-wrapper {
    max-height: 500px;
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--bg-tertiary);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: var(--transition);
    position: sticky;
    top: 0;
    z-index: 1;
}

th:hover {
    color: var(--accent);
}

tr {
    cursor: pointer;
    transition: var(--transition);
}

tr:hover {
    background: var(--accent-dim);
}

tr.selected {
    background: var(--accent-dim);
    border-left: 3px solid var(--accent);
}

td {
    font-size: 14px;
}

.symbol-name {
    font-weight: 600;
    color: var(--text-primary);
}

/* Watchlist Star Icon */
.symbol-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.watchlist-star {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    cursor: pointer;
    color: var(--text-muted);
    opacity: 0.4;
    transition: var(--transition);
    flex-shrink: 0;
}

.watchlist-star:hover {
    opacity: 1;
    transform: scale(1.15);
}

.watchlist-star.active {
    color: var(--accent);
    opacity: 1;
}

.watchlist-star svg {
    width: 16px;
    height: 16px;
}

.watchlist-star.active svg {
    fill: var(--accent);
}

.price-positive {
    color: var(--success);
}

.price-negative {
    color: var(--danger);
}

.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-touching {
    background: rgba(228, 167, 0, 0.2);
    color: var(--accent);
}

.status-above {
    background: rgba(0, 200, 83, 0.2);
    color: var(--success);
}

.status-below {
    background: rgba(255, 82, 82, 0.2);
    color: var(--danger);
}

/* ============================================================================
   Chart Panel
   ============================================================================ */

.chart-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.chart-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.chart-info {
    display: flex;
    gap: 20px;
}

.chart-info span {
    font-size: 14px;
    color: var(--text-secondary);
}

#chartPrice {
    font-weight: 600;
    color: var(--text-primary);
}

#chartSmma {
    color: var(--accent);
}

/* ============================================================================
   Chart Wrapper & Resizable Layout
   ============================================================================ */

.chart-wrapper {
    display: flex;
    flex-direction: column;
    height: 600px; /* Total height for chart area */
    overflow: hidden;
    padding: 10px;
    padding-bottom: 0;
}

#chartContainer {
    flex: 1 1 auto;
    min-height: 100px;
}

#squeezeContainer {
    flex: 0 0 auto;
    height: 150px;
    min-height: 60px;
    width: 100%;
}

/* Resizable Divider */
.chart-resizer {
    flex: 0 0 8px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    cursor: ns-resize;
    transition: background 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-resizer::after {
    content: '';
    width: 40px;
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    transition: background 0.15s ease;
}

.chart-resizer:hover,
.chart-resizer:active {
    background: var(--accent-dim);
}

.chart-resizer:hover::after,
.chart-resizer:active::after {
    background: var(--accent);
}

/* Prevent text selection during resize drag */
.chart-resizing {
    cursor: ns-resize !important;
    user-select: none;
}

.chart-resizing * {
    cursor: ns-resize !important;
    user-select: none;
}

.chart-legend {
    display: flex;
    gap: 20px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-secondary);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-color {
    width: 16px;
    height: 3px;
    border-radius: 2px;
}

.legend-color.smma-legend {
    background: var(--smma-line);
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
}

/* ============================================================================
   Touches Panel
   ============================================================================ */

/* Scroll to Latest Button */
.scroll-to-latest-btn {
    position: absolute;
    bottom: 170px; /* Above squeeze container */
    right: 100px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    opacity: 0;
    visibility: hidden;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.scroll-to-latest-btn.visible {
    opacity: 1;
    visibility: visible;
}

.scroll-to-latest-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-primary);
    transform: scale(1.05);
}

.scroll-to-latest-btn svg {
    pointer-events: none;
}

/* Ensure chart-panel has relative positioning for button placement */
.chart-panel {
    position: relative;
}

/* Fullscreen scroll-to-latest button positioning */
.chart-fullscreen-content {
    position: relative;
}

.scroll-to-latest-btn.fullscreen-scroll-btn {
    bottom: 220px; /* Position above fullscreen squeeze container */
    right: 120px;
}

.touches-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.touches-panel h3 {
    font-size: 16px;
    margin: 0;
}

.touches-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.touches-header h3 span {
    font-weight: normal;
    color: var(--text-secondary);
}

.touches-view-toggle {
    display: flex;
    gap: 4px;
}

.touches-view-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.touches-view-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.touches-view-btn.active {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

.touches-list {
    max-height: 450px;
    overflow-y: auto;
}

.touches-list.card-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.touch-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    transition: var(--transition);
    cursor: pointer;
}

.touch-item:hover {
    border-color: var(--accent);
}

/* Touch item inner layout for star icon */
.touch-item-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    cursor: pointer;
}

/* Watchlist star in touch items (card view) */
.touch-item .watchlist-star {
    width: 18px;
    height: 18px;
}

.touch-item .watchlist-star svg {
    width: 14px;
    height: 14px;
}

/* Update pulse animation for touch items */
.touch-item.updated {
    animation: touchPulse 0.6s ease-out;
    border-left: 3px solid var(--accent);
}

@keyframes touchPulse {
    0% {
        background: rgba(228, 167, 0, 0.3);
        transform: scale(1.01);
    }
    100% {
        background: var(--bg-tertiary);
        transform: scale(1);
    }
}

.touch-symbol {
    font-weight: 600;
    color: var(--accent);
}

.touch-info {
    font-size: 13px;
    color: var(--text-secondary);
    margin-left: 8px;
}

.touch-time {
    font-size: 12px;
    color: var(--text-muted);
}

/* Touches Table View */
.touches-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.touches-table th,
.touches-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.touches-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
}

.touches-table th:hover {
    color: var(--accent);
}

.touches-table tr:hover td {
    background: var(--bg-tertiary);
}

/* Watchlist star in touches tables */
.touches-table .symbol-cell {
    display: flex;
    align-items: center;
    gap: 6px;
}

.touches-table .watchlist-star {
    width: 18px;
    height: 18px;
}

.touches-table .watchlist-star svg {
    width: 14px;
    height: 14px;
}

/* Update pulse animation for table rows */
.touches-table tr.updated td {
    animation: touchPulse 0.6s ease-out;
    border-left: 3px solid var(--accent);
}

.empty-state {
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
    padding: 20px;
}

/* ============================================================================
   Scrollbar
   ============================================================================ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================================================
   Responsive
   ============================================================================ */

@media (max-width: 1400px) {
    .main-content {
        grid-template-columns: 200px 1fr;
    }

    .bottom-section {
        grid-template-columns: 2fr 1fr;
    }

    /* Enable horizontal scroll for tables */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
    }

    /* Touches panels scroll */
    .touches-panel,
    .signal-touches-panel,
    .squeeze-smma-panel {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .touches-list {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .touches-table {
        min-width: 400px;
    }
}


@media (max-width: 1200px) {
    .bottom-section {
        grid-template-columns: 1fr 1fr;
    }

    /* Chart spans full width on top */
    .chart-panel {
        grid-column: 1 / -1;
        grid-row: 1;
        min-height: 400px;
    }

    /* SMMA Touches and Signal Touches on second row */
    .touches-panel {
        grid-column: 1;
        grid-row: 2;
    }

    .signal-touches-panel {
        grid-column: 2;
        grid-row: 2;
    }

    /* Squeeze panel full width on third row */
    .squeeze-smma-panel {
        grid-column: 1 / -1;
        grid-row: 3;
    }

    /* Enable horizontal scroll for tables */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 550px;
    }

    /* Touches panels scroll */
    .touches-panel,
    .signal-touches-panel,
    .squeeze-smma-panel {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .touches-list {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .touches-table {
        min-width: 380px;
    }
}

@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .bottom-section {
        grid-template-columns: 1fr;
    }

    /* Chart still on top with its own row */
    .chart-panel {
        grid-column: 1;
        grid-row: 1;
        min-height: 350px;
    }

    /* Each touches panel gets its own row */
    .touches-panel {
        grid-column: 1;
        grid-row: 2;
    }

    .signal-touches-panel {
        grid-column: 1;
        grid-row: 3;
    }

    .squeeze-smma-panel {
        grid-column: 1;
        grid-row: 4;
    }

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

    .header {
        flex-direction: column;
        gap: 16px;
    }

    /* Enable horizontal scroll for all tables and panels */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 500px;
    }

    .touches-panel,
    .signal-touches-panel,
    .squeeze-smma-panel {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .touches-list {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .touches-table {
        min-width: 350px;
    }

    /* Chart header ensure actions visible */
    .chart-header {
        flex-wrap: wrap;
        gap: 8px;
    }

    .chart-header h3 {
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}


/* ============================================================================
   Table Filter Row
   ============================================================================ */

.filter-row td {
    background: var(--bg-tertiary);
    padding: 8px 12px;
    border-bottom: 2px solid var(--border);
}

.filter-cell {
    display: flex;
    gap: 4px;
    align-items: center;
}

.filter-op {
    width: 42px;
    padding: 4px 2px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 12px;
    cursor: pointer;
    text-align: center;
}

.filter-op:focus {
    outline: none;
    border-color: var(--accent);
}

.filter-val {
    width: 60px;
    padding: 4px 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 12px;
}

.filter-val:focus {
    outline: none;
    border-color: var(--accent);
}

.filter-val::placeholder {
    color: var(--text-muted);
}

/* Hide number input spinners */
.filter-val::-webkit-outer-spin-button,
.filter-val::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.filter-val[type=number] {
    -moz-appearance: textfield;
}

/* Touches Table Filter Row */
.touches-filter-row td {
    background: var(--bg-tertiary);
    padding: 6px 8px;
    border-bottom: 2px solid var(--border);
}

.touches-filter-row .filter-cell {
    display: flex;
    gap: 3px;
    align-items: center;
}

.touches-filter-row .filter-op {
    width: 36px;
    padding: 3px 2px;
    font-size: 11px;
}

.touches-filter-row .filter-val {
    width: 50px;
    padding: 3px 4px;
    font-size: 11px;
}

/* Clear Filters Button */
.clear-filters-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: 6px;
    padding: 0;
    background: rgba(255, 82, 82, 0.2);
    border: 1px solid var(--danger);
    border-radius: 50%;
    color: var(--danger);
    font-size: 10px;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
    vertical-align: middle;
}

.clear-filters-btn:hover {
    background: var(--danger);
    color: white;
}

/* ============================================================================
   Squeeze Pro Indicator
   ============================================================================ */

#squeezeContainer {
    height: 120px;
    padding: 0 10px;
    margin-top: 4px;
}

.squeeze-legend {
    flex-wrap: wrap;
    gap: 12px 20px;
    border-top: none;
    padding-top: 8px;
}

.squeeze-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1px solid var(--border);
}

.squeeze-dot.green {
    background: #00FF00;
    border-color: #00FF00;
}

.squeeze-dot.black {
    background: #000000;
    border-color: #666666;
}

.squeeze-dot.red {
    background: #FF0000;
    border-color: #FF0000;
}


.squeeze-dot.orange {
    background: #FFA500;
    border-color: #FFA500;
}

/* ==========================================================================
   Context Menu
   ========================================================================== */
.context-menu {
    position: fixed;
    z-index: 10000; /* Above fullscreen modal (9999) */
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    padding: 6px 0;
    min-width: 220px;
    display: none; /* Hidden by default */
}

.context-menu-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.context-menu-item {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    transition: background-color 0.15s ease;
}

.context-menu-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.context-menu-item .check-icon {
    width: 20px;
    margin-right: 8px;
    color: var(--color-primary);
    font-weight: bold;
    display: inline-block;
    text-align: center;
}

.context-menu-separator {
    height: 1px;
    background-color: var(--border);
    margin: 6px 0;
}

/* Symbol Context Menu Icon */
.context-menu-item .menu-icon {
    width: 20px;
    margin-right: 8px;
    font-size: 14px;
    display: inline-block;
    text-align: center;
}

/* Symbol row highlight when context menu is open */
#symbolTableBody tr.context-menu-active,
.touches-table tr.context-menu-active {
    background: var(--bg-tertiary);
    border-color: var(--accent);
}

/* Touch item highlight when context menu is open */
.touch-item.context-menu-active {
    background: var(--bg-tertiary);
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

/* Close button for new-tab mode (replaces minimize button) */
.close-tab-btn {
    margin-left: auto;
    background: rgba(255, 82, 82, 0.1) !important;
    border-color: rgba(255, 82, 82, 0.3) !important;
}

.close-tab-btn:hover {
    background: rgba(255, 82, 82, 0.2) !important;
    border-color: var(--danger) !important;
    color: var(--danger) !important;
}

/* ============================================================================
   Chart Action Buttons & Fullscreen Modal
   ============================================================================ */

/* Chart action button (maximize/minimize) */
.chart-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    margin-left: 12px;
}

.chart-action-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
}

.chart-action-btn svg {
    width: 16px;
    height: 16px;
}

/* Fullscreen Modal */
.chart-fullscreen-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-primary);
    z-index: 9999;
    display: none;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.chart-fullscreen-modal.active {
    display: flex;
    opacity: 1;
}

.chart-fullscreen-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 20px;
}

.chart-fullscreen-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.chart-fullscreen-header h3 {
    font-size: 22px;
    font-weight: 600;
    color: var(--accent);
}

/* Fullscreen title section with star */
.fullscreen-title-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Fullscreen Watchlist Star */
.fullscreen-watchlist-star {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    cursor: pointer;
    color: var(--text-muted);
    opacity: 0.5;
    transition: var(--transition);
    border-radius: var(--radius-sm);
}

.fullscreen-watchlist-star:hover {
    opacity: 1;
    transform: scale(1.15);
    background: rgba(228, 167, 0, 0.1);
}

.fullscreen-watchlist-star.active {
    color: var(--accent);
    opacity: 1;
}

.fullscreen-watchlist-star svg {
    width: 22px;
    height: 22px;
}

.fullscreen-watchlist-star.active svg {
    fill: var(--accent);
}

.chart-fullscreen-info {
    display: flex;
    gap: 24px;
    flex: 1;
    justify-content: center;
}

.chart-fullscreen-info span {
    font-size: 16px;
    color: var(--text-secondary);
}

.chart-fullscreen-info #fullscreenChartPrice {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 18px;
}

.chart-fullscreen-info #fullscreenChartSmma {
    color: var(--accent);
    font-size: 16px;
}

.minimize-btn {
    margin-left: auto;
}

/* Fullscreen chart containers with resizable wrapper */
.fullscreen-chart-wrapper {
    flex: 1;
    height: auto;
    min-height: 0;
    padding: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative; /* Required for measure overlay positioning */
}

.fullscreen-chart-area {
    flex: 1;
    min-height: 100px;
}

.fullscreen-squeeze-area {
    flex: 0 0 auto;
    height: 180px;
    min-height: 60px;
}

/* Prevent body scroll when modal is open */
body.chart-fullscreen-active {
    overflow: hidden;
}

/* Hide main chart panel when fullscreen is active (fixes mobile display + memory) */
body.chart-fullscreen-active .chart-panel {
    display: none !important;
}

/* Ensure fullscreen modal is always on top and fully visible */
body.chart-fullscreen-active .chart-fullscreen-modal.active {
    display: flex !important;
    visibility: visible !important;
    pointer-events: auto;
}

/* Fullscreen header actions */
.fullscreen-header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Chart Header Actions */
.chart-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Save Layout Button */
.save-layout-btn:hover {
    color: #4CAF50;
    background: rgba(76, 175, 80, 0.1);
}

.save-layout-btn.saved {
    color: #4CAF50;
    animation: pulse-green 0.5s ease;
}

@keyframes pulse-green {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Fullscreen countdown timer */
.fullscreen-countdown {
    display: flex;
    align-items: center;
    padding: 6px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.fullscreen-countdown::before {
    content: '⏱';
    margin-right: 8px;
    font-size: 12px;
}

/* ============================================================================
   Price Measuring Tool
   ============================================================================ */

.measure-overlay {
    position: absolute;
    pointer-events: none;
    z-index: 1000;
    display: none;
}

.measure-overlay.active {
    display: block;
}

.measure-highlight {
    position: absolute;
    left: 0;
    opacity: 1;
    transition: height 0.02s linear, top 0.02s linear, left 0.02s linear, width 0.02s linear;
    pointer-events: none;
}

.measure-highlight.up {
    background: linear-gradient(180deg, rgba(0, 200, 83, 0.05) 0%, rgba(0, 200, 83, 0.12) 100%);
    border-top: 1px dashed rgba(0, 200, 83, 0.6);
    border-bottom: 1px solid rgba(0, 200, 83, 0.8);
    border-left: 1px dashed rgba(0, 200, 83, 0.3);
    border-right: 1px dashed rgba(0, 200, 83, 0.3);
}

.measure-highlight.down {
    background: linear-gradient(0deg, rgba(255, 82, 82, 0.05) 0%, rgba(255, 82, 82, 0.12) 100%);
    border-top: 1px solid rgba(255, 82, 82, 0.8);
    border-bottom: 1px dashed rgba(255, 82, 82, 0.6);
    border-left: 1px dashed rgba(255, 82, 82, 0.3);
    border-right: 1px dashed rgba(255, 82, 82, 0.3);
}

.measure-start-line {
    position: absolute;
    left: 0;
    height: 1px;
    background: var(--accent);
    box-shadow: 0 0 4px var(--accent);
    opacity: 0.7;
}

/* TradingView-style Compact Measure Info Label */
.measure-info-compact {
    position: absolute;
    padding: 6px 10px;
    background: rgba(41, 98, 255, 0.95);
    border-radius: 4px;
    font-size: 12px;
    z-index: 1001;
    white-space: nowrap;
    text-align: center;
    pointer-events: none;
    transition: opacity 0.1s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.measure-info-compact.up {
    background: rgba(38, 166, 154, 0.95);
}

.measure-info-compact.down {
    background: rgba(239, 83, 80, 0.95);
}

.measure-info-main {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: #fff;
    font-weight: 600;
    font-family: 'Roboto Mono', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.4;
}

.measure-info-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.9);
    font-size: 11px;
    line-height: 1.4;
}

.measure-info-volume {
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.85);
    font-size: 11px;
    line-height: 1.4;
}

.measure-price-change {
    color: #fff;
}

.measure-percent {
    color: #fff;
}

.measure-abs-price {
    color: #fff;
}

.measure-bars-count {
    color: #fff;
}

.measure-bars-duration {
    color: rgba(255, 255, 255, 0.9);
}

.measure-duration {
    color: rgba(255, 255, 255, 0.9);
}

.measure-volume {
    color: rgba(255, 255, 255, 0.9);
    font-family: 'Roboto Mono', 'Consolas', monospace;
}

/* Legacy classes - keep for compatibility */
.measure-info {
    display: none;
}

/* Arrow removed - not used in TradingView-style design */

.measure-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    background: rgba(228, 167, 0, 0.2);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    color: var(--accent);
    font-size: 12px;
    z-index: 1002;
    white-space: nowrap;
    display: none;
}

.measure-hint.visible {
    display: block;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ============================================================================
   Watchlist Dropdown (Fullscreen Mode)
   ============================================================================ */

.watchlist-dropdown-container {
    position: relative;
    display: flex;
    align-items: center;
}

.watchlist-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.watchlist-dropdown-btn:hover {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.watchlist-dropdown-btn .star-icon {
    color: var(--accent);
    font-size: 14px;
}

.watchlist-dropdown-btn .count-badge {
    background: var(--accent);
    color: var(--bg-primary);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.watchlist-dropdown-btn .dropdown-arrow {
    font-size: 10px;
    margin-left: 4px;
    transition: transform 0.2s ease;
}

.watchlist-dropdown-btn.open .dropdown-arrow {
    transform: rotate(180deg);
}

.watchlist-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 220px;
    max-height: 350px;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    z-index: 1000;
    display: none;
}

.watchlist-dropdown.open {
    display: block;
    animation: dropdownFadeIn 0.15s ease;
}

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

.watchlist-dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid var(--border);
}

.watchlist-dropdown-item:last-child {
    border-bottom: none;
}

.watchlist-dropdown-item:hover {
    background: var(--accent-dim);
}

.watchlist-dropdown-item.selected {
    background: var(--accent-dim);
    border-left: 3px solid var(--accent);
}

.watchlist-dropdown-item .symbol-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.watchlist-dropdown-item .symbol-name {
    font-weight: 600;
    font-size: 13px;
}

.watchlist-dropdown-item .symbol-price {
    font-size: 11px;
    color: var(--text-secondary);
}

.watchlist-dropdown-item .symbol-change {
    font-size: 12px;
    font-weight: 600;
}

.watchlist-dropdown-item .remove-btn {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: var(--transition);
}

.watchlist-dropdown-item:hover .remove-btn {
    opacity: 1;
}

.watchlist-dropdown-item .remove-btn:hover {
    color: var(--danger);
    background: rgba(255, 82, 82, 0.1);
}

.watchlist-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.watchlist-empty .empty-star {
    font-size: 24px;
    display: block;
    margin-bottom: 8px;
    opacity: 0.5;
}
/* ============================================================================
   Split Screen Mode (Real-time Charts)
   ============================================================================ */

/* Split Screen Toggle Button */
.split-screen-btn:hover {
    background: rgba(228, 167, 0, 0.1);
    border-color: var(--accent);
    color: var(--accent);
}

.split-screen-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-primary);
}

/* Split Screen Container */
.split-screen-container {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.split-screen-container.active {
    display: flex;
}

/* Split Screen Header */
.split-screen-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

/* Compact header for split screen */
.split-screen-header.compact {
    padding: 6px 16px;
    min-height: auto;
}

.split-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.live-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #00C853;
    box-shadow: 0 0 8px rgba(0, 200, 83, 0.6);
    animation: pulse-live 2s infinite;
}

.live-text {
    color: #00C853;
    font-weight: 600;
}

.split-header-left #splitScreenSymbol {
    color: var(--accent);
    font-weight: 600;
}

.split-screen-header h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.split-screen-header h4 span {
    color: var(--accent);
}

.split-close-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.split-close-btn:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

/* Split Header Actions Container */
.split-header-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* Split Screen Save Layout Button */
.split-save-layout-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.split-save-layout-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.split-save-layout-btn.saved {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

/* Split Screen Crosshair Sync Toggle Button */
.split-sync-toggle-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.split-sync-toggle-btn:hover {
    background: rgba(228, 167, 0, 0.15);
    border-color: var(--accent);
    color: var(--accent);
}

.split-sync-toggle-btn.active {
    background: rgba(0, 200, 83, 0.2);
    border-color: #00C853;
    color: #00C853;
}

.split-sync-toggle-btn.active:hover {
    background: rgba(0, 200, 83, 0.3);
}

/* Split Screen Sync View Button (manual sync) */
.split-sync-view-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.split-sync-view-btn:hover {
    background: rgba(228, 167, 0, 0.15);
    border-color: var(--accent);
    color: var(--accent);
}

/* Sync Options Dropdown */
.sync-options-dropdown {
    position: relative;
    display: inline-block;
}

.sync-options-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.sync-options-btn:hover {
    background: rgba(228, 167, 0, 0.15);
    border-color: var(--accent);
    color: var(--accent);
}

.sync-options-dropdown.open .sync-options-btn {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

.sync-options-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    z-index: 1000;
    display: none;
    padding: 8px 0;
}

.sync-options-dropdown.open .sync-options-menu {
    display: block;
    animation: dropdownFadeIn 0.15s ease;
}

.sync-option-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    cursor: default;
}

.sync-option-item:hover {
    background: var(--bg-tertiary);
}

.sync-option-label {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
}

/* Toggle Switch */
.sync-toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

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

.sync-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 22px;
    transition: 0.3s;
}

.sync-toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    transition: 0.3s;
}

.sync-toggle-switch input:checked + .sync-toggle-slider {
    background-color: rgba(0, 200, 83, 0.3);
    border-color: #00C853;
}

.sync-toggle-switch input:checked + .sync-toggle-slider:before {
    transform: translateX(18px);
    background-color: #00C853;
}

.sync-toggle-switch input:focus + .sync-toggle-slider {
    box-shadow: 0 0 0 2px rgba(0, 200, 83, 0.2);
}

/* Split Screen Panels Container */
.split-screen-panels {
    display: flex;
    flex: 1;
    min-height: 0;
}

/* Individual Split Panel */
.split-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-secondary);
}

/* Split Panel Header - Compact */
.split-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 12px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    min-height: 32px;
}

.split-panel-header.compact {
    padding: 4px 10px;
    min-height: 28px;
}

.split-panel-title {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.split-panel-intervals {
    display: flex;
    gap: 4px;
}

.panel-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 8px;
}

.split-panel-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Connection Status Indicator */
.connection-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background 0.3s ease;
}

.connection-status.connected {
    background: #00C853;
    box-shadow: 0 0 8px rgba(0, 200, 83, 0.5);
    animation: pulse-live 2s infinite;
}

.connection-status.disconnected {
    background: var(--danger);
    animation: pulse-disconnected 1s infinite;
}

@keyframes pulse-live {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 8px rgba(0, 200, 83, 0.5);
    }
    50% {
        opacity: 0.7;
        box-shadow: 0 0 4px rgba(0, 200, 83, 0.3);
    }
}

@keyframes pulse-disconnected {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Split Price Display */
.split-price {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Consolas', 'Monaco', monospace;
    font-variant-numeric: tabular-nums;
}

.price-change {
    font-size: 11px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 3px;
}

.price-change.positive {
    color: #00C853;
    background: rgba(0, 200, 83, 0.15);
}

.price-change.negative {
    color: #FF5252;
    background: rgba(255, 82, 82, 0.15);
}

/* Interval Selector */
.split-interval-selector {
    display: flex;
    align-items: center;
    gap: 4px;
}

.split-interval-btn {
    padding: 3px 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.split-interval-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.split-interval-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-primary);
}

/* Chart Type buttons in split panel - same style as interval buttons */
.split-interval-btn.chart-type-btn {
    padding: 4px 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.split-interval-btn.chart-type-btn svg {
    display: block;
}

/* Separator between chart type and interval buttons */
.split-panel-separator {
    width: 1px;
    height: 18px;
    background: var(--border);
    margin: 0 4px;
}

/* Split Panel Controls - wrapper for intervals and data source toggle */
.split-panel-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Data Source Toggle Button */
.split-datasource-btn {
    padding: 3px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.split-datasource-btn.realtime {
    background: rgba(255, 82, 82, 0.15);
    border-color: #FF5252;
    color: #FF5252;
}

.split-datasource-btn.realtime:hover {
    background: rgba(255, 82, 82, 0.25);
}

.split-datasource-btn.rest {
    background: var(--bg-secondary);
    border-color: var(--border);
    color: var(--text-secondary);
}

.split-datasource-btn.rest:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Split Chart Wrapper - contains chart + squeeze */
.split-chart-wrapper {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

/* Split Panel Content - main chart area */
.split-panel-content {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

/* Split Chart Container */
.split-chart-container {
    flex: 1;
    min-height: 0;
    background: var(--bg-primary);
}

/* Split Squeeze Container */
.split-squeeze-container {
    height: 60px;
    min-height: 60px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

/* Vertical Divider Between Panels */
.split-divider {
    width: 3px;
    background: var(--border);
    cursor: col-resize;
    transition: background 0.2s ease;
}

.split-divider:hover {
    background: var(--accent);
}

/* Hide fullscreen chart scroll-to-latest button when split screen is active */
/* Split screen panels have their own integrated scroll buttons via chart-module */
.split-screen-container.active ~ .scroll-to-latest-btn {
    display: none !important;
}

/* Fullscreen chart wrapper when inside split panel */
#splitLeftChartWrapper .fullscreen-chart-wrapper {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#splitLeftChartWrapper .fullscreen-chart-area {
    flex: 1;
    min-height: 0;
}

#splitLeftChartWrapper .fullscreen-squeeze-area {
    height: 60px;
    min-height: 60px;
}

/* Responsive adjustments for split screen */
@media (max-width: 900px) {
    .split-screen-panels {
        flex-direction: column;
    }

    .split-divider {
        width: 100%;
        height: 3px;
        cursor: row-resize;
    }

    .split-panel-header {
        flex-direction: column;
        gap: 4px;
        padding: 4px 8px;
    }

    .split-interval-selector {
        width: 100%;
        justify-content: center;
    }

    .split-squeeze-container {
        height: 50px;
        min-height: 50px;
    }
}

/* ============================================================================
   Mobile Responsive Styles
   ============================================================================ */

/* Prevent horizontal overflow on body */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

.container {
    overflow-x: hidden;
}

/* Medium screens - tablet/small laptop */
@media (max-width: 768px) {
    /* Header becomes column layout */
    .header {
        flex-direction: column;
        gap: 12px;
        padding: 16px;
    }

    .logo h1 {
        font-size: 18px;
    }

    .logo-icon {
        font-size: 22px;
    }

    /* Header stats wrap horizontally */
    .header-stats {
        margin: 0;
        gap: 12px;
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
    }

    .stat-item {
        min-width: fit-content;
    }

    .stat-value-sm {
        font-size: 16px;
    }

    .stat-label-sm {
        font-size: 10px;
    }

    /* Header actions wrap */
    .header-actions {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        width: 100%;
    }

    .auto-refresh-header {
        padding: 6px 12px;
        gap: 8px;
    }

    /* Main content becomes single column */
    .main-content {
        grid-template-columns: 1fr;
    }

    .filters-panel {
        order: 2; /* Move filters below table on mobile */
    }

    .table-panel {
        order: 1;
    }

    /* Bottom section single column */
    .bottom-section {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }

    .chart-panel,
    .touches-panel,
    .signal-touches-panel,
    .squeeze-smma-panel {
        grid-column: 1;
        grid-row: auto;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Chart wrapper reduced height */
    .chart-wrapper {
        height: 400px;
    }

    /* Table wrapper scroll */
    .table-wrapper {
        max-height: 350px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Make table scrollable horizontally if needed */
    table {
        min-width: 500px;
    }

    /* Touches panels (SMMA Touches, Signal Touches, Squeeze/SMMA) scroll */
    .touches-list {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .touches-table {
        min-width: 400px;
    }

    /* Card view adjusts columns */
    .touches-list.card-view {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    /* Chart header - ensure action buttons are visible */
    .chart-header {
        flex-wrap: wrap;
        gap: 8px;
    }

    .chart-header h3 {
        flex: 1;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .chart-header-actions {
        display: flex;
        gap: 4px;
        flex-shrink: 0;
    }

    .chart-action-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        padding: 4px;
        background: var(--bg-tertiary);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        color: var(--text-secondary);
        cursor: pointer;
    }

    .chart-action-btn:hover {
        border-color: var(--accent);
        color: var(--accent);
    }
}


/* Small screens - mobile phones */
@media (max-width: 480px) {
    .container {
        padding: 12px;
    }

    /* Header even more compact */
    .header {
        padding: 12px;
        gap: 10px;
    }

    .logo {
        gap: 8px;
    }

    .logo h1 {
        font-size: 16px;
    }

    .logo-icon {
        font-size: 20px;
    }

    /* Stats in column on very small screens */
    .header-stats {
        gap: 8px;
    }

    /* Hide separators on very small screens */
    .stat-seperator {
        display: none;
    }

    .stat-value-sm {
        font-size: 14px;
    }

    .stat-label-sm {
        font-size: 9px;
    }

    /* Stack header actions vertically */
    .header-actions {
        flex-direction: column;
        width: 100%;
    }

    .auto-refresh-header {
        width: 100%;
        justify-content: center;
    }

    .btn {
        width: 100%;
        justify-content: center;
        padding: 10px 16px;
    }

    /* Filters panel compact */
    .filters-panel {
        padding: 16px;
    }

    .filters-panel h3 {
        font-size: 14px;
    }

    /* Table adjustments */
    th, td {
        padding: 8px 10px;
        font-size: 12px;
    }

    /* Table filter row adjustments */
    .filter-cell {
        flex-direction: column;
        gap: 4px;
    }

    .filter-cell select,
    .filter-cell input {
        width: 100%;
        font-size: 11px;
    }

    /* Chart and panels */
    .chart-wrapper {
        height: 300px;
    }

    .chart-header {
        padding: 12px 16px;
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }

    .chart-header h3 {
        font-size: 16px;
    }

    .chart-header-actions {
        width: 100%;
        justify-content: flex-end;
    }

    /* Touches panel */
    .touches-header {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .touches-header h3 {
        font-size: 14px;
    }

    .touches-list {
        max-height: 250px;
    }

    /* Touch cards */
    .touch-card {
        padding: 10px;
    }

    .touch-card-header {
        flex-wrap: wrap;
        gap: 6px;
    }

    /* Table header adjustments */
    .table-header {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .table-header h3 {
        font-size: 14px;
    }
}

/* Very small screens */
@media (max-width: 360px) {
    .container {
        padding: 8px;
    }

    .header {
        padding: 10px;
        border-radius: var(--radius-sm);
    }

    .logo h1 {
        font-size: 14px;
    }

    .stat-value-sm {
        font-size: 13px;
    }

    .stat-label-sm {
        font-size: 8px;
    }

    .interval-select {
        padding: 4px 6px;
        font-size: 11px;
    }

    .toggle-compact span {
        font-size: 11px;
    }

    .btn {
        font-size: 12px;
        padding: 8px 12px;
    }

    .chart-wrapper {
        height: 250px;
    }
}

/* Fullscreen modal mobile adjustments */
@media (max-width: 768px) {
    .chart-fullscreen-header {
        padding: 10px 12px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .fullscreen-title-section h3 {
        font-size: 16px;
    }

    .fullscreen-header-actions {
        flex-wrap: wrap;
        gap: 6px;
    }

    .watchlist-dropdown-btn {
        font-size: 12px;
        padding: 6px 10px;
    }

    .fullscreen-countdown {
        padding: 4px 10px;
    }

    .fullscreen-countdown span {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .chart-fullscreen-header {
        padding: 8px 10px;
    }

    .fullscreen-title-section {
        width: 100%;
        justify-content: center;
    }

    .fullscreen-title-section h3 {
        font-size: 14px;
    }

    .fullscreen-header-actions {
        width: 100%;
        justify-content: center;
    }

    .watchlist-dropdown-btn span:not(.star-icon):not(.count-badge):not(.dropdown-arrow) {
        display: none; /* Hide "Watchlist" text, keep icon and count */
    }

    .chart-action-btn {
        padding: 6px;
    }

    .chart-action-btn svg {
        width: 14px;
        height: 14px;
    }
}
