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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #0d1117;
    color: #c9d1d9;
    overflow-x: hidden;
}

.container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background-color: #161b22;
    border-right: 1px solid #30363d;
    transition: width 0.3s ease;
    position: fixed;
    height: 100vh;
    z-index: 1000;
    overflow: hidden;
}

.sidebar.collapsed {
    width: 1cm;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #30363d;
    display: flex;
    justify-content: space-between;
    align-items: center;
    white-space: nowrap;
    min-height: 60px;
}

.sidebar-header h2 {
    font-size: 18px;
    color: #58a6ff;
    transition: opacity 0.3s ease;
    overflow: hidden;
}

.sidebar.collapsed .sidebar-header {
    padding: 20px 5px;
    justify-content: center;
}

.sidebar.collapsed .sidebar-header h2 {
    opacity: 0;
    width: 0;
}

.sidebar-toggle {
    background-color: transparent;
    border: none;
    color: #c9d1d9;
    cursor: pointer;
    font-size: 20px;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    flex-shrink: 0;
    min-width: 30px;
}

.sidebar-toggle:hover {
    color: #58a6ff;
}

.sidebar-nav {
    padding: 10px 0;
}

.nav-item {
    padding: 12px 20px;
    cursor: pointer;
    transition: background-color 0.2s;
    border-left: 3px solid transparent;
    white-space: nowrap;
    overflow: hidden;
}

.nav-item:hover {
    background-color: #21262d;
}

.nav-item.active {
    background-color: #21262d;
    border-left-color: #58a6ff;
    color: #58a6ff;
}

.sidebar.collapsed .nav-item {
    padding: 12px 5px;
    font-size: 0;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 250px;
    transition: margin-left 0.3s ease;
    padding: 20px;
}

.main-content.expanded {
    margin-left: 1cm;
}

/* Page Content */
.page {
    display: none;
}

.page.active {
    display: block;
}

.page-header {
    margin-bottom: 30px;
}

.page-header h1 {
    font-size: 32px;
    margin-bottom: 10px;
    color: #58a6ff;
}

.page-header p {
    color: #8b949e;
    font-size: 16px;
}

/* Chart Sections */
.chart-section {
    background-color: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 30px;
}

.chart-section h2 {
    font-size: 20px;
    margin-bottom: 15px;
    color: #c9d1d9;
}

.chart-controls {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.btn-group {
    display: flex;
    gap: 5px;
}

.btn {
    padding: 8px 16px;
    background-color: #21262d;
    border: 1px solid #30363d;
    color: #c9d1d9;
    cursor: pointer;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s;
}

.btn:hover {
    background-color: #30363d;
}

.btn.active {
    background-color: #58a6ff;
    border-color: #58a6ff;
    color: #0d1117;
}

select {
    padding: 8px 12px;
    background-color: #21262d;
    border: 1px solid #30363d;
    color: #c9d1d9;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: #58a6ff;
}

.chart-container {
    min-height: 400px;
    width: 100%;
}

.chart-container > div {
    width: 100% !important;
}

label {
    color: #8b949e;
    font-size: 14px;
    margin-right: 8px;
}


/* Latest Date Display - bottom of sidebar */
.latest-date-container {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    padding: 12px 20px;
    border-top: 1px solid #30363d;
    text-align: center;
    font-size: 13px;
}

.sidebar.collapsed .latest-date-container {
    display: none; /* hide when sidebar is collapsed */
}

.latest-date-label {
    color: #8b949e;
    margin-bottom: 4px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.latest-date-value {
    color: #58a6ff;
    font-weight: 600;
    font-size: 14px;
}


/* Top 5 Snapshot */
.top5-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.top5-card {
    background-color: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.top5-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.top5-card .rank {
    font-size: 2.2rem;
    font-weight: bold;
    color: #58a6ff;
    margin-bottom: 8px;
    line-height: 1;
}

.top5-card .ticker {
    font-size: 1.5rem;
    font-weight: 700;
    color: #c9d1d9;
    margin: 8px 0 4px;
}

.top5-card .name {
    font-size: 0.95rem;
    color: #8b949e;
    margin-bottom: 12px;
    line-height: 1.3;
    min-height: 2.6em; /* prevent jumping when names are different length */
}

.top5-card .short-pct {
    font-size: 1.8rem;
    font-weight: bold;
    color: #f85149; /* red for short interest */
}

.top5-card.loading {
    background-color: #0d1117;
    color: #8b949e;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    font-style: italic;
}


.watchlist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 24px;
}

.watchlist-card {
    background-color: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 20px;
    transition: all 0.2s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.watchlist-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    border-color: #58a6ff44;
}

.watchlist-card h3 {
    margin: 0 0 16px 0;
    color: #58a6ff;
    font-size: 1.35rem;
    font-weight: 600;
}

.watchlist-links {
    list-style: none;
    margin: 0;
    padding: 0;
    flex-grow: 1;
}

.watchlist-links li {
    margin-bottom: 12px;
}

.watchlist-links a {
    color: #c9d1d9;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.watchlist-links a:hover {
    background-color: #21262d;
    color: #58a6ff;
}

.external-icon {
    font-size: 0.9rem;
    opacity: 0.7;
    margin-left: 8px;
    transition: all 0.2s;
}

.watchlist-links a:hover .external-icon {
    opacity: 1;
    transform: translate(2px, -2px);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .watchlist-grid {
        grid-template-columns: 1fr;
    }
}