/* ═══════════════════════════════════════════════════════════════════
   Chartly Smart Trader — TradingView-style Dark Theme
   ═══════════════════════════════════════════════════════════════════ */

:root {
    /* Core palette */
    --bg-primary:    #0f172a;
    --bg-secondary:  #1e293b;
    --bg-tertiary:   #334155;
    --bg-elevated:   #475569;

    --text-primary:  #f8fafc;
    --text-secondary:#94a3b8;
    --text-muted:    #64748b;

    --accent:        #3b82f6;
    --accent-hover:  #2563eb;

    --green:         #22c55e;
    --green-dim:     #16a34a;
    --red:           #ef4444;
    --red-dim:       #dc2626;
    --yellow:        #eab308;
    --orange:        #f97316;
    --poc-color:     #eab308;

    --border:        rgba(148, 163, 184, 0.12);
    --border-light:  rgba(148, 163, 184, 0.08);

    --font-mono:     'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    --font-sans:     -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    --toolbar-h:     44px;
    --statusbar-h:   24px;
    --sidebar-w:     48px;
    --dash-width:    380px;
    --radius:        6px;
    --radius-sm:     4px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html {
    touch-action: manipulation;
    -ms-touch-action: manipulation;
}

/* Hidden by default, shown via @media on mobile */
.mobile-bottom-nav { display: none !important; }
.mobile-backdrop { display: none; }
.mobile-more-sheet { display: none; }
.ind-mobile-cats { display: none; }

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
}

/* ═══ TOOLBAR ═══ */
.toolbar {
    height: var(--toolbar-h);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    z-index: 100;
    flex-shrink: 0;
    touch-action: manipulation;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-right: 12px;
    border-right: 1px solid var(--border);
}
.logo-icon { width: 28px; height: 28px; border-radius: 6px; display: block; }
.logo-text { font-size: 16px; font-weight: 700; color: var(--accent); }
.logo-sub  { font-size: 11px; color: var(--text-muted); }

/* Symbol Selector */
.symbol-selector {
    position: relative;
    cursor: pointer;
    padding: 4px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s;
}
.symbol-selector:hover { background: var(--bg-elevated); }
.symbol-name { font-weight: 600; font-size: 14px; }
.symbol-arrow { font-size: 10px; color: var(--text-muted); }

.symbol-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 280px;
    max-height: 320px;
    overflow-y: auto;
    z-index: 200;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.symbol-dropdown.open { display: block; }

.symbol-search {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: none;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
}

.symbol-item {
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.1s;
}
.symbol-item:hover { background: var(--bg-tertiary); }
.symbol-item .sym { font-weight: 600; font-size: 13px; }
.symbol-item .sym-name { font-size: 11px; color: var(--text-muted); }
.symbol-item .sym-type {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    text-transform: uppercase;
}

/* Timeframe Picker — Quick buttons + Dropdown */
.tf-picker {
    display: flex;
    align-items: center;
    gap: 2px;
    position: relative;
}
.tf-btn {
    padding: 4px 10px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    white-space: nowrap;
}
.tf-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.tf-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.tf-more {
    padding: 4px 6px;
    font-size: 11px;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    min-width: 28px;
    text-align: center;
}
.tf-more:hover, .tf-more.open { background: var(--bg-tertiary); color: var(--text-primary); }
.tf-more.has-custom {
    color: var(--accent);
    border-color: var(--accent);
    font-weight: 600;
}

/* Timeframe Dropdown Panel */
.tf-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px;
    min-width: 260px;
    z-index: 600;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.tf-dropdown.open { display: block; }
.tf-group { margin-bottom: 8px; }
.tf-group:last-child { margin-bottom: 0; }
.tf-group-title {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 4px 6px 2px;
}
.tf-group-items {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    padding: 2px 2px;
}
.tf-option {
    padding: 5px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    min-width: 36px;
    text-align: center;
}
.tf-option:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--text-muted);
}
.tf-option.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.tf-range {
    font-style: italic;
    color: var(--text-muted);
}
.tf-range.active {
    background: #7c3aed;
    color: white;
    border-color: #7c3aed;
    font-style: normal;
}

/* Chart Type Group */
.chart-type-group {
    display: flex;
    gap: 2px;
    margin-left: 8px;
    padding-left: 8px;
    border-left: 1px solid var(--border);
}
.ct-btn {
    padding: 4px 8px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    line-height: 1;
}
.ct-btn:hover { background: var(--bg-tertiary); }
.ct-btn.active {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--accent);
}

/* Price Display */
.price-display { display: flex; align-items: baseline; gap: 8px; }
.price-value {
    font-size: 18px;
    font-weight: 700;
    font-family: var(--font-mono);
}
.price-change {
    font-size: 12px;
    font-family: var(--font-mono);
    padding: 2px 6px;
    border-radius: 3px;
}
.price-change.positive { color: var(--green); background: rgba(34,197,94,0.12); }
.price-change.negative { color: var(--red); background: rgba(239,68,68,0.12); }

/* Tool Buttons */
.indicator-toggles { display: flex; gap: 4px; }
.tool-btn {
    padding: 4px 10px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 11px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s;
    white-space: nowrap;
}
.tool-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.tool-btn.active {
    background: rgba(59,130,246,0.15);
    border-color: var(--accent);
    color: var(--accent);
}

/* ═══ MAIN CONTAINER ═══ */
.main-container {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

.chart-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
}

.chart-container {
    width: 100%;
    height: 100%;
}

/* OHLCV Legend */
.ohlcv-legend {
    position: absolute;
    top: 8px;
    left: 12px;
    display: flex;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 12px;
    z-index: 10;
    background: rgba(15,23,42,0.75);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    backdrop-filter: blur(8px);
}
.legend-label { color: var(--text-muted); margin-right: 2px; }
.legend-val { color: var(--text-primary); margin-right: 8px; }
.legend-val.up { color: var(--green); }
.legend-val.down { color: var(--red); }

/* Block Info Overlay */
.block-info-overlay {
    position: absolute;
    top: 32px;
    left: 12px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    z-index: 10;
    pointer-events: none;
}

/* ═══ DASHBOARD PANEL ═══ */
.dashboard-panel {
    width: var(--dash-width);
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    flex-shrink: 0;
    transition: width 0.2s, opacity 0.2s;
}
.dashboard-panel.collapsed { width: 0; opacity: 0; overflow: hidden; }

.dash-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(15,23,42,0.7);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 5;
}
.dash-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-primary);
}
.dash-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 3px;
    transition: all 0.15s;
}
.dash-close:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.dash-section {
    padding: 8px 14px;
    border-bottom: 1px solid var(--border-light);
}

.dash-section-header {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: var(--text-primary);
    padding: 6px 0;
    text-align: center;
    background: rgba(15,23,42,0.5);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
}

.dash-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
}
.dash-label { font-size: 11px; color: var(--text-muted); }
.dash-value { font-size: 11px; font-family: var(--font-mono); color: var(--text-secondary); }
.dash-value.accent { color: var(--accent); }

/* Dashboard Grids */
.dash-grid-2x2, .dash-grid-4, .dash-grid-2 {
    display: grid;
    gap: 4px;
}
.dash-grid-2x2 { grid-template-columns: 1fr 1fr; }
.dash-grid-4   { grid-template-columns: 1fr 1fr 1fr 1fr; }
.dash-grid-2   { grid-template-columns: 1fr 1fr; }

.dash-cell {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 5px 8px;
    text-align: center;
}
.dash-cell-label {
    display: block;
    font-size: 9px;
    color: var(--text-muted);
    margin-bottom: 2px;
    white-space: nowrap;
}
.dash-cell-label.buy  { color: var(--green); }
.dash-cell-label.sell { color: var(--red); }
.dash-cell-value {
    display: block;
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-primary);
    white-space: nowrap;
}
.dash-cell-value.buy  { color: var(--green); }
.dash-cell-value.sell { color: var(--red); }
.dash-cell-value.small { font-size: 10px; }

.mt-4 { margin-top: 4px; }

/* Narrative Section */
.narrative-section {
    background: rgba(15,23,42,0.5);
}
.narrative-header {
    background: rgba(234,179,8,0.1) !important;
    color: var(--yellow) !important;
}
.narrative-content {
    padding: 8px 0;
    max-height: 200px;
    overflow-y: auto;
}
.narrative-text {
    font-size: 11px;
    line-height: 1.6;
    color: var(--text-primary);
}
.narrative-disclaimer {
    font-size: 9px;
    color: var(--text-muted);
    padding: 6px 0;
    border-top: 1px solid var(--border-light);
    text-align: center;
    line-height: 1.4;
}

/* ═══ SETTINGS MODAL ═══ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 500;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }

/* Indicator settings modal must sit above the indicators modal (z:2000) */
#indSettingsModal {
    z-index: 2500;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 480px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 16px 64px rgba(0,0,0,0.5);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: 4px;
}
.modal-close:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.modal-body { padding: 16px 18px; }

.settings-group-container {
    margin-bottom: 16px;
}
.settings-title {
    font-size: 11px;
    letter-spacing: 1px;
    color: var(--accent);
    margin-bottom: 10px;
}
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 12px;
}
.setting-row label {
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.setting-row input[type="number"],
.setting-row select {
    width: 100px;
    padding: 4px 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: var(--font-mono);
}
.setting-row input[type="range"] {
    flex: 1;
    accent-color: var(--accent);
}
.range-val {
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    width: 30px;
    text-align: right;
}
.setting-row input[type="checkbox"] {
    accent-color: var(--accent);
    margin-right: 6px;
}

.setting-row input[type="color"] {
    width: 50px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    cursor: pointer;
    padding: 2px;
}

.btn-apply {
    width: 100%;
    padding: 10px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 12px;
    transition: background 0.15s;
}
.btn-apply:hover { background: var(--accent-hover); }

/* ═══ STATUS BAR ═══ */
.statusbar {
    height: var(--statusbar-h);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.status-left, .status-center, .status-right {
    display: flex;
    align-items: center;
    gap: 6px;
}
.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}
.status-dot.green { background: var(--green); }
.status-dot.yellow { background: var(--yellow); }
.status-dot.red { background: var(--red); }

/* ═══ SCROLLBAR ═══ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ═══════════════════════════════════════════════════════════════════
   LEFT SIDEBAR NAVIGATION
   ═══════════════════════════════════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    flex-shrink: 0;
    z-index: 50;
}
.sidebar-icons, .sidebar-bottom {
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: center;
}
.sidebar-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius);
    transition: all 0.15s;
    position: relative;
}
.sidebar-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.sidebar-btn.active {
    color: var(--accent);
    background: rgba(59,130,246,0.1);
}
.sidebar-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--red);
    color: white;
    font-size: 9px;
    font-weight: 700;
    min-width: 14px;
    height: 14px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
}

/* ═══ SIDEBAR EXPANDABLE PANELS ═══ */
.sidebar-panel {
    width: 300px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    animation: panelSlideIn 0.15s ease-out;
}
.sidebar-panel-wide {
    width: 380px;
}

@keyframes panelSlideIn {
    from { width: 0; opacity: 0; }
    to   { opacity: 1; }
}

.sp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(15,23,42,0.7);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.sp-title { font-size: 13px; font-weight: 700; }
.sp-actions { display: flex; gap: 4px; }
.sp-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: all 0.15s;
}
.sp-btn:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

/* Pin button active state */
.sp-btn.pinned {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--accent);
    color: var(--accent);
}
.sp-btn.pinned svg {
    transform: rotate(45deg);
    transition: transform 0.2s;
}

/* ═══ WATCHLIST ═══ */
.wl-tabs {
    display: flex;
    padding: 4px 8px;
    gap: 2px;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
    overflow-x: auto;
}
.wl-tab {
    padding: 5px 10px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    transition: all 0.15s;
}
.wl-tab:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.wl-tab.active { background: var(--accent); color: white; }

.wl-add {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}
.wl-search-input {
    width: 100%;
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-size: 12px;
    outline: none;
    transition: border-color 0.15s;
}
.wl-search-input:focus { border-color: var(--accent); }

.wl-list-header {
    display: grid;
    grid-template-columns: 1fr 70px 70px 44px;
    padding: 4px 10px;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}
.wl-list {
    flex: 1;
    overflow-y: auto;
}
.wl-item {
    display: grid;
    grid-template-columns: 1fr 70px 70px 44px;
    align-items: center;
    padding: 8px 10px;
    cursor: pointer;
    transition: background 0.1s;
    border-bottom: 1px solid var(--border-light);
}
.wl-item:hover { background: var(--bg-tertiary); }
.wl-item-sym { font-weight: 600; font-size: 12px; }
.wl-item-name { font-size: 10px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wl-item-price { font-size: 12px; font-family: var(--font-mono); text-align: right; }
.wl-item-change { font-size: 11px; font-family: var(--font-mono); text-align: right; padding: 2px 6px; border-radius: 3px; }
.wl-item-change.up { color: var(--green); background: rgba(34,197,94,0.1); }
.wl-item-change.down { color: var(--red); background: rgba(239,68,68,0.1); }
.wl-sparkline { width: 44px; height: 24px; }
.wl-item-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s;
}
.wl-item:hover .wl-item-actions { opacity: 1; }
.wl-item-del {
    width: 20px; height: 20px;
    display: flex; align-items: center; justify-content: center;
    background: none; border: none;
    color: var(--text-muted); cursor: pointer;
    font-size: 12px; border-radius: 3px;
}
.wl-item-del:hover { background: rgba(239,68,68,0.2); color: var(--red); }

/* ═══ ALERTS ═══ */
.alert-form {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    background: rgba(15,23,42,0.5);
}
.af-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    gap: 8px;
}
.af-row label { font-size: 11px; color: var(--text-muted); flex-shrink: 0; width: 70px; }
.af-input {
    flex: 1;
    padding: 5px 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: var(--font-mono);
    outline: none;
}
.af-input:focus { border-color: var(--accent); }
.af-actions { display: flex; gap: 6px; margin-top: 4px; }

.btn-sm {
    padding: 6px 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-accent { background: var(--accent); color: white; }
.btn-accent:hover { background: var(--accent-hover); }
.btn-muted { background: var(--bg-tertiary); color: var(--text-secondary); }
.btn-muted:hover { background: var(--bg-elevated); color: var(--text-primary); }

.alert-section-title {
    padding: 6px 14px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--text-muted);
    background: rgba(15,23,42,0.5);
    border-bottom: 1px solid var(--border-light);
}
.alert-list { overflow-y: auto; }
.alert-empty {
    padding: 24px 14px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.6;
}
.alert-item {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background 0.1s;
}
.alert-item:hover { background: var(--bg-tertiary); }
.alert-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}
.alert-item-sym { font-weight: 600; font-size: 12px; }
.alert-item-cond { font-size: 11px; font-family: var(--font-mono); color: var(--text-secondary); }
.alert-item-note { font-size: 10px; color: var(--text-muted); }
.alert-item-time { font-size: 9px; color: var(--text-muted); }
.alert-item-del {
    background: none; border: none;
    color: var(--text-muted); cursor: pointer;
    font-size: 14px; padding: 2px;
}
.alert-item-del:hover { color: var(--red); }

/* ═══ MARKET OVERVIEW ═══ */
.mkt-tabs {
    display: flex;
    padding: 4px 8px;
    gap: 2px;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
    overflow-x: auto;
}
.mkt-tab {
    padding: 5px 10px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    transition: all 0.15s;
}
.mkt-tab:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.mkt-tab.active { background: var(--accent); color: white; }
.mkt-list { flex: 1; overflow-y: auto; padding: 4px; }

.mkt-card {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    cursor: pointer;
    transition: background 0.1s;
}
.mkt-card:hover { background: var(--bg-elevated); }
.mkt-card-sym { font-weight: 600; font-size: 13px; }
.mkt-card-name { font-size: 10px; color: var(--text-muted); }
.mkt-card-price { font-size: 13px; font-family: var(--font-mono); text-align: right; }
.mkt-card-change {
    font-size: 12px; font-family: var(--font-mono);
    text-align: right; padding: 3px 8px;
    border-radius: 4px; font-weight: 600;
}
.mkt-card-change.up { color: var(--green); background: rgba(34,197,94,0.15); }
.mkt-card-change.down { color: var(--red); background: rgba(239,68,68,0.15); }

/* ═══ SCREENER ═══ */
.screener-filters {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}
.sf-row { display: flex; gap: 6px; margin-bottom: 6px; }
.sf-row select { flex: 1; }
.screener-results { flex: 1; overflow-y: auto; }

/* ═══ RIGHT PANEL TABS ═══ */
.rp-tabs {
    display: flex;
    justify-content: center;
    gap: 2px;
    padding: 4px 8px;
    background: rgba(15,23,42,0.8);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.rp-tab {
    padding: 5px 14px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}
.rp-tab:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.rp-tab.active { background: rgba(59,130,246,0.15); color: var(--accent); }

.rp-content { display: none; flex-direction: column; overflow-y: auto; flex: 1; }
.rp-content.active { display: flex; }

/* ═══ SYMBOL DETAILS ═══ */
.detail-card { padding: 14px; }
.det-symbol { font-size: 22px; font-weight: 700; font-family: var(--font-mono); }
.det-name { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.det-exchange { font-size: 11px; color: var(--text-muted); margin-bottom: 12px; }
.det-price-big {
    font-size: 28px; font-weight: 700;
    font-family: var(--font-mono);
    margin: 8px 0 16px;
}
.det-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.det-item {
    display: flex;
    justify-content: space-between;
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}
.det-label { font-size: 11px; color: var(--text-muted); }
.det-val { font-size: 12px; font-family: var(--font-mono); color: var(--text-primary); }

/* ═══ HOTKEYS ═══ */
.hotkey-list { padding: 14px; }
.hk-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-light);
}
.hk-row kbd {
    display: inline-block;
    min-width: 28px;
    text-align: center;
    padding: 3px 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 4px;
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-primary);
}
.hk-row span { font-size: 12px; color: var(--text-secondary); }

/* ═══ INDICATOR SELECTOR DROPDOWN ═══ */
.indicator-selector-group {
    position: relative;
    display: inline-flex;
    margin-left: 6px;
}

.ind-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: white;
    font-size: 9px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    padding: 0 4px;
    margin-left: 4px;
    line-height: 1;
}

/* ═══════════════════════════════════════════════════════════════════
   AUTH AREA — Sign In Button & User Menu
   ═══════════════════════════════════════════════════════════════════ */
.auth-area {
    display: flex;
    align-items: center;
    margin-left: 8px;
}
.guest-area {
    display: flex;
    align-items: center;
}
.auth-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.auth-btn:hover { background: var(--accent-hover); transform: translateY(-1px); }
.auth-icon { font-size: 14px; }

/* User Menu Button */
.user-menu-area { position: relative; }
.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px 10px 4px 4px;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--text-primary);
}
.user-menu-btn:hover { background: var(--bg-elevated); border-color: var(--text-muted); }

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
}
.user-name {
    font-size: 12px;
    font-weight: 500;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Tier Badges */
.tier-badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tier-free { background: rgba(107,114,128,0.2); color: #9ca3af; }
.tier-pro { background: rgba(59,130,246,0.2); color: #60a5fa; }
.tier-premium { background: rgba(245,158,11,0.2); color: #fbbf24; }

/* User Dropdown */
.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 260px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
    z-index: 1000;
    overflow: hidden;
}
.user-dropdown.open { display: block; }

.user-dropdown-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
}
.user-avatar-lg {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
}
.user-dropdown-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.user-dropdown-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-dropdown-email {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 0;
}
.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.1s;
    text-align: left;
}
.user-dropdown-item:hover { background: var(--bg-elevated); color: var(--text-primary); }
.user-dropdown-item.danger:hover { background: rgba(239,68,68,0.1); color: #ef4444; }

.cloud-sync-badge {
    display: inline-flex;
    align-items: center;
    margin-left: auto;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 700;
    background: rgba(34,197,94,0.2);
    color: #22c55e;
}

/* ═══════════════════════════════════════════════════════════
   INDICATORS MODAL (TradingView-style)
   ═══════════════════════════════════════════════════════════ */
.ind-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}
.ind-modal-overlay.open {
    display: flex;
}

.ind-modal {
    width: 720px;
    max-width: 95vw;
    height: 560px;
    max-height: 85vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.6);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ind-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.ind-modal-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}
.ind-modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.15s;
}
.ind-modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

.ind-modal-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
    flex-shrink: 0;
}
.ind-search-icon {
    font-size: 14px;
    opacity: 0.5;
}
.ind-modal-search input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}
.ind-modal-search input::placeholder {
    color: var(--text-muted);
}

.ind-modal-body {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ─── Sidebar ─── */
.ind-modal-sidebar {
    width: 200px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 8px 0;
    background: var(--bg-primary);
}
.ind-sidebar-group {
    padding: 4px 0;
}
.ind-sidebar-group + .ind-sidebar-group {
    border-top: 1px solid var(--border);
    margin-top: 4px;
    padding-top: 8px;
}
.ind-sidebar-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    padding: 6px 16px 4px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.ind-sidebar-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: all 0.12s;
    border-left: 3px solid transparent;
}
.ind-sidebar-btn:hover {
    background: rgba(59, 130, 246, 0.06);
    color: var(--text-primary);
}
.ind-sidebar-btn.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 600;
}

/* ─── List Section ─── */
.ind-modal-list-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.ind-modal-tabs {
    display: flex;
    gap: 0;
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.ind-tab {
    padding: 10px 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.ind-tab:hover {
    color: var(--text-primary);
}
.ind-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.ind-modal-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.ind-modal-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

.ind-modal-footer {
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* ─── Indicator Item (reused styles) ─── */
.ind-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s;
    border-left: 3px solid transparent;
}
.ind-item:hover { background: rgba(59, 130, 246, 0.06); }
.ind-item.active {
    background: rgba(59, 130, 246, 0.08);
    border-left-color: var(--accent);
}

.ind-item-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

/* Favorite Star Button */
.ind-fav-btn {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    width: 22px;
    flex-shrink: 0;
    color: var(--text-muted);
    opacity: 0.35;
    transition: all 0.15s;
    line-height: 1;
    text-align: center;
}
.ind-fav-btn:hover {
    opacity: 1;
    color: #f59e0b;
    transform: scale(1.2);
}
.ind-fav-btn.is-fav {
    color: #f59e0b;
    opacity: 1;
}

.ind-item-icon {
    font-size: 20px;
    width: 28px;
    text-align: center;
    flex-shrink: 0;
}

.ind-item-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.ind-item-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ind-item-desc {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

.ind-item-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-left: 8px;
}

/* Indicator Settings Gear */
.ind-settings-btn {
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    opacity: 0.4;
    transition: all 0.15s;
    color: var(--text-muted);
    line-height: 1;
}
.ind-settings-btn:hover {
    opacity: 1;
    color: var(--accent);
    background: rgba(59, 130, 246, 0.12);
}

/* Toggle Switch */
.ind-toggle {
    width: 36px;
    height: 20px;
    border-radius: 10px;
    background: var(--bg-tertiary);
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
    border: 1px solid var(--border);
}
.ind-toggle.on {
    background: var(--accent);
    border-color: var(--accent);
}
.ind-toggle-knob {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: white;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.ind-toggle.on .ind-toggle-knob {
    transform: translateX(16px);
}

/* (ind-modal-footer moved above) */

/* ─── Add Custom Pine Script Button ─── */
.pine-add-btn {
    display: block;
    width: 100%;
    padding: 8px 12px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(139, 92, 246, 0.12));
    border: 1px dashed rgba(59, 130, 246, 0.4);
    border-radius: 6px;
    color: var(--accent);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.3px;
}
.pine-add-btn:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(139, 92, 246, 0.2));
    border-color: var(--accent);
    transform: translateY(-1px);
}

/* ─── Custom Indicator Item Actions ─── */
.ind-item-actions {
    display: flex;
    gap: 4px;
    margin-left: 6px;
}
.ind-action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    opacity: 0.5;
    transition: all 0.15s;
}
.ind-action-btn:hover {
    opacity: 1;
    background: var(--bg-elevated);
}
.ind-action-btn.delete:hover {
    color: #EF5350;
    background: rgba(239, 83, 80, 0.12);
}
.ind-action-btn.edit:hover {
    color: var(--accent);
    background: rgba(59, 130, 246, 0.12);
}

/* ─── Custom Badge ─── */
.ind-custom-badge {
    display: inline-block;
    background: rgba(139, 92, 246, 0.2);
    color: #a78bfa;
    font-size: 8px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    vertical-align: middle;
}

/* ═══════════════════════════════════════════════════════════
   PINE SCRIPT EDITOR MODAL
   ═══════════════════════════════════════════════════════════ */
.pine-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}
.pine-modal-overlay.open {
    display: flex;
}

.pine-modal {
    width: 580px;
    max-width: 95vw;
    max-height: 90vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: pineModalSlideIn 0.25s ease-out;
}

@keyframes pineModalSlideIn {
    from { opacity: 0; transform: translateY(20px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.pine-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
}
.pine-modal-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}
.pine-modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.15s;
}
.pine-modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

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

.pine-form-row {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.pine-form-group {
    margin-bottom: 12px;
}
.pine-form-group label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.pine-form-group input,
.pine-form-group select {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 12px;
    font-family: inherit;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.pine-form-group input:focus,
.pine-form-group select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Code Textarea (the star) */
.pine-code-textarea {
    width: 100%;
    min-height: 320px;
    padding: 12px 14px;
    background: #0d1117;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: #c9d1d9;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'JetBrains Mono', monospace;
    font-size: 12px;
    line-height: 1.6;
    resize: vertical;
    tab-size: 4;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
    box-sizing: border-box;
    transition: border-color 0.2s;
}
.pine-code-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.pine-code-textarea::placeholder {
    color: #484f58;
}

/* Error & Success */
.pine-editor-errors {
    padding: 10px 12px;
    background: rgba(239, 83, 80, 0.1);
    border: 1px solid rgba(239, 83, 80, 0.3);
    border-radius: 6px;
    color: #EF5350;
    font-size: 11px;
    font-family: monospace;
    white-space: pre-wrap;
    margin-top: 8px;
}
.pine-editor-success {
    padding: 10px 12px;
    background: rgba(38, 166, 154, 0.1);
    border: 1px solid rgba(38, 166, 154, 0.3);
    border-radius: 6px;
    color: #26A69A;
    font-size: 11px;
    font-weight: 600;
    margin-top: 8px;
}
.pine-warning {
    color: #FF9800;
}

/* Modal Footer */
.pine-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.pine-btn {
    padding: 8px 18px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}
.pine-btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.pine-btn-secondary:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}
.pine-btn-primary {
    background: linear-gradient(135deg, #3B82F6, #8B5CF6);
    color: white;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}
.pine-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4);
}
.pine-btn-primary:active {
    transform: translateY(0);
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 1200px) {
    .dashboard-panel { width: 320px; }
    .indicator-toggles .tool-btn span:last-child { display: none; }
    .sidebar-panel { width: 260px; }
    .sidebar-panel-wide { width: 300px; }
}

/* ═══════════════════════════════════════════════════════════════════
   MOBILE: Bottom Sheet + Bottom Nav (≤ 900px)
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
    /* ─── Hide desktop sidebar & dashboard ─── */
    .sidebar { display: none !important; }
    .dashboard-panel { display: none !important; }

    /* ─── Sidebar panels become bottom sheets ─── */
    .sidebar-panel,
    .sidebar-panel-wide {
        display: none;
        position: fixed !important;
        bottom: 56px;
        left: 0;
        right: 0;
        top: auto !important;
        width: 100% !important;
        max-height: 70vh;
        border-right: none !important;
        border-top: 1px solid var(--border);
        border-radius: 16px 16px 0 0;
        z-index: 500;
        animation: bottomSheetUp 0.25s ease-out;
        overflow-y: auto;
        box-shadow: 0 -8px 40px rgba(0,0,0,0.5);
    }
    /* When panel is opened by JS (display:flex) */
    .sidebar-panel[style*="display: flex"],
    .sidebar-panel[style*="display:flex"],
    .sidebar-panel-wide[style*="display: flex"],
    .sidebar-panel-wide[style*="display:flex"] {
        display: flex !important;
        flex-direction: column;
    }

    @keyframes bottomSheetUp {
        from { transform: translateY(100%); opacity: 0; }
        to   { transform: translateY(0); opacity: 1; }
    }

    /* ─── Bottom sheet drag handle ─── */
    .sp-header::before {
        content: '';
        position: absolute;
        top: 6px;
        left: 50%;
        transform: translateX(-50%);
        width: 36px;
        height: 4px;
        background: var(--bg-elevated);
        border-radius: 2px;
    }
    .sp-header {
        position: relative;
        padding-top: 18px !important;
    }

    /* ─── Bottom sheet backdrop ─── */
    .mobile-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 490;
    }
    .mobile-backdrop.open {
        display: block;
    }

    /* ─── Mobile Bottom Navigation Bar ─── */
    .mobile-bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 56px;
        background: var(--bg-secondary);
        border-top: 1px solid var(--border);
        z-index: 600;
        justify-content: space-around;
        align-items: center;
        padding: 0 4px;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        touch-action: manipulation;
    }
    .mobile-nav-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        background: none;
        border: none;
        color: var(--text-muted);
        cursor: pointer;
        padding: 6px 8px;
        border-radius: var(--radius);
        transition: all 0.15s;
        min-width: 48px;
        position: relative;
        -webkit-tap-highlight-color: transparent;
    }
    .mobile-nav-btn:active {
        background: var(--bg-tertiary);
    }
    .mobile-nav-btn.active {
        color: var(--accent);
    }
    .mobile-nav-btn svg {
        width: 22px;
        height: 22px;
    }
    .mobile-nav-label {
        font-size: 10px;
        font-weight: 500;
        line-height: 1;
    }
    .mobile-nav-badge {
        position: absolute;
        top: 2px;
        right: 6px;
        background: var(--red);
        color: white;
        font-size: 8px;
        font-weight: 700;
        min-width: 14px;
        height: 14px;
        border-radius: 7px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 3px;
    }

    /* ─── Adjust main layout for bottom nav ─── */
    body {
        padding-bottom: 56px;
    }
    .statusbar {
        display: none;
    }

    /* ─── Toolbar: compact for mobile ─── */
    .toolbar {
        height: 40px;
        padding: 0 8px;
    }
    .logo-sub { display: none; }
    .logo-text { font-size: 14px; }
    .toolbar-center { display: none; }
    .toolbar-right .settings-group { display: none; }

    /* ─── Auth area: compact on mobile ─── */
    .auth-label { display: none; }
    .auth-btn { padding: 5px 8px; }
    .user-name { display: none; }
    .user-menu-btn { padding: 3px; border: none; }
    .user-dropdown {
        position: fixed;
        top: auto;
        bottom: 56px;
        left: 0;
        right: 0;
        width: 100%;
        border-radius: 16px 16px 0 0;
        z-index: 510;
    }

    /* ─── Timeframe picker: compact on mobile ─── */
    .tf-picker {
        flex-shrink: 0;
    }
    .tf-fav { display: none; } /* Hide quick buttons on mobile, only show ▾ dropdown trigger */
    .tf-more {
        font-size: 12px;
        padding: 4px 10px;
        min-width: auto;
    }
    .tf-more.has-custom,
    .tf-more.open {
        font-weight: 600;
    }
    .tf-dropdown {
        position: fixed !important;
        top: auto !important;
        bottom: 56px;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        min-width: unset;
        border-radius: 16px 16px 0 0;
        z-index: 600;
        max-height: 60vh;
        overflow-y: auto;
        padding: 12px;
    }
    .tf-btn {
        font-size: 11px;
        padding: 3px 8px;
    }
    .tf-option {
        padding: 8px 12px;
        font-size: 13px;
        min-width: 44px;
    }

    /* ─── Indicator Modal: fullscreen on mobile ─── */
    .ind-modal {
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        border-radius: 0;
    }
    .ind-modal-header {
        padding: 12px 16px;
    }
    .ind-modal-header h3 {
        font-size: 14px;
    }
    .ind-modal-close {
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .ind-modal-sidebar {
        display: none;
    }
    .ind-modal-body {
        flex-direction: column;
    }
    .ind-modal-list-wrapper {
        flex: 1;
    }

    /* ─── Mobile category chip bar (replaces sidebar) ─── */
    .ind-mobile-cats {
        display: flex;
        gap: 6px;
        padding: 8px 12px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-bottom: 1px solid var(--border);
        background: var(--bg-primary);
        flex-shrink: 0;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    .ind-mobile-cats::-webkit-scrollbar {
        display: none;
    }
    .ind-cat-chip {
        flex-shrink: 0;
        padding: 6px 14px;
        border-radius: 20px;
        border: 1px solid var(--border);
        background: var(--bg-secondary);
        color: var(--text-secondary);
        font-size: 12px;
        font-weight: 500;
        cursor: pointer;
        white-space: nowrap;
        transition: all 0.15s;
        -webkit-tap-highlight-color: transparent;
    }
    .ind-cat-chip:active {
        transform: scale(0.95);
    }
    .ind-cat-chip.active {
        background: var(--accent);
        border-color: var(--accent);
        color: white;
        font-weight: 600;
    }

    /* ─── Hide tabs header on mobile (use chips instead) ─── */
    .ind-modal-tabs {
        display: none;
    }

    /* ─── Settings modal: full width ─── */
    .modal-content {
        width: 95vw !important;
        max-width: 95vw !important;
        max-height: 85vh;
    }

    /* ─── OHLCV legend: smaller ─── */
    .ohlcv-legend {
        font-size: 10px;
        gap: 3px;
        padding: 3px 6px;
    }

    /* ─── Indicator items: bigger touch targets on mobile ─── */
    .ind-item {
        padding: 14px 16px;
        min-height: 56px;
        border-left: none;
    }
    .ind-item-name {
        font-size: 13px;
    }
    .ind-item-desc {
        font-size: 11px;
        white-space: normal;
        line-height: 1.3;
    }
    .ind-item-icon {
        display: none;
    }
    .ind-fav-btn {
        width: 28px;
        font-size: 18px;
    }
    .ind-settings-btn {
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        opacity: 0.6;
    }
    .ind-modal-list-header {
        padding: 8px 16px;
        font-size: 9px;
    }
    .ind-modal-footer {
        padding: 12px 16px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }
    .pine-add-btn {
        width: 100%;
        min-height: 44px;
        font-size: 13px;
    }
    .ind-toggle {
        width: 44px;
        height: 26px;
        border-radius: 13px;
    }
    .ind-toggle-knob {
        width: 20px;
        height: 20px;
        top: 2px;
        left: 2px;
    }
    .ind-toggle.on .ind-toggle-knob {
        transform: translateX(18px);
    }

    /* ─── Symbol search: bottom sheet on mobile ─── */
    .symbol-dropdown {
        position: fixed !important;
        top: auto !important;
        bottom: 56px;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        max-height: 60vh;
        border-radius: 16px 16px 0 0;
        z-index: 700;
        margin-top: 0;
        animation: bottomSheetUp 0.25s ease-out;
    }
    .symbol-search {
        padding: 14px 16px;
        font-size: 16px; /* prevents iOS zoom */
    }
    .symbol-item {
        padding: 12px 16px;
        min-height: 48px;
    }

    /* ─── Upgrade Modal: stack plan cards vertically ─── */
    #upgradeModal .modal-content {
        width: 95vw !important;
        max-width: 95vw !important;
    }
    #upgradeModal .modal-body > div[style*="flex"] {
        flex-direction: column !important;
    }
    .upgrade-plan-card {
        padding: 16px 14px;
    }
    .upgrade-plan-price {
        font-size: 24px;
    }

    /* ─── Pine Script Editor: full screen on mobile ─── */
    .pine-modal {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        border-radius: 0;
    }
    .pine-code-textarea {
        font-size: 13px;
        min-height: 150px;
    }
    .pine-modal-body {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* ─── Ind Settings Modal: responsive ─── */
    #indSettingsModal .modal-content {
        width: 95vw !important;
        max-width: 95vw !important;
    }

    /* ─── All form inputs: prevent iOS zoom ─── */
    input, select, textarea {
        font-size: 16px !important;
    }

    /* ─── mc-search-overlay: above mobile nav ─── */
    .mc-search-overlay {
        z-index: 700;
    }
    .mc-search-box {
        width: 95vw;
        max-width: 95vw;
    }
    .mc-search-box input {
        font-size: 16px;
        padding: 14px 16px;
    }

    /* ─── Alert form: bigger touch targets ─── */
    .alert-form input,
    .alert-form select {
        min-height: 44px;
        padding: 10px 12px;
    }
    .alert-form button {
        min-height: 44px;
    }

    /* ─── Watchlist: bigger touch targets ─── */
    .wl-item {
        min-height: 52px;
        padding: 10px 12px;
    }
    .wl-item-del {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    .wl-item-actions {
        opacity: 1 !important; /* Always show on touch devices */
    }
    .wl-search-input {
        min-height: 44px;
        font-size: 16px !important;
    }
    .wl-tab {
        min-height: 36px;
        padding: 6px 12px;
    }

    /* ─── Scrollable bottom sheets ─── */
    .sidebar-panel,
    .sidebar-panel-wide {
        -webkit-overflow-scrolling: touch;
    }

    /* ─── Safe area for bottom nav ─── */
    .mobile-bottom-nav {
        height: calc(56px + env(safe-area-inset-bottom, 0px));
    }

    /* ─── Hide layout selector on mobile (single chart only) ─── */
    .layout-selector-group { display: none; }

    /* ─── Pin button: hide on mobile (panels auto-close) ─── */
    #btnPinWatchlist { display: none; }

    /* ─── Mobile More Sheet ─── */
    .mobile-more-sheet {
        display: none;
        position: fixed;
        bottom: calc(56px + env(safe-area-inset-bottom, 0px));
        left: 0;
        right: 0;
        background: var(--bg-secondary);
        border-top: 1px solid var(--border);
        border-radius: 16px 16px 0 0;
        z-index: 550;
        box-shadow: 0 -8px 40px rgba(0,0,0,0.5);
        animation: bottomSheetUp 0.2s ease-out;
        padding-bottom: 8px;
    }
    .mobile-more-sheet.open {
        display: block;
    }
    .mobile-more-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 14px 18px 8px;
        font-weight: 600;
        font-size: 15px;
        color: var(--text-primary);
    }
    .mobile-more-close {
        background: none;
        border: none;
        color: var(--text-muted);
        font-size: 18px;
        cursor: pointer;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: var(--radius-sm);
    }
    .mobile-more-close:active {
        background: var(--bg-tertiary);
    }
    .mobile-more-items {
        display: flex;
        flex-direction: column;
    }
    .mobile-more-item {
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 14px 20px;
        background: none;
        border: none;
        color: var(--text-secondary);
        font-size: 15px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: background 0.1s;
        text-align: left;
    }
    .mobile-more-item:active {
        background: var(--bg-tertiary);
    }
    .mobile-more-item svg {
        flex-shrink: 0;
        color: var(--text-muted);
    }
}

/* ═══ Very small screens (≤ 480px) ═══ */
@media (max-width: 480px) {
    .logo { display: none; }
    .chart-type-group { display: none; }
    .tf-btn { padding: 3px 6px; font-size: 10px; }
    .tf-fav { display: none; }
    .tool-btn span:last-child { display: none; }
    .layout-selector-group { display: none; }
}

/* ═══════════════════════════════════════════════════════════════════
   MULTI-CHART LAYOUT SYSTEM
   ═══════════════════════════════════════════════════════════════════ */

/* Layout Selector (Toolbar) */
.layout-selector-group {
    position: relative;
}
.layout-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
}
.layout-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.layout-current-icon {
    font-size: 16px;
    line-height: 1;
}
.layout-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
    display: none;
    z-index: 500;
    min-width: 180px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.layout-dropdown.show {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.layout-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 13px;
    transition: all 0.12s;
    text-align: left;
}
.layout-option:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.layout-option.active {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent);
}
.lo-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
    line-height: 1;
}
.lo-label {
    flex: 1;
}
.lo-pro {
    font-size: 9px;
    font-weight: 700;
    color: var(--yellow);
    background: rgba(234, 179, 8, 0.15);
    padding: 1px 5px;
    border-radius: 3px;
    letter-spacing: 0.5px;
}

/* ─── Multi-Chart Grid Container ─── */
.chart-wrapper.mc-grid {
    display: grid;
    gap: 2px;
    background: var(--bg-primary);
}

/* ─── Chart Cell ─── */
.mc-cell {
    position: relative;
    overflow: hidden;
    border: 1px solid transparent;
    border-radius: 2px;
    transition: border-color 0.15s;
    flex: 1;
    min-height: 0;
    min-width: 0;
}
.mc-cell.mc-active {
    border-color: var(--accent);
}
/* No active border in single layout */
.chart-wrapper:not(.mc-grid) .mc-cell.mc-active {
    border-color: transparent;
}
.mc-chart {
    width: 100%;
    height: 100%;
}

/* ─── Cell Symbol Label ─── */
.mc-label {
    position: absolute;
    top: 6px;
    left: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    background: rgba(15, 23, 42, 0.8);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    z-index: 10;
    backdrop-filter: blur(6px);
    pointer-events: auto;
}
.mc-symbol-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 11px;
    padding: 0 2px;
    transition: color 0.15s;
}
.mc-symbol-btn:hover {
    color: var(--accent);
}

/* Hide label for single layout */
.chart-wrapper:not(.mc-grid) .mc-label {
    display: none;
}

/* ─── Cell Symbol Search Overlay ─── */
.mc-search-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 600;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}
.mc-search-overlay.show {
    display: flex;
}
.mc-search-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 360px;
    max-height: 400px;
    overflow: hidden;
    box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}
.mc-search-box input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: none;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 14px;
    outline: none;
}
.mc-search-results {
    max-height: 320px;
    overflow-y: auto;
}
.mc-search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.1s;
}
.mc-search-item:hover {
    background: var(--bg-tertiary);
}
.mc-si-sym {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-primary);
    min-width: 70px;
}
.mc-si-name {
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ═══ UPGRADE TO PRO MODAL ═══ */
#upgradeModal { z-index: 3000; }
.upgrade-plan-card {
    flex: 1;
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 20px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, transform .15s, box-shadow .2s;
    position: relative;
}
.upgrade-plan-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(59,130,246,0.15);
}
.upgrade-plan-card.popular {
    border-color: var(--accent);
    background: linear-gradient(135deg, rgba(59,130,246,0.08), rgba(59,130,246,0.02));
}
.upgrade-plan-badge {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 100px;
    letter-spacing: .5px;
}
.upgrade-plan-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.upgrade-plan-price {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
    margin-bottom: 4px;
}
.upgrade-plan-price span {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-muted);
}
.upgrade-plan-desc {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 14px;
}
.upgrade-plan-btn {
    width: 100%;
    padding: 10px 0;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, transform .1s;
}
.upgrade-plan-card .upgrade-plan-btn {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.upgrade-plan-card .upgrade-plan-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.upgrade-plan-card.popular .upgrade-plan-btn {
    background: var(--accent);
    color: #fff;
}
.upgrade-plan-card.popular .upgrade-plan-btn:hover {
    background: #2563eb;
    transform: scale(1.02);
}
