/* Modern Minimalist Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --text: #1f2937;
    --text-light: #6b7280;
    --bg: #ffffff;
    --bg-light: #f9fafb;
    --border: #e5e7eb;
    --positive: #10b981;
    --negative: #ef4444;
    --spacing: 1.5rem;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing);
}

/* Header */
header {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: var(--spacing) 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

nav {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

nav a {
    text-decoration: none;
    color: var(--text-light);
    font-weight: 500;
    transition: color 0.2s;
}

nav a:hover,
nav a.active {
    color: var(--primary);
}

/* Main Content */
main {
    padding: calc(var(--spacing) * 2) 0;
    min-height: calc(100vh - 200px);
}

.hero {
    text-align: center;
    padding: calc(var(--spacing) * 3) 0;
    margin-bottom: calc(var(--spacing) * 2);
}

.hero h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.hero p {
    font-size: 1.25rem;
    color: var(--text-light);
}

/* Stats */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing);
    margin-bottom: calc(var(--spacing) * 2);
}

.stat-card {
    background: var(--bg-light);
    padding: var(--spacing);
    border-radius: 8px;
    text-align: center;
}

.stat-card h3 {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

/* Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--spacing);
    margin-top: var(--spacing);
}

.card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: var(--spacing);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.card h3 {
    margin-bottom: 0.5rem;
}

.card h3 a {
    color: var(--text);
    text-decoration: none;
}

.card h3 a:hover {
    color: var(--primary);
}

.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0.5rem 0;
}

.value {
    font-size: 1.25rem;
    font-weight: 600;
}

.change {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 500;
}

.change.positive {
    color: var(--positive);
    background: rgba(16, 185, 129, 0.1);
}

.change.negative {
    color: var(--negative);
    background: rgba(239, 68, 68, 0.1);
}

.chart-preview img {
    width: 100%;
    height: auto;
    border-radius: 4px;
    margin-top: 0.5rem;
}

/* Detail Page */
.detail-header {
    margin-bottom: calc(var(--spacing) * 2);
}

.back-link {
    display: inline-block;
    margin-bottom: 1rem;
    color: var(--primary);
    text-decoration: none;
}

.back-link:hover {
    text-decoration: underline;
}

.type-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--bg-light);
    border-radius: 4px;
    font-size: 0.875rem;
    color: var(--text-light);
    margin-top: 0.5rem;
}

.metrics {
    margin-bottom: calc(var(--spacing) * 2);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing);
    margin-top: var(--spacing);
}

.metric {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing);
    background: var(--bg-light);
    border-radius: 8px;
}

.metric-label {
    color: var(--text-light);
}

.metric-value {
    font-weight: 600;
}

.charts {
    margin-top: calc(var(--spacing) * 2);
}

.chart-container {
    margin-bottom: calc(var(--spacing) * 2);
}

.chart-container h3 {
    margin-bottom: var(--spacing);
    font-size: 1.25rem;
}

.chart-image {
    width: 100%;
    height: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

/* Footer */
footer {
    background: var(--bg-light);
    border-top: 1px solid var(--border);
    padding: var(--spacing) 0;
    margin-top: calc(var(--spacing) * 3);
    text-align: center;
    color: var(--text-light);
}

/* History Tables */
.history {
    margin: calc(var(--spacing) * 2) 0;
}

.history-table-container {
    overflow-x: auto;
    margin: var(--spacing) 0;
}

/* Outer table - contains period columns */
.history-table-outer {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    background: #ffffff;
}

.history-table-outer td {
    padding: 0.5rem;
    vertical-align: top;
    border: none;
}

.period-cell {
    padding: 0.5rem;
}

.period-header {
    font-weight: 600;
    text-align: center;
    margin-bottom: 0.5rem;
    padding: 0.25rem;
}

/* Nested table - contains Rates and Vols rows */
.history-table-nested {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    background: #ffffff;
}

.history-table-nested td {
    padding: 0.25rem 0.5rem;
    background: #ffffff;
    border: none;
}

/* Header row for nested table */
.history-table-nested th {
    font-weight: 600;
    text-align: center;
    border: none;
}

/* Header row value cells - right aligned to match values below */
.history-table-nested th.value-col {
    text-align: right;
}

/* Label column - flexible alignment */
.history-table-nested .label-col {
    font-weight: 600;
    min-width: 100px;
}

.history-table-nested .label-col.label-left {
    text-align: left;
}

.history-table-nested .label-col.label-right {
    text-align: right;
}

/* Value cells - always right aligned, with border */
.history-table-nested .value-col {
    text-align: right;
    min-width: 60px;
    font-weight: 400;
    border: 1px solid #000000;
}

/* Value cells with no border - reusable class */
.history-table-nested .value-col.noborder-col {
    border: none;
}

/* Value cell links - no decoration */
.history-table-nested .value-col a {
    color: inherit;
    text-decoration: none;
}

.history-table-nested .value-col a:hover {
    text-decoration: none;
}

/* Responsive */
@media (max-width: 768px) {
    .hero h2 {
        font-size: 2rem;
    }
    
    .grid {
        grid-template-columns: 1fr;
    }
    
    nav {
        gap: 1rem;
    }
    
    .history-table-outer {
        font-size: 0.75rem;
    }
    
    .history-table-nested {
        font-size: 0.75rem;
    }
    
    .history-table-nested td {
        padding: 0.25rem;
    }
}