:root {
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;
    --blue-600: #2563eb;
}

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: white;
    color: var(--slate-800);
    -webkit-font-smoothing: antialiased;
}

.layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    height: calc(100vh - 64px);
    overflow: hidden;
}

.top-banner {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    background: white;
    border-bottom: 1px solid var(--slate-200);
    z-index: 1000;
}

.banner-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.banner-logo {
    height: 32px;
    width: auto;
}

.banner-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--slate-900);
    line-height: 1.2;
}

.banner-subtitle {
    font-size: 12px;
    color: var(--slate-500);
    font-weight: 500;
}

.back-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid var(--slate-200);
    color: var(--slate-600);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
}

.back-link:hover {
    background: var(--slate-50);
    border-color: var(--slate-300);
    color: var(--slate-900);
}

.back-link-icon-img {
    height: 16px;
    width: auto;
}

/* Chart Area */
.main-content {
    padding: 32px 60px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    position: relative;
}

.header {
    margin-bottom: 32px;
}

h1 {
    font-size: 32px;
    font-weight: 800;
    margin: 0;
    color: var(--slate-900);
    letter-spacing: -0.025em;
}

.subtitle {
    font-size: 15px;
    color: var(--slate-500);
    margin-top: 8px;
    font-weight: 500;
}

.header .subtitle {
    margin-top: 0;
}

/* Sidebar */
.sidebar {
    background-color: var(--slate-50);
    border-left: 1px solid var(--slate-200);
    display: flex;
    flex-direction: column;
    padding: 32px 24px;
    overflow: hidden;
}

.section-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--slate-400);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Toggle Button */
.toggle-group {
    display: flex;
    background: var(--slate-200);
    padding: 4px;
    border-radius: 12px;
    margin-bottom: 32px;
}

.energy-toggle .toggle-btn {
    font-size: 11px;
    padding: 10px 4px;
    line-height: 1.2;
}

.toggle-btn {
    flex: 1;
    padding: 8px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--slate-500);
    position: relative;
}

.toggle-btn.active {
    background: white;
    color: var(--slate-900);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* CSS Tooltips removed in favor of JS tooltip */

/* Regions List */
.regions-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin-bottom: 24px;
}

.regions-list {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-right: 8px;
}

/* Custom Scrollbar for Regions List */
.regions-list::-webkit-scrollbar {
    width: 6px;
    display: block;
}

.regions-list::-webkit-scrollbar-track {
    background: var(--slate-100);
    border-radius: 10px;
}

.regions-list::-webkit-scrollbar-thumb {
    background: var(--slate-300);
    border-radius: 10px;
    transition: background 0.2s;
}

.regions-list::-webkit-scrollbar-thumb:hover {
    background: var(--slate-400);
}

.region-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--slate-600);
    transition: all 0.1s;
}

.region-item:hover {
    background: var(--slate-200);
    color: var(--slate-900);
}

.region-item.active {
    background: white;
    color: var(--slate-900);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.select-all-btn {
    font-size: 11px;
    color: var(--blue-600);
    cursor: pointer;
    font-weight: 600;
}

/* Controls */
.playback-controls {
    margin-top: auto;
    background: white;
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--slate-100);
}

.top-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.play-pause {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--slate-900);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s;
}

.play-pause:active {
    transform: scale(0.95);
}

.current-year {
    font-size: 24px;
    font-weight: 800;
    color: var(--slate-900);
    font-variant-numeric: tabular-nums;
}

#year-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--slate-200);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    margin: 20px 0;
}

#year-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--slate-900);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s;
}

.speed-selector {
    display: flex;
    gap: 4px;
}

.speed-btn {
    flex: 1;
    padding: 6px;
    font-size: 11px;
    font-weight: 700;
    background: var(--slate-100);
    border: none;
    border-radius: 6px;
    color: var(--slate-500);
    cursor: pointer;
}

.speed-btn.active {
    background: var(--slate-900);
    color: white;
}

/* Visualization Elements */
#viz-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.chart-legend {
    position: absolute;
    right: 60px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    padding: 16px;
    max-height: 70%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: auto;
    transition: opacity 0.2s;
    border: 1px solid var(--slate-100);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    z-index: 100;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--slate-600);
    white-space: nowrap;
}

.chart-legend::-webkit-scrollbar {
    width: 4px;
}

.chart-legend::-webkit-scrollbar-track {
    background: transparent;
}

.chart-legend::-webkit-scrollbar-thumb {
    background: var(--slate-200);
    border-radius: 4px;
}

.triangle-axis {
    stroke: var(--slate-300);
    stroke-width: 1.5;
}

.grid-line {
    stroke: var(--slate-200);
    stroke-width: 1;
    opacity: 0.7;
    transition: all 0.2s ease;
}

.grid-line.highlighted {
    stroke: var(--slate-900);
    stroke-width: 1.5;
    opacity: 1;
}

.axis-label {
    font-size: 14px;
    font-weight: 700;
    fill: var(--slate-800);
    cursor: pointer;
    transition: fill 0.2s ease;
}

.axis-label:hover {
    fill: var(--slate-900);
}

.axis-label.highlighted {
    fill: var(--slate-900);
}

.axis-tick {
    font-size: 11px;
    font-weight: 500;
    fill: var(--slate-400);
    transition: fill 0.2s ease;
}

.axis-tick.highlighted {
    fill: var(--slate-900);
}

.axis-range-label {
    font-size: 11px;
    font-weight: 500;
    fill: var(--slate-400);
    transition: fill 0.2s ease;
    letter-spacing: 0.02em;
}

.axis-range-label.highlighted {
    fill: var(--slate-900);
}

.axis-edge {
    stroke: var(--slate-300);
    stroke-width: 1.5;
    fill: none;
    transition: all 0.2s ease;
}

.axis-edge.highlighted {
    stroke: var(--slate-900);
    stroke-width: 2;
}

.year-trail {
    fill: none;
    stroke-width: 2;
    opacity: 0.6;
    stroke-linecap: round;
}

.year-trail.dimmed {
    opacity: 0.05;
}

.tooltip {
    position: absolute;
    background: var(--slate-900);
    color: white;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
    pointer-events: none;
    opacity: 0;
    z-index: 9999;
    min-width: 180px;
    transition: opacity 0.1s ease;
    transform: translateX(-100%);
}

.tooltip-title {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 12px;
    color: white;
    border-bottom: 1px solid var(--slate-700);
    padding-bottom: 8px;
}

.tooltip-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.tooltip-label {
    color: var(--slate-400);
    font-weight: 500;
}

.tooltip-value {
    font-weight: 700;
    color: white;
}

.tooltip-source {
    font-size: 10px;
    color: var(--slate-500);
    margin-top: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}