:root {
    --un-blue: #009edb;
    --un-blue-dark: #0079b0;
    --un-blue-light: #e6f4fb;
    --white: #ffffff;
    --off-white: #f8f9fa;
    --light-gray: #e9ecef;
    --mid-gray: #6c757d;
    --dark-gray: #343a40;
    --text: #212529;
    --border: #dee2e6;
    --accent-red: #d32f2f;
    --accent-green: #2e7d32;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
}

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

body {
    font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--off-white);
    color: var(--text);
    line-height: 1.6;
    font-size: 15px;
}

/* ── Header ─────────────────────────────────────────── */
header {
    background-color: var(--un-blue);
    color: var(--white);
    padding: 1rem 0;
    border-bottom: 4px solid var(--un-blue-dark);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logo {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.header-subtitle {
    font-size: 0.85rem;
    opacity: 0.9;
    font-weight: 400;
}

.header-meta {
    font-size: 0.8rem;
    opacity: 0.85;
    text-align: right;
    line-height: 1.4;
}

.header-meta strong {
    display: block;
    font-size: 0.9rem;
}

/* ── Hero ───────────────────────────────────────────── */
.hero {
    background: linear-gradient(135deg, var(--un-blue-dark) 0%, var(--un-blue) 50%, #4db8e8 100%);
    color: var(--white);
    padding: 3rem 2rem;
    text-align: center;
}

.hero h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: 0.5px;
}

.hero p {
    font-size: 1.05rem;
    opacity: 0.9;
    max-width: 720px;
    margin: 0 auto;
}

/* ── Container ──────────────────────────────────────── */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--un-blue-dark);
    margin-bottom: 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 3px solid var(--un-blue);
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title .bar {
    display: inline-block;
    width: 6px;
    height: 28px;
    background-color: var(--un-blue);
    border-radius: 3px;
}

/* ── Map Section ────────────────────────────────────── */
.map-section {
    background: var(--white);
    border-radius: 6px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    overflow: hidden;
}

.map-container {
    width: 100%;
    height: 520px;
}

#choropleth-map {
    width: 100%;
    height: 100%;
}

/* ── Info Cards ─────────────────────────────────────── */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.info-card {
    background: var(--white);
    padding: 1.25rem;
    border-radius: 6px;
    box-shadow: var(--shadow);
    text-align: center;
    border-top: 4px solid var(--un-blue);
}

.info-card .value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--un-blue-dark);
}

.info-card .label {
    font-size: 0.8rem;
    color: var(--mid-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 0.25rem;
}

/* ── Tables ─────────────────────────────────────────── */
.table-wrapper {
    background: var(--white);
    border-radius: 6px;
    box-shadow: var(--shadow);
    overflow-x: auto;
    margin-bottom: 2rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

thead th {
    background-color: var(--un-blue);
    color: var(--white);
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    position: sticky;
    top: 0;
}

thead th:hover {
    background-color: var(--un-blue-dark);
}

thead th .sort-icon {
    margin-left: 4px;
    font-size: 0.7rem;
}

tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody tr:nth-child(even) {
    background-color: var(--un-blue-light);
}

tbody tr:hover {
    background-color: #d4eaf7;
}

td.rank {
    font-weight: 700;
    color: var(--un-blue-dark);
    text-align: center;
}

td.value-highlight {
    font-weight: 700;
    color: var(--accent-red);
}

td.value-low {
    font-weight: 700;
    color: var(--accent-green);
}

.rank-badge {
    display: inline-block;
    background: var(--un-blue);
    color: white;
    width: 28px;
    height: 28px;
    line-height: 28px;
    text-align: center;
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 700;
}

/* ── Table Controls ─────────────────────────────────── */
.table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--off-white);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.table-controls input {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.85rem;
    min-width: 220px;
}

.table-controls select {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.85rem;
}

.table-caption {
    padding: 10px 14px;
    background: var(--un-blue-light);
    font-size: 0.85rem;
    color: var(--dark-gray);
    border-bottom: 1px solid var(--border);
}

/* ── Methodology ────────────────────────────────────── */
.methodology {
    background: var(--white);
    border-radius: 6px;
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.methodology h3 {
    color: var(--un-blue-dark);
    margin-bottom: 0.75rem;
}

.methodology ul {
    list-style: none;
    padding: 0;
}

.methodology li {
    padding: 0.35rem 0;
    padding-left: 1.2rem;
    position: relative;
}

.methodology li::before {
    content: "•";
    color: var(--un-blue);
    font-weight: bold;
    position: absolute;
    left: 0;
}

.formula {
    background: var(--off-white);
    padding: 0.75rem 1rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    text-align: center;
    margin: 0.75rem 0;
}

/* ── Footer ─────────────────────────────────────────── */
footer {
    background-color: var(--dark-gray);
    color: #adb5bd;
    text-align: center;
    padding: 1.5rem;
    font-size: 0.85rem;
    line-height: 1.7;
}

footer a {
    color: var(--un-blue);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* ── Tabs ───────────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 3px solid var(--un-blue);
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    background: var(--off-white);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--mid-gray);
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--un-blue);
    color: white;
}

.tab-btn:hover:not(.active) {
    background: var(--light-gray);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ── Continent Filter Buttons ──────────────────────── */
.cont-btn {
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--white);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--dark-gray);
    transition: all 0.15s;
}

.cont-btn.active {
    background: var(--un-blue);
    color: white;
    border-color: var(--un-blue);
}

.cont-btn:hover:not(.active) {
    background: var(--un-blue-light);
}

/* ── Legend ─────────────────────────────────────────── */
.map-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0.5rem 1rem;
    background: var(--white);
    border-radius: 4px;
    font-size: 0.8rem;
    flex-wrap: wrap;
}

.legend-gradient {
    width: 200px;
    height: 14px;
    border-radius: 2px;
    background: linear-gradient(to right, #f7fbff, #6baed6, #2171b5, #08306b);
}

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 768px) {
    .header-inner {
        flex-direction: column;
        text-align: center;
    }
    .header-meta {
        text-align: center;
    }
    .hero h1 {
        font-size: 1.5rem;
    }
    .container {
        padding: 1rem;
    }
    .map-container {
        height: 350px;
    }
    .info-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    table {
        font-size: 0.78rem;
    }
    thead th, tbody td {
        padding: 8px 10px;
    }
    .tabs {
        overflow-x: auto;
    }
}
