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

:root {
    --primary-color: #1e3a8a;
    --primary-light: #3b82f6;
    --success-color: #059669;
    --danger-color: #dc2626;
    --warning-color: #d97706;
    --bg-color: #f1f5f9;
    --card-bg: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --border-color: #cbd5e1;
    --accent-color: #0ea5e9;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.08);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* Header */
.header {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
    color: white;
    padding: 32px 40px;
    border-radius: 8px;
    margin-bottom: 32px;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--accent-color);
}

.header h1 {
    font-size: 2.25rem;
    margin-bottom: 8px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 1rem;
    opacity: 0.85;
    margin-bottom: 20px;
    font-weight: 400;
}

.header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
}

.last-update {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Buttons */
.btn {
    padding: 11px 24px;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.btn-primary {
    background-color: white;
    color: var(--primary-color);
    box-shadow: var(--shadow);
}

.btn-primary:hover {
    background-color: #f8fafc;
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Loading Spinner */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

@keyframes rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.rotating {
    display: inline-block;
    animation: rotate 1s linear infinite;
}

/* Error Message */
.error-message {
    background-color: #fee2e2;
    border-left: 4px solid var(--danger-color);
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.error-icon {
    font-size: 1.5rem;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 28px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card h3 {
    font-size: 1.125rem;
    margin-bottom: 20px;
    color: var(--text-primary);
    font-weight: 600;
    letter-spacing: -0.3px;
}

/* Summary Section */
.summary-section {
    margin-bottom: 30px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.metric-card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    border-top: 3px solid transparent;
}

.metric-card:hover {
    box-shadow: var(--shadow-md);
    border-top-color: var(--primary-light);
}

.metric-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
}

.metric-value {
    font-size: 1.875rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.metric-change {
    font-size: 0.9375rem;
    font-weight: 600;
}

.metric-sublabel {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

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

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

/* Benchmark Section */
.benchmark-section {
    margin-bottom: 30px;
}

.benchmark-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-color);
    border-radius: 6px;
}

.stat-label {
    font-weight: 500;
    color: var(--text-secondary);
}

.stat-value {
    font-weight: 700;
    font-size: 1.125rem;
}

/* Charts */
.charts-section {
    margin-bottom: 30px;
}

.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

canvas {
    max-height: 300px;
}

/* Performers */
.performers-section {
    margin-bottom: 30px;
}

.performer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

.performer-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.performer-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: #f8fafc;
    border-radius: 6px;
    border-left: 3px solid transparent;
    transition: all 0.15s ease;
}

.performer-item:hover {
    background: #f1f5f9;
}

.performer-item.positive {
    border-left-color: var(--success-color);
}

.performer-item.negative {
    border-left-color: var(--danger-color);
}

.performer-ticker {
    font-weight: 600;
    font-size: 0.9375rem;
    font-family: 'Courier New', monospace;
    color: var(--text-primary);
}

.performer-return {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.performer-pnl {
    font-weight: 600;
    font-size: 1rem;
    letter-spacing: -0.3px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    padding: 12px 28px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    color: var(--text-secondary);
    margin-bottom: -2px;
    font-size: 0.9375rem;
}

.tab-btn:hover {
    color: var(--text-primary);
    border-bottom-color: var(--border-color);
}

.tab-btn.active {
    background: transparent;
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Tables */
.table-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.search-input {
    flex: 1;
    padding: 11px 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9375rem;
    transition: all 0.2s ease;
    background: var(--card-bg);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.sort-select {
    padding: 11px 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9375rem;
    cursor: pointer;
    background: var(--card-bg);
    transition: all 0.2s ease;
}

.sort-select:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.table-wrapper {
    overflow-x: auto;
}

.positions-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

.positions-table thead {
    background: #f8fafc;
    position: sticky;
    top: 0;
}

.positions-table th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    border-bottom: 2px solid var(--border-color);
}

.positions-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #e2e8f0;
}

.positions-table tbody tr {
    transition: background-color 0.15s ease;
}

.positions-table tbody tr:hover {
    background: #f8fafc;
}

.ticker-cell {
    font-weight: 600;
    color: var(--primary-color);
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

/* Footer */
.footer {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 40px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.75rem;
    }

    .chart-grid {
        grid-template-columns: 1fr;
    }

    .performer-grid {
        grid-template-columns: 1fr;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

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

    .tabs {
        flex-direction: column;
    }

    .tab-btn {
        border-radius: 8px;
    }
}
