/* ========================================
   TV Screener - Professional Dark Theme
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg-primary: #0f1118;
    --bg-secondary: #161923;
    --bg-tertiary: #1c2030;
    --bg-elevated: #222639;
    --bg-hover: #2a2f45;
    --bg-active: #303654;
    --text-primary: #e1e3ea;
    --text-secondary: #8a8f9e;
    --text-muted: #555a6e;
    --border-color: #1e2235;
    --border-subtle: rgba(255,255,255,0.04);
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.15);
    --green: #22c55e;
    --green-dim: #16a34a;
    --green-bg: rgba(34, 197, 94, 0.08);
    --green-bg-strong: rgba(34, 197, 94, 0.15);
    --red: #ef4444;
    --red-dim: #dc2626;
    --red-bg: rgba(239, 68, 68, 0.08);
    --red-bg-strong: rgba(239, 68, 68, 0.15);
    --yellow: #eab308;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
    --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Header ===== */
.header {
    background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    border-bottom: 1px solid var(--border-color);
    padding: 0 20px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    position: relative;
    z-index: 100;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.logo-icon svg {
    width: 30px;
    height: 30px;
    filter: drop-shadow(0 2px 8px rgba(41, 98, 255, 0.3));
}

.logo-text {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-divider {
    width: 1px;
    height: 20px;
    background: var(--border-color);
}

.clock {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* ===== Tabs ===== */
.tabs {
    display: flex;
    gap: 2px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 3px;
}

.tab {
    padding: 6px 14px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.tab:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.tab.active {
    color: white;
    background: var(--accent);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.tab svg {
    opacity: 0.7;
}

.tab.active svg {
    opacity: 1;
}

/* ===== Live Indicator ===== */
.live-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    letter-spacing: 0.5px;
    border: 1px solid transparent;
}

.live-indicator.active {
    background: var(--green-bg-strong);
    color: var(--green);
    border-color: rgba(34, 197, 94, 0.2);
}

.live-indicator.inactive {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    border-color: var(--border-color);
}

.live-indicator:hover {
    border-color: var(--text-muted);
}

.live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
    animation: pulse 2s ease-in-out infinite;
}

.live-indicator.inactive .live-dot {
    background: var(--text-muted);
    box-shadow: none;
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

/* ===== Filter Bar ===== */
.filter-bar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.filter-presets {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.preset-btn {
    padding: 5px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 11px;
    font-weight: 500;
    border-radius: 20px;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.preset-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.preset-btn.active {
    background: var(--accent-glow);
    color: var(--accent);
    border-color: var(--accent);
}

.filter-divider {
    width: 1px;
    height: 28px;
    background: var(--border-color);
    flex-shrink: 0;
}

.filter-fields {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    flex: 1;
}

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

.filter-label {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    margin-right: 2px;
}

.filter-dash {
    color: var(--text-muted);
    font-size: 11px;
}

.filter-input {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 12px;
    width: 80px;
    outline: none;
    transition: all var(--transition);
}

.filter-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

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

.filter-select {
    width: 100px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23555a6e' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
    padding-right: 22px;
}

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

.filter-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    margin-left: auto;
}

.btn {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    border: none;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
    transform: translateY(-1px);
}

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

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

.btn-ghost:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ===== Status Bar ===== */
.status-bar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 10px;
    color: var(--text-muted);
    flex-shrink: 0;
    height: 28px;
    gap: 8px;
    overflow: hidden;
}

.status-left {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    flex-shrink: 0;
}

.status-right {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    flex-shrink: 0;
}


.status-dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--text-muted);
}

.result-count {
    font-weight: 600;
    color: var(--text-secondary);
}

.data-source {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== Table ===== */
.table-container {
    flex: 1;
    overflow: auto;
    min-height: 0;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    background: var(--bg-secondary);
    padding: 9px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: color var(--transition);
    position: relative;
}

th::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border-color);
}

th:hover {
    color: var(--text-primary);
}

th.sorted {
    color: var(--accent);
}

th .sort-icon {
    margin-left: 4px;
    font-size: 9px;
    opacity: 0;
    transition: opacity var(--transition);
}

th:hover .sort-icon,
th.sorted .sort-icon {
    opacity: 1;
}

/* Row number column */
th:first-child, td:first-child {
    width: 40px;
    text-align: center;
    color: var(--text-muted);
    font-size: 11px;
}

td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    transition: background-color 0.2s;
}

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

tr.active td {
    background: var(--accent-glow);
}

/* Zebra striping */
tbody tr:nth-child(even) td {
    background: rgba(255,255,255,0.01);
}

tbody tr:nth-child(even):hover td {
    background: var(--bg-tertiary);
}

/* Flash effects */
tr.flash-green td {
    background: var(--green-bg-strong) !important;
}

tr.flash-red td {
    background: var(--red-bg-strong) !important;
}

/* ===== Ticker Cell ===== */
.ticker-cell {
    display: flex;
    flex-direction: column;
    gap: 1px;
    cursor: pointer;
}

.ticker-cell:hover .ticker-symbol {
    color: var(--accent);
}

.ticker-symbol {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    transition: color var(--transition);
}

.ticker-desc {
    color: var(--text-muted);
    font-size: 11px;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== Number Formatting ===== */
.positive { color: var(--green); }
.negative { color: var(--red); }
.neutral { color: var(--text-secondary); }

/* Change bar */
.change-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.change-bar {
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: var(--bg-elevated);
    overflow: hidden;
    flex-shrink: 0;
}

.change-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.change-bar-fill.positive {
    background: var(--green);
}

.change-bar-fill.negative {
    background: var(--red);
}

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-strong-buy {
    background: var(--green-bg-strong);
    color: var(--green);
    box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.2);
}

.badge-buy {
    background: var(--green-bg);
    color: var(--green-dim);
    box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.12);
}

.badge-neutral {
    background: rgba(138, 143, 158, 0.1);
    color: var(--text-secondary);
    box-shadow: inset 0 0 0 1px rgba(138, 143, 158, 0.12);
}

.badge-sell {
    background: var(--red-bg);
    color: var(--red-dim);
    box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.12);
}

.badge-strong-sell {
    background: var(--red-bg-strong);
    color: var(--red);
    box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.2);
}

/* ===== Loading ===== */
.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 17, 24, 0.75);
    backdrop-filter: blur(4px);
    z-index: 200;
    justify-content: center;
    align-items: center;
}

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

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--bg-elevated);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.loading-text {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

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

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

.empty-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 20px;
    background: var(--bg-tertiary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-icon svg {
    width: 24px;
    height: 24px;
    stroke: var(--text-muted);
}

.empty-state h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.empty-state p {
    font-size: 13px;
    color: var(--text-muted);
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    z-index: 300;
    transform: translateY(80px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-lg);
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-error {
    background: var(--red);
    color: white;
}

.toast-success {
    background: var(--green);
    color: white;
}

/* ===== Chart Panel ===== */
.chart-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--accent);
    z-index: 150;
    transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.4);
}

.chart-panel.open {
    height: 55vh;
}

.chart-resize-handle {
    height: 6px;
    cursor: ns-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chart-resize-handle::after {
    content: '';
    width: 40px;
    height: 3px;
    border-radius: 3px;
    background: var(--bg-hover);
    transition: background var(--transition);
}

.chart-resize-handle:hover::after {
    background: var(--text-muted);
}

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

.chart-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-title svg {
    color: var(--accent);
}

.chart-close-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    transition: all var(--transition);
}

.chart-close-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.chart-body {
    flex: 1;
    min-height: 0;
}

.chart-body iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Adjust table when chart is open */
body.chart-open .table-container {
    max-height: calc(45vh - 160px);
}

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

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

::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 3px;
}

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

/* ===== Search Box ===== */
.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 10px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 12px;
    padding: 6px 10px 6px 30px;
    border-radius: var(--radius-sm);
    width: 180px;
    outline: none;
    transition: all var(--transition);
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
    width: 240px;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-kbd {
    position: absolute;
    right: 6px;
    font-family: inherit;
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 3px;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    display: none;
}

.search-input:focus ~ .search-kbd,
.search-input:not(:placeholder-shown) ~ .search-kbd {
    display: block;
}

/* ===== Watchlist Star ===== */
.star-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    color: var(--text-muted);
    transition: all var(--transition);
    display: flex;
    align-items: center;
}

.star-btn:hover {
    color: var(--yellow);
    transform: scale(1.15);
}

.star-btn.starred {
    color: var(--yellow);
}

.star-btn.starred svg {
    fill: var(--yellow);
}

/* ===== View Toggle ===== */
.view-toggle {
    display: flex;
    gap: 2px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 2px;
}

.view-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 2px 6px;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: all var(--transition);
}

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

.view-btn.active {
    background: var(--bg-hover);
    color: var(--accent);
}

.btn-sm {
    padding: 2px 8px;
    font-size: 10px;
}

/* ===== Heatmap ===== */
.heatmap-container {
    flex: 1;
    overflow: auto;
    min-height: 0;
    padding: 12px;
}

.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 3px;
    width: 100%;
}

.heatmap-tile {
    border-radius: var(--radius-sm);
    padding: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all var(--transition);
    min-height: 70px;
    position: relative;
    overflow: hidden;
}

.heatmap-tile:hover {
    transform: scale(1.03);
    z-index: 2;
    box-shadow: var(--shadow-md);
}

.heatmap-tile .tile-symbol {
    font-size: 12px;
    font-weight: 700;
    color: white;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.heatmap-tile .tile-change {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255,255,255,0.85);
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

.heatmap-tile .tile-price {
    font-size: 10px;
    color: rgba(255,255,255,0.6);
    margin-top: 2px;
}

/* Large cap tiles are bigger */
.heatmap-tile.tile-lg {
    grid-column: span 2;
    grid-row: span 2;
    min-height: 140px;
}

.heatmap-tile.tile-lg .tile-symbol {
    font-size: 16px;
}

.heatmap-tile.tile-lg .tile-change {
    font-size: 14px;
}

.heatmap-tile.tile-md {
    grid-column: span 2;
    min-height: 70px;
}

.heatmap-tile.tile-md .tile-symbol {
    font-size: 13px;
}

/* Heatmap tooltip */
.heatmap-tooltip {
    position: fixed;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: 12px;
    z-index: 200;
    pointer-events: none;
    box-shadow: var(--shadow-lg);
    display: none;
}

.heatmap-tooltip.visible {
    display: block;
}

.heatmap-tooltip .tt-symbol {
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 4px;
}

.heatmap-tooltip .tt-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    color: var(--text-secondary);
}

.heatmap-tooltip .tt-row span:last-child {
    color: var(--text-primary);
    font-weight: 500;
}

body.chart-open .heatmap-container {
    max-height: calc(45vh - 160px);
}

/* ===== Light Theme ===== */
[data-theme="light"] {
    --bg-primary: #f5f5f8;
    --bg-secondary: #ffffff;
    --bg-tertiary: #ebedf0;
    --bg-elevated: #e2e4e8;
    --bg-hover: #d8dae0;
    --bg-active: #cdd0d6;
    --text-primary: #1a1a2e;
    --text-secondary: #5a5d6b;
    --text-muted: #8c8f9c;
    --border-color: #d8dae0;
    --border-subtle: rgba(0,0,0,0.05);
    --accent: #2962ff;
    --accent-hover: #1e53e5;
    --accent-glow: rgba(41, 98, 255, 0.12);
    --green-bg: rgba(34, 197, 94, 0.1);
    --green-bg-strong: rgba(34, 197, 94, 0.18);
    --red-bg: rgba(239, 68, 68, 0.1);
    --red-bg-strong: rgba(239, 68, 68, 0.18);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.15);
}


[data-theme="light"] .header {
    background: linear-gradient(180deg, #ffffff 0%, #f5f5f8 100%);
}

/* ===== Theme Toggle ===== */
.theme-toggle {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 5px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: all var(--transition);
}

.theme-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
[data-theme="light"] .icon-sun { display: block; }
[data-theme="light"] .icon-moon { display: none; }

/* ===== Column Dropdown ===== */
.column-dropdown {
    display: none;
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px;
    z-index: 200;
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    max-height: 300px;
    overflow-y: auto;
}

.column-dropdown.open {
    display: block;
}

.col-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    transition: background var(--transition);
}

.col-option:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.col-option input[type="checkbox"] {
    accent-color: var(--accent);
}

/* ===== Dashboard ===== */
.dashboard-container {
    flex: 1;
    overflow: auto;
    min-height: 0;
    padding: 16px;
    background: var(--bg-primary);
}

.portfolio-container {
    background: var(--bg-primary);
}

.dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px;
}

.dash-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.dash-card.dash-wide {
    grid-column: 1 / -1;
}

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

.dash-card-header h3 {
    font-size: 13px;
    font-weight: 600;
}

.dash-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
}

/* Dashboard market selector */
.dash-market-selector {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 12px;
    width: fit-content;
}

.dash-mkt-btn {
    padding: 8px 24px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.dash-mkt-btn:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.dash-mkt-btn.active { background: var(--accent); color: white; box-shadow: 0 2px 8px rgba(59,130,246,0.35); }
.dash-mkt-btn svg { opacity: 0.7; }
.dash-mkt-btn.active svg { opacity: 1; }

.dash-badge.positive { background: var(--green-bg-strong); color: var(--green); }
.dash-badge.negative { background: var(--red-bg-strong); color: var(--red); }
.dash-badge.neutral-badge { background: rgba(138,143,158,0.12); color: var(--text-secondary); }

.dash-card-body {
    padding: 12px 16px;
}

/* Calendar card needs solid background for readability */
#dashCalendar {
    background: var(--bg-primary);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

[data-theme="light"] #dashCalendar {
    background: #ffffff;
}

.dash-list {
    padding: 0 !important;
}

/* Dashboard list items */
.dash-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: background var(--transition);
}

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

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

.dash-item-left {
    display: flex;
    flex-direction: column;
}

.dash-item-symbol {
    font-weight: 600;
    font-size: 12px;
}

.dash-item-name {
    font-size: 11px;
    color: var(--text-muted);
}

.dash-item-right {
    text-align: right;
}

.dash-item-price {
    font-weight: 500;
    font-size: 12px;
}

.dash-item-change {
    font-size: 11px;
    font-weight: 600;
}

/* Market widget row */
.market-widget-row {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.market-mini-card {
    flex-shrink: 0;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    min-width: 140px;
    cursor: pointer;
    transition: background var(--transition);
}

.market-mini-card:hover {
    background: var(--bg-hover);
}

.market-mini-card .mmc-name {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.market-mini-card .mmc-price {
    font-size: 15px;
    font-weight: 700;
}

.market-mini-card .mmc-change {
    font-size: 11px;
    font-weight: 600;
}

/* Calendar */
.calendar-widget {
    min-height: 180px;
}

.cal-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 12px;
}

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

.cal-time {
    color: var(--text-muted);
    font-weight: 500;
    width: 50px;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.cal-event {
    color: var(--text-primary);
    font-weight: 500;
}

.cal-impact {
    margin-left: auto;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cal-impact.high { background: var(--red); }
.cal-impact.medium { background: var(--yellow); }
.cal-impact.low { background: var(--green); }

/* Alert items */
.alert-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 12px;
}

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

.alert-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-symbol { font-weight: 600; }
.alert-condition { color: var(--text-secondary); }
.alert-price { font-weight: 600; color: var(--accent); }
.alert-status { font-size: 11px; }
.alert-status.triggered { color: var(--green); font-weight: 600; }
.alert-status.waiting { color: var(--text-muted); }

.alert-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all var(--transition);
}

.alert-delete:hover {
    color: var(--red);
    background: var(--red-bg);
}

.no-data-msg {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 12px;
}

/* ===== Portfolio ===== */
.portfolio-container {
    flex: 1;
    overflow: auto;
    min-height: 0;
    padding: 16px;
}

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

.portfolio-summary {
    display: flex;
    gap: 24px;
}

.ps-item {
    display: flex;
    flex-direction: column;
}

.ps-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.ps-value {
    font-size: 18px;
    font-weight: 700;
}

.ps-value.positive { color: var(--green); }
.ps-value.negative { color: var(--red); }

.portfolio-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.portfolio-table th {
    background: var(--bg-tertiary);
    cursor: default;
}

.portfolio-table td {
    font-variant-numeric: tabular-nums;
}

.portfolio-table .del-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
}

.portfolio-table .del-btn:hover {
    color: var(--red);
    background: var(--red-bg);
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 17, 24, 0.7);
    backdrop-filter: blur(4px);
    z-index: 250;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 380px;
    box-shadow: var(--shadow-lg);
}

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

.modal-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.modal-body {
    padding: 20px;
}

.form-group {
    margin-bottom: 14px;
}

.form-group:last-child {
    margin-bottom: 0;
}

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

.form-group .filter-input {
    width: 100%;
}

.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ===== Market Status Bar ===== */
.market-status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    font-size: 10px;
    flex-shrink: 0;
}

.market-status-left {
    display: flex;
    align-items: center;
    gap: 6px;
}

.market-status-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.market-status-indicator.open {
    background: var(--green);
    box-shadow: 0 0 6px rgba(34,197,94,0.5);
}

.market-status-indicator.closed {
    background: var(--red);
}

.market-status-indicator.pre {
    background: var(--yellow);
}

.market-status-text {
    font-weight: 600;
    color: var(--text-secondary);
}

.market-status-timer {
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.market-status-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.trending-label {
    color: var(--text-muted);
    font-weight: 500;
}

.trending-symbols {
    display: flex;
    gap: 8px;
}

.trending-chip {
    color: var(--accent);
    font-weight: 600;
    cursor: pointer;
    transition: opacity var(--transition);
}

.trending-chip:hover {
    opacity: 0.7;
}

/* ===== Ticker Tape ===== */
.ticker-tape {
    height: 46px;
    flex-shrink: 0;
    overflow: hidden;
    border-bottom: 1px solid var(--border-color);
}

.ticker-tape iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ===== Refresh Selector ===== */
.refresh-selector {
    display: flex;
    align-items: center;
}

.refresh-select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 11px;
    padding: 3px 6px;
    border-radius: 4px;
    cursor: pointer;
    outline: none;
}

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

/* ===== Saved Presets Bar ===== */
.saved-presets-bar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 6px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.saved-presets-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.saved-presets-list {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.saved-preset-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    font-size: 11px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.saved-preset-chip:hover {
    background: var(--accent-glow);
    color: var(--accent);
    border-color: var(--accent);
}

.saved-preset-chip .chip-delete {
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    margin-left: 2px;
}

.saved-preset-chip .chip-delete:hover {
    color: var(--red);
}

/* ===== Sentiment Gauge ===== */
.sentiment-container {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 8px 0;
}

.sentiment-gauge {
    position: relative;
    width: 160px;
    height: 80px;
    flex-shrink: 0;
}

.sentiment-gauge svg {
    width: 100%;
    height: 100%;
}

.sentiment-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sentiment-value {
    font-size: 28px;
    font-weight: 700;
}

.sentiment-text {
    font-size: 14px;
    font-weight: 600;
}

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

.sentiment-stats {
    display: flex;
    gap: 20px;
    margin-left: auto;
}

.sentiment-stat {
    text-align: center;
}

.sentiment-stat-val {
    font-size: 18px;
    font-weight: 700;
}

.sentiment-stat-label {
    font-size: 11px;
    color: var(--text-muted);
}

/* ===== Shortcuts Modal ===== */
.shortcut-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sc-row {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.sc-row kbd {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px 8px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 28px;
    text-align: center;
}

.sc-row span {
    color: var(--text-secondary);
}

/* ===== Fullscreen ===== */
body.fullscreen .header,
body.fullscreen .filter-bar,
body.fullscreen .status-bar,
body.fullscreen .ticker-tape,
body.fullscreen .market-status-bar,
body.fullscreen .saved-presets-bar {
    display: none !important;
}

body.fullscreen .table-container,
body.fullscreen .heatmap-container,
body.fullscreen .dashboard-container {
    max-height: 100vh;
}

/* Row selection highlight */
tr.selected td {
    background: var(--accent-glow) !important;
}

/* ===== SEO Footer ===== */
.seo-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 6px 20px 4px;
    flex-shrink: 0;
    opacity: 0.5;
}

.seo-footer-inner {
    max-width: 1200px;
    margin: 0 auto;
}

.seo-footer-brand {
    margin-bottom: 4px;
}

.seo-h1 {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.seo-footer-brand p {
    font-size: 8px;
    color: var(--text-muted);
    line-height: 1.4;
    max-width: 600px;
}

.seo-footer-links {
    display: flex;
    gap: 24px;
    margin-bottom: 4px;
}

.seo-footer-col h2 {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 3px;
}

.seo-footer-col ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0 8px;
}

.seo-footer-col li {
    font-size: 9px;
    color: var(--text-muted);
    opacity: 0.7;
}

.seo-footer-bottom {
    border-top: 1px solid var(--border-color);
    padding-top: 6px;
}

.seo-footer-bottom p {
    font-size: 9px;
    color: var(--text-muted);
    text-align: center;
    opacity: 0.6;
}

@media (max-width: 768px) {
    .seo-footer-links { flex-direction: column; gap: 8px; }
}

/* ===== Language Toggle ===== */
.lang-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

/* ===== Ads ===== */
.ad-container {
    flex-shrink: 0;
}

.ad-leaderboard {
    display: flex;
    justify-content: center;
    padding: 6px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.ad-mid {
    display: flex;
    justify-content: center;
    padding: 6px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.ad-banner {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.ad-label {
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 9px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.6;
}

/* Leaderboard 728x90 */
.ad-728x90 {
    width: 100%;
    max-width: 900px;
    height: 64px;
}

.ad-content-broker {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 20px;
    gap: 16px;
}

.ad-broker-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ad-broker-logo svg {
    display: block;
}

.ad-broker-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.ad-broker-tagline {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 1px;
}

.ad-broker-right {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}

.ad-broker-offer {
    font-size: 12px;
    color: var(--text-secondary);
}

.ad-broker-offer strong {
    color: var(--green);
    font-size: 14px;
}

.ad-cta-btn {
    padding: 7px 18px;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--green);
    color: white;
    white-space: nowrap;
}

.ad-cta-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34,197,94,0.3);
}

.ad-cta-purple {
    background: #7c3aed;
}

.ad-cta-purple:hover {
    box-shadow: 0 4px 12px rgba(124,58,237,0.3);
}

.ad-cta-orange {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
}

.ad-cta-orange:hover {
    box-shadow: 0 4px 12px rgba(245,158,11,0.3);
}

.ad-cta-small {
    padding: 5px 12px;
    font-size: 11px;
    border-radius: 4px;
}

/* Content with sidebar */
.content-with-sidebar {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.content-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.content-main .table-container {
    flex: 1;
    overflow: auto;
}

.content-main .heatmap-container {
    flex: 1;
    overflow: auto;
}

/* Sidebar ads */
.ad-sidebar {
    width: 280px;
    flex-shrink: 0;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    border-left: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.ad-300x250 {
    width: 100%;
    min-height: 220px;
}

.ad-content-vertical {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 20px 16px;
    gap: 10px;
}

.ad-dark-card {
    background: linear-gradient(135deg, var(--bg-elevated) 0%, var(--bg-tertiary) 100%);
    border-radius: var(--radius-md);
}

.ad-vert-badge {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--accent);
    background: var(--accent-glow);
    padding: 2px 8px;
    border-radius: 10px;
}

.ad-vert-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.ad-vert-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.ad-vert-price {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.ad-vert-price span {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.ad-vert-stats {
    display: flex;
    gap: 20px;
    margin-top: 4px;
}

.ad-vert-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.ad-vert-stat strong {
    font-size: 14px;
    color: var(--text-primary);
}

.ad-vert-stat span {
    font-size: 10px;
    color: var(--text-muted);
}

.ad-newsletter-input {
    display: flex;
    gap: 4px;
    width: 100%;
}

.ad-email-input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 11px;
    outline: none;
}

.ad-email-input:focus {
    border-color: var(--accent);
}

.ad-email-input::placeholder {
    color: var(--text-muted);
}

/* Hide sidebar & mid-ad on non-screener views */
body.view-dashboard .content-with-sidebar,
body.view-dashboard .ad-mid,
body.view-dashboard .ad-leaderboard,
body.view-portfolio .content-with-sidebar,
body.view-portfolio .ad-mid,
body.view-portfolio .ad-leaderboard,
body.view-watchlist .ad-mid {
    display: none;
}

/* ===== Responsive ===== */
@media (max-width: 1200px) {
    .ad-sidebar { display: none; }
}

@media (max-width: 1024px) {
    .filter-presets { display: none; }
    .filter-divider { display: none; }
    .dash-grid { grid-template-columns: 1fr; }
    .ad-leaderboard, .ad-mid { display: none; }
}

@media (max-width: 768px) {
    .header { padding: 0 12px; }
    .filter-bar { padding: 8px 12px; }
    .filter-input { width: 65px; }
    td, th { padding: 8px 10px; }
    .logo-text { display: none; }
    .clock { display: none; }
    .search-box { display: none; }
}
