:root {
    --primary-color: #3498db;
    --primary-dark: #2980b9;
    --secondary-color: #2c3e50;
    --light-color: #f8f9fa;
    --border-color: #e9ecef;
    --text-color: #212529;
    --text-muted: #6c757d;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --shadow: 0 4px 12px rgba(0,0,0,0.1);

    --skeleton-base: #ebebeb;
    --skeleton-shine: #f5f5f5;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f4f7f9;
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 20px;
}

.container {
    background-color: white;
    padding: 30px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    max-width: 1100px;
    width: 100%;
    overflow-x: hidden;
}

.header {
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    color: var(--secondary-color);
    margin-bottom: 15px;
    font-size: 2.2em;
    position: relative;
    display: inline-block;
}

h1::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -8px;
    transform: translateX(-50%);
    width: 100px;
    height: 3px;
    background-color: var(--primary-color);
    border-radius: 3px;
}

p.description {
    font-size: 1.05em;
    color: var(--text-muted);
    max-width: 800px;
    margin: 0 auto 25px;
}

.tabs-container {
    margin-bottom: 20px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) var(--border-color);
}

.tabs-container::-webkit-scrollbar {
    height: 4px;
}

.tabs-container::-webkit-scrollbar-thumb {
    background-color: var(--primary-color);
}

.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1px;
}

.tab {
    padding: 12px 20px;
    cursor: pointer;
    font-weight: 500;
    border-radius: 6px 6px 0 0;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    border-bottom: none;
    margin-right: 4px;
    color: var(--text-muted);
    white-space: nowrap;
}

.tab:hover {
    color: var(--primary-color);
    background-color: rgba(52, 152, 219, 0.05);
}

.tab.active {
    color: var(--primary-color);
    border-color: var(--border-color);
    border-bottom: 2px solid white;
    background-color: white;
    margin-bottom: -1px;
}

.tab-icon {
    margin-right: 8px;
}

.tab-skeleton-indicator {
    display: inline-block;
    margin-left: 8px;
    vertical-align: middle;
    width: 30px;
    height: 12px;
    background: linear-gradient(90deg, var(--skeleton-base) 0%, var(--skeleton-shine) 50%, var(--skeleton-base) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 15px;
}

.years-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.years-select {
    padding: 8px 15px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: white;
    color: var(--text-color);
    font-size: 0.95em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.years-select:hover, .years-select:focus {
    border-color: var(--primary-color);
    outline: none;
}

.chart-options {
    display: flex;
    align-items: center;
    gap: 15px;
}

.chart-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.chart-option:hover {
    background-color: rgba(52, 152, 219, 0.1);
}

.chart-option input {
    margin-right: 5px;
}

.skeleton-container {
    width: 100%;
    margin: 20px 0;
}

.skeleton-chart {
    height: 450px;
    border-radius: 10px;
    background: linear-gradient(90deg, var(--skeleton-base) 0%, var(--skeleton-shine) 50%, var(--skeleton-base) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    margin-bottom: 20px;
}

.skeleton-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 20px;
}

.skeleton-stat-card {
    flex: 1;
    min-width: 230px;
    height: 120px;
    border-radius: 8px;
    background: linear-gradient(90deg, var(--skeleton-base) 0%, var(--skeleton-shine) 50%, var(--skeleton-base) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.skeleton-text {
    height: 30px;
    width: 200px;
    margin: 0 auto;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--skeleton-base) 0%, var(--skeleton-shine) 50%, var(--skeleton-base) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.error-message {
    color: var(--danger-color);
    padding: 12px;
    background-color: rgba(220, 53, 69, 0.1);
    border-radius: 6px;
    margin: 15px 0;
    font-weight: 500;
}

.chart-container {
    position: relative;
    height: 450px;
    width: 100%;
    margin: 20px auto;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 20px;
    background-color: white;
    overflow: visible !important;
}

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

.chart-title {
    font-size: 1.2em;
    color: var(--secondary-color);
    font-weight: 600;
}

.chart-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 20px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

.chartjs-size-monitor,
.chartjs-render-monitor {
    overflow: visible !important;
}

canvas + div {
    overflow: visible !important;
}

.stat-card {
    flex: 1;
    min-width: 230px;
    background-color: var(--light-color);
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.stat-title {
    color: var(--text-muted);
    font-size: 0.9em;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.5em;
    font-weight: 600;
    color: var(--secondary-color);
}

.stat-change {
    margin-top: 5px;
    font-size: 0.9em;
}

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

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

.footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.9em;
}

.data-source {
    display: flex;
    align-items: center;
    gap: 8px;
}

.data-source a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

.data-source a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.tooltip {
    position: relative;
    display: inline-block;
    margin-left: 5px;
}

.tooltip-icon {
    color: var(--text-muted);
    font-size: 0.9em;
    cursor: help;
}

.tooltip-text {
    visibility: hidden;
    width: 200px;
    background-color: var(--secondary-color);
    color: white;
    text-align: center;
    border-radius: 6px;
    padding: 8px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.85em;
    line-height: 1.4;
    box-shadow: 0 3px 8px rgba(0,0,0,0.2);
}

.tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: var(--secondary-color) transparent transparent transparent;
}

.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

.no-data-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-style: italic;
}

.skeleton-stats-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 20px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

.skeleton-stat-title {
    width: 60%;
    height: 14px;
    margin-bottom: 10px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--skeleton-base) 0%, var(--skeleton-shine) 50%, var(--skeleton-base) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.skeleton-stat-value {
    width: 80%;
    height: 28px;
    margin-bottom: 10px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--skeleton-base) 0%, var(--skeleton-shine) 50%, var(--skeleton-base) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.skeleton-stat-subtext {
    width: 70%;
    height: 12px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--skeleton-base) 0%, var(--skeleton-shine) 50%, var(--skeleton-base) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* Responsive adjustments */
@media (max-width: 992px) {
    .container {
        padding: 25px 20px;
    }

    .chart-container, .skeleton-chart {
        height: 400px;
    }
}

@media (max-width: 768px) {
    h1 {
        font-size: 1.8em;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .years-control, .chart-options {
        justify-content: space-between;
    }

    .chart-stats, .skeleton-stats {
        gap: 15px;
    }

    .footer {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .data-source {
        justify-content: center;
    }

    .skeleton-stat-card {
        min-width: 100%;
    }
    .chart-container {
        padding-bottom: 40px;
        margin-bottom: 30px;
        min-height: 350px;
    }
    #indicator-chart {
        height: calc(100% - 30px) !important;
    }
}

@media (max-width: 576px) {
    .container {
        padding: 20px 15px;
        border-radius: 12px;
    }

    h1 {
        font-size: 1.6em;
    }

    .chart-container, .skeleton-chart {
        height: 350px;
        padding: 15px;
    }

    .chart-title {
        font-size: 1.1em;
    }

    .stat-card, .skeleton-stat-card {
        min-width: 100%;
    }
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #121212;
    }

    .container, .chart-container {
        background-color: #1e1e1e;
        color: #e0e0e0;
    }

    h1, .chart-title, .stat-value {
        color: #e0e0e0;
    }

    .tab.active {
        border-bottom-color: #1e1e1e;
        background-color: #1e1e1e;
    }

    p.description, .years-label, .stat-title {
        color: #a0a0a0;
    }

    .years-select, .stat-card {
        background-color: #2a2a2a;
        color: #e0e0e0;
        border-color: #3a3a3a;
    }

    .error-message {
        background-color: rgba(220, 53, 69, 0.1);
    }

    .tooltip-text {
        background-color: #333;
    }

    .tooltip-text::after {
        border-color: #333 transparent transparent transparent;
    }

    :root {
        --skeleton-base: #2a2a2a;
        --skeleton-shine: #3a3a3a;
    }
}