:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-purple: #a855f7;
    --accent-yellow: #fbbf24;
    --border-color: #475569;
}

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

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

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    text-align: center;
    margin-bottom: 3rem;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.last-updated {
    margin-top: 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.btn-refresh {
    margin-top: 1rem;
    padding: 0.75rem 1.5rem;
    background: var(--accent-blue);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.btn-refresh:hover {
    background: var(--accent-purple);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.5);
}

.btn-refresh:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s;
}

.card:hover {
    transform: translateY(-4px);
}

.card-title {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.card-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--accent-blue);
}

/* Sections */
.section {
    background: var(--bg-secondary);
    padding: 2rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

h2 {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

/* Opportunities */
.opportunities-container {
    max-height: 600px;
    overflow-y: auto;
}

.opportunities-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.opportunity-card {
    background: var(--bg-card);
    padding: 1.25rem;
    border-radius: 8px;
    border-left: 4px solid var(--accent-blue);
    transition: all 0.2s;
}

.opportunity-card:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.opp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.opp-station {
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.opp-signal {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
}

.signal-buy-yes {
    background: var(--accent-green);
    color: white;
}

.signal-buy-no {
    background: var(--accent-red);
    color: white;
}

.signal-avoid {
    background: var(--accent-yellow);
    color: #0f172a;
}

.opp-description {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.opp-magnitude {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.opp-type {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: capitalize;
}

.no-opportunities {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

/* Charts */
.chart-section {
    background: var(--bg-secondary);
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
}

.chart-full-width {
    width: 100%;
}

.chart-section canvas {
    height: 400px !important;
}

/* Table */
.table-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: center;
}

.table-controls input {
    flex: 1;
    padding: 0.75rem;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
}

.table-controls input:focus {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

.btn-secondary {
    padding: 0.75rem 1.5rem;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

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

.table-wrapper {
    position: relative;
    max-height: 600px;
    overflow: hidden;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.table-container {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 600px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
}

thead {
    background: var(--bg-primary);
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

th.sortable:hover {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-blue);
}

td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

tbody tr:hover {
    background: rgba(59, 130, 246, 0.1);
}

/* Table cell styles - gradient background color coding for diff columns */
/* Neutral (exactly 0) */
.diff-neutral {
    background-color: transparent;
    color: var(--text-secondary);
}

/* Positive values (warmer) - red backgrounds, progressively more intense */
.diff-pos-0 {
    background-color: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

.diff-pos-1 {
    background-color: rgba(239, 68, 68, 0.25);
    color: #f87171;
}

.diff-pos-2 {
    background-color: rgba(239, 68, 68, 0.35);
    color: #fca5a5;
    font-weight: bold;
}

.diff-pos-3 {
    background-color: rgba(239, 68, 68, 0.5);
    color: #fecaca;
    font-weight: bold;
}

.diff-pos-4 {
    background-color: rgba(239, 68, 68, 0.65);
    color: #fee2e2;
    font-weight: bold;
}

.diff-pos-5 {
    background-color: rgba(239, 68, 68, 0.8);
    color: #ffffff;
    font-weight: bold;
}

/* Negative values (cooler) - blue backgrounds, progressively more intense */
.diff-neg-0 {
    background-color: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
}

.diff-neg-1 {
    background-color: rgba(59, 130, 246, 0.25);
    color: #60a5fa;
}

.diff-neg-2 {
    background-color: rgba(59, 130, 246, 0.35);
    color: #93c5fd;
    font-weight: bold;
}

.diff-neg-3 {
    background-color: rgba(59, 130, 246, 0.5);
    color: #bfdbfe;
    font-weight: bold;
}

.diff-neg-4 {
    background-color: rgba(59, 130, 246, 0.65);
    color: #dbeafe;
    font-weight: bold;
}

.diff-neg-5 {
    background-color: rgba(59, 130, 246, 0.8);
    color: #ffffff;
    font-weight: bold;
}

.action-yes {
    color: var(--accent-green);
    font-weight: bold;
}

.action-no {
    color: var(--accent-red);
    font-weight: bold;
}

.action-hold {
    color: var(--text-secondary);
}

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

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

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

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

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

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

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.btn-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-close:hover {
    background: var(--accent-red);
    color: white;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.column-groups {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.column-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-group-action {
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

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

.column-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.column-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.column-checkbox:hover {
    border-color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.1);
}

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

.column-checkbox span {
    color: var(--text-primary);
    font-size: 0.9rem;
}

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

.btn-primary {
    padding: 0.75rem 2rem;
    background: var(--accent-blue);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

/* Responsive */
@media (max-width: 1200px) {
    .chart-section canvas {
        height: 300px !important;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    h1 {
        font-size: 1.75rem;
    }

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

    .opportunities-list {
        grid-template-columns: 1fr;
    }

    .table-controls {
        flex-direction: column;
    }
}
