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

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a25;
    --text-primary: #ffffff;
    --text-secondary: #8b8b9e;
    --accent: #6366f1;
    --green: #22c55e;
    --red: #ef4444;
    --border: #2a2a3a;
}

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

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

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

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.connection-status {
    font-size: 0.75rem;
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    background: var(--bg-card);
    color: var(--text-secondary);
}

.connection-status.connected {
    background: rgba(34, 197, 94, 0.1);
    color: var(--green);
}

.connection-status.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--red);
}

.index-display {
    text-align: center;
    padding: 3rem 2rem;
    background: var(--bg-secondary);
    border-radius: 1rem;
    border: 1px solid var(--border);
    margin-bottom: 2rem;
}

.index-price {
    font-size: 4rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 0.5rem;
}

.index-change {
    font-size: 1.25rem;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.index-change.positive {
    color: var(--green);
}

.index-change.negative {
    color: var(--red);
}

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

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

.chart-header h2 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.chart-tabs {
    display: flex;
    gap: 0.5rem;
}

.chart-tab {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.chart-tab:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.chart-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

#indexChart {
    height: 300px;
    width: 100%;
}

.performance-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.perf-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1rem;
    text-align: center;
}

.perf-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.perf-value {
    font-size: 1.25rem;
    font-weight: 600;
}

.holdings {
    margin-top: 2rem;
}

.holdings h2 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.holdings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.holding-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.25rem;
    transition: border-color 0.2s, transform 0.2s;
}

.holding-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.holding-card.flash-green {
    animation: flashGreen 0.3s ease;
}

.holding-card.flash-red {
    animation: flashRed 0.3s ease;
}

@keyframes flashGreen {
    0%, 100% { background: var(--bg-card); }
    50% { background: rgba(34, 197, 94, 0.15); }
}

@keyframes flashRed {
    0%, 100% { background: var(--bg-card); }
    50% { background: rgba(239, 68, 68, 0.15); }
}

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

.holding-header .symbol {
    font-weight: 600;
    font-size: 1.125rem;
}

.holding-header .weight {
    font-size: 0.875rem;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
}

.holding-price {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.holding-change {
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.holding-change.positive {
    color: var(--green);
}

.holding-change.negative {
    color: var(--red);
}

.holding-contribution {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--text-secondary);
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

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

    .index-price {
        font-size: 2.5rem;
    }

    .index-display {
        padding: 2rem 1rem;
    }

    header h1 {
        font-size: 1.25rem;
    }

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

    .chart-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    #indexChart {
        height: 250px;
    }
}
