* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #0f172a;
    color: #e2e8f0;
    min-height: 100vh;
}

/* New signal highlight animation */
@keyframes signal-highlight {
    0% {
        background-color: #22c55e;
        box-shadow: 0 0 20px rgba(34, 197, 94, 0.6);
    }
    100% {
        background-color: transparent;
        box-shadow: none;
    }
}

.new-signal-highlight {
    animation: signal-highlight 10s ease-out;
}

/* Header */
header {
    background: #1e293b;
    border-bottom: 1px solid #334155;
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1920px;
    margin: 0 auto;
}

h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #f8fafc;
}

.header-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #334155;
    border-radius: 6px;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #64748b;
}

.status-indicator.connected {
    background: #10b981;
}

.status-indicator.disconnected {
    background: #ef4444;
}

/* Controls Bar */
.controls-bar {
    background: #1e293b;
    border-bottom: 1px solid #334155;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.panel-toggles, .view-controls, .price-filter {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.panel-toggles label, .view-controls label, .price-filter label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
}

.price-filter input[type="number"] {
    background: #334155;
    color: #e2e8f0;
    border: 1px solid #475569;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

input[type="checkbox"] {
    cursor: pointer;
}

select {
    background: #334155;
    color: #e2e8f0;
    border: 1px solid #475569;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-secondary {
    background: #475569;
    color: white;
}

.btn-secondary:hover {
    background: #64748b;
}

.control-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #334155;
    color: #e2e8f0;
    border: 1px solid #475569;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
}

.control-btn:hover {
    background: #475569;
    border-color: #64748b;
}

.control-btn.paused {
    background: #10b981;
    border-color: #059669;
    color: white;
}

.control-btn.paused:hover {
    background: #059669;
}

/* GridStack Container */
.grid-stack {
    margin: 1.5rem;
}

/* Scanner Panel */
.scanner-panel {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    background: #334155;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #475569;
    cursor: move;
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.95rem;
}

.signal-count {
    background: #3b82f6;
    color: white;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.panel-controls {
    display: flex;
    gap: 0.5rem;
}

.panel-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.panel-btn:hover {
    background: #475569;
    color: #e2e8f0;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

/* Signals Table */
.signals-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.signals-table thead {
    position: sticky;
    top: 0;
    background: #334155;
    z-index: 10;
}

.signals-table th {
    padding: 0.75rem 0.5rem;
    text-align: left;
    font-weight: 600;
    color: #94a3b8;
    border-bottom: 1px solid #475569;
}

.signals-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 1.5rem;
}

.signals-table th.sortable:hover {
    color: #e2e8f0;
    background: #475569;
}

.signals-table th.sortable::after {
    content: '⇅';
    position: absolute;
    right: 0.5rem;
    opacity: 0.3;
    font-size: 0.75rem;
}

.signals-table th.sort-asc::after {
    content: '↑';
    opacity: 1;
    color: #3b82f6;
}

.signals-table th.sort-desc::after {
    content: '↓';
    opacity: 1;
    color: #3b82f6;
}

.signals-table td {
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid #334155;
}

.signals-table tbody tr {
    transition: background 0.2s;
}

.signals-table tbody tr:hover {
    background: #334155;
}

.signal-type {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.signal-type.bullish {
    background: #065f46;
    color: #10b981;
}

.signal-type.bearish {
    background: #7f1d1d;
    color: #ef4444;
}

.signal-type.neutral {
    background: #1e3a8a;
    color: #3b82f6;
}

.symbol {
    font-weight: 600;
    color: #f8fafc;
}

.price {
    font-family: 'Courier New', monospace;
    color: #e2e8f0;
}

.timestamp {
    color: #94a3b8;
    font-size: 0.8rem;
}

/* News Indicator Styles */
.news-indicator {
    cursor: pointer;
    font-size: 1rem;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.news-indicator:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.1);
}

.news-indicator.news-hot {
    color: #ef4444;
    text-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

.news-indicator.news-warm {
    color: #f97316;
    text-shadow: 0 0 6px rgba(249, 115, 22, 0.4);
}

.news-indicator.news-mild {
    color: #eab308;
}

.news-indicator.news-cold {
    color: #22c55e;
}

.news-indicator.news-none {
    color: #64748b;
    opacity: 0.5;
}

.news-count-badge {
    font-size: 0.65rem;
    font-weight: 600;
    min-width: 1rem;
    text-align: center;
}

/* News Tooltip/Popup */
.news-tooltip {
    position: fixed;
    z-index: 3000;
    background: #1e293b;
    border: 1px solid #475569;
    border-radius: 8px;
    padding: 1rem;
    max-width: 400px;
    min-width: 300px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: none;
}

.news-tooltip.show {
    display: block;
}

.news-tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #334155;
}

.news-tooltip-title {
    font-weight: 600;
    color: #f8fafc;
}

.news-tooltip-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0.25rem;
}

.news-tooltip-close:hover {
    color: #e2e8f0;
}

.news-tooltip-item {
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #334155;
}

.news-tooltip-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.news-tooltip-headline {
    font-size: 0.875rem;
    color: #e2e8f0;
    margin-bottom: 0.25rem;
    line-height: 1.4;
}

.news-tooltip-headline a {
    color: #60a5fa;
    text-decoration: none;
}

.news-tooltip-headline a:hover {
    text-decoration: underline;
}

.news-tooltip-meta {
    font-size: 0.75rem;
    color: #64748b;
    display: flex;
    gap: 0.75rem;
}

.news-tooltip-age {
    font-weight: 500;
}

.news-tooltip-age.hot {
    color: #ef4444;
}

.news-tooltip-age.warm {
    color: #f97316;
}

.news-tooltip-age.mild {
    color: #eab308;
}

.news-tooltip-age.cold {
    color: #22c55e;
}

/* News Panel Styles */
.news-panel-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.news-panel-item {
    background: #334155;
    border-radius: 6px;
    padding: 0.75rem;
    transition: all 0.2s;
}

.news-panel-item:hover {
    background: #475569;
}

.news-panel-item.hot {
    border-left: 3px solid #ef4444;
}

.news-panel-item.warm {
    border-left: 3px solid #f97316;
}

.news-panel-item.mild {
    border-left: 3px solid #eab308;
}

.news-panel-item.cold {
    border-left: 3px solid #22c55e;
}

.news-panel-headline {
    font-size: 0.875rem;
    color: #e2e8f0;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.news-panel-headline a {
    color: #60a5fa;
    text-decoration: none;
}

.news-panel-headline a:hover {
    text-decoration: underline;
}

.news-panel-symbols {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

.news-panel-symbol {
    background: #1e293b;
    color: #94a3b8;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.news-panel-symbol:hover {
    background: #3b82f6;
    color: white;
}

.news-panel-meta {
    font-size: 0.75rem;
    color: #64748b;
    display: flex;
    justify-content: space-between;
}

.news-panel-age {
    font-weight: 500;
}

.news-panel-age.hot {
    color: #ef4444;
}

.news-panel-age.warm {
    color: #f97316;
}

.news-panel-age.mild {
    color: #eab308;
}

.news-panel-age.cold {
    color: #22c55e;
}

.news-panel-empty {
    text-align: center;
    padding: 2rem;
    color: #64748b;
}

.news-panel-loading {
    text-align: center;
    padding: 2rem;
    color: #94a3b8;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #64748b;
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Dashboard Empty State (no panels) */
.dashboard-empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: #94a3b8;
    background: #1e293b;
    border: 2px dashed #334155;
    border-radius: 12px;
    margin: 2rem;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.dashboard-empty-state h2 {
    color: #f8fafc;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.dashboard-empty-state p {
    color: #94a3b8;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.dashboard-empty-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
}

.btn-large {
    padding: 0.75rem 2rem;
    font-size: 1rem;
}

/* New Signals Badge */
.new-signals-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: #ef4444;
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    animation: pulse-badge 1.5s ease-in-out infinite;
    margin-left: 0.5rem;
}

.new-signals-badge:hover {
    background: #dc2626;
}

@keyframes pulse-badge {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 4px rgba(239, 68, 68, 0);
    }
}

/* Infinite Scroll Loader */
.infinite-scroll-loader {
    text-align: center;
    padding: 1rem;
    color: #94a3b8;
    font-size: 0.875rem;
}

.infinite-scroll-loader span {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.infinite-scroll-loader span::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid #475569;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Pagination Controls */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: #334155;
    border-top: 1px solid #475569;
    margin-top: 0.5rem;
    border-radius: 0 0 6px 6px;
}

.pagination-prev,
.pagination-next {
    background: #475569;
    border: 1px solid #64748b;
    color: #e2e8f0;
    padding: 0.4rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.pagination-prev:hover:not(:disabled),
.pagination-next:hover:not(:disabled) {
    background: #64748b;
    border-color: #94a3b8;
}

.pagination-prev:disabled,
.pagination-next:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-info {
    color: #94a3b8;
    font-size: 0.8rem;
    font-weight: 500;
    min-width: 100px;
    text-align: center;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
}

.modal-content h3 {
    margin-bottom: 1.5rem;
    color: #f8fafc;
}

.modal-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.panel-option {
    background: #334155;
    border: 2px solid #475569;
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.2s;
    color: #e2e8f0;
    font-size: 1rem;
}

.panel-option:hover {
    background: #475569;
    border-color: #3b82f6;
}

.panel-option .icon {
    font-size: 2rem;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #1e293b;
}

::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    /* Header adjustments */
    header {
        padding: 0.75rem 1rem;
    }

    .header-content {
        flex-direction: column;
        gap: 0.75rem;
    }

    h1 {
        font-size: 1.2rem;
    }

    .header-controls {
        width: 100%;
        justify-content: space-between;
    }

    .connection-status {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }

    /* Controls bar */
    .controls-bar {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.75rem 1rem;
    }

    .panel-toggles, .view-controls, .price-filter {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.75rem;
        width: 100%;
    }

    .price-filter label {
        font-size: 0.8rem;
    }

    .price-filter input[type="number"] {
        width: 60px !important;
    }

    .view-controls label {
        font-size: 0.8rem;
    }

    .view-controls select {
        font-size: 0.8rem;
        padding: 0.2rem 0.4rem;
    }

    /* Grid container */
    .grid-stack {
        margin: 0.5rem;
    }

    /* Panel adjustments */
    .scanner-panel {
        border-radius: 6px;
    }

    .panel-header {
        padding: 0.5rem 0.75rem;
    }

    .panel-title {
        font-size: 0.85rem;
    }

    .panel-content {
        padding: 0.5rem;
    }

    /* Table - hide non-essential columns on mobile */
    /* Keep: Symbol, Signal, Price, Volume, Time */
    /* Hide: Details (4), RVOL (6), Gap % (7), News (8) */
    .signals-table th:nth-child(4),
    .signals-table td:nth-child(4),
    .signals-table th:nth-child(6),
    .signals-table td:nth-child(6),
    .signals-table th:nth-child(7),
    .signals-table td:nth-child(7),
    .signals-table th:nth-child(8),
    .signals-table td:nth-child(8) {
        display: none;
    }

    .signals-table {
        font-size: 0.8rem;
    }

    .signals-table th {
        padding: 0.5rem 0.25rem;
        font-size: 0.75rem;
    }

    .signals-table td {
        padding: 0.5rem 0.25rem;
    }

    .signal-type {
        padding: 0.2rem 0.35rem;
        font-size: 0.65rem;
    }

    .timestamp {
        font-size: 0.7rem;
    }

    /* Buttons - touch-friendly sizing (min 44px tap target) */
    .btn {
        min-height: 44px;
        padding: 0.6rem 1rem;
    }

    .panel-btn {
        min-width: 44px;
        min-height: 44px;
        padding: 0.5rem;
    }

    /* Modal adjustments */
    .modal-content {
        padding: 1.5rem;
        margin: 1rem;
        max-height: 90vh;
        overflow-y: auto;
    }

    .panel-option {
        padding: 0.75rem;
        min-height: 44px;
    }

    .panel-option .icon {
        font-size: 1.5rem;
    }

    /* Empty state */
    .empty-state {
        padding: 2rem 0.5rem;
    }

    .empty-state-icon {
        font-size: 2rem;
    }
}

/* Extra small devices (phones in portrait) */
@media (max-width: 480px) {
    h1 {
        font-size: 1rem;
    }

    .header-controls {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .btn {
        font-size: 0.75rem;
        padding: 0.5rem 0.75rem;
    }

    /* Even more compact table */
    .signals-table {
        font-size: 0.75rem;
    }

    .signals-table th,
    .signals-table td {
        padding: 0.4rem 0.2rem;
    }

    /* Stack price filter vertically on very small screens */
    .price-filter {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Replay badge for historical replay signals */
.replay-badge {
    display: inline-block;
    margin-left: 4px;
    padding: 1px 4px;
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    background: #8b5cf6;
    border-radius: 3px;
    vertical-align: middle;
}
