html {
    height: 100%;
}
body {
    margin: 0;
    font-family: system-ui, sans-serif;
    background: #0f172a;
    color: #f1f5f9;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    text-align: center;
    padding: 1rem;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
nav.top-nav {
    width: 100%;
    max-width: 640px;
    display: flex;
    justify-content: flex-start;
    margin-bottom: 0.5rem;
}
nav.top-nav.end {
    justify-content: flex-end;
}
nav.top-nav a {
    color: #94a3b8;
    font-size: 0.85rem;
    text-decoration: none;
}
nav.top-nav a:hover { color: #f1f5f9; }

h1 { font-size: 2.5rem; margin-bottom: 0.25rem; }
p.tagline { color: #94a3b8; margin-top: 0; margin-bottom: 2rem; }

.card {
    background: #1e293b;
    border-radius: 12px;
    padding: 2rem;
    width: 100%;
    max-width: 640px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}
.card.left-align {
    text-align: left;
}
.card h2 {
    font-size: 1.1rem;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: #f1f5f9;
}
.card h2:first-of-type { margin-top: 0; }
.card p {
    font-size: 0.95rem;
    line-height: 1.5;
    color: #cbd5e1;
    margin: 0 0 1rem;
}
.card p:last-child { margin-bottom: 0; }

.calculator-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.calculator-link {
    display: block;
    padding: 1rem 1.25rem;
    border: 1px solid #334155;
    border-radius: 10px;
    text-decoration: none;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.calculator-link:hover,
.calculator-link:focus-visible {
    border-color: #22c55e;
    background: #0f172a;
}
.calculator-link-title {
    display: block;
    font-size: 1.05rem;
    font-weight: 600;
    color: #f1f5f9;
    margin-bottom: 0.3rem;
}
.calculator-link-desc {
    display: block;
    font-size: 0.85rem;
    line-height: 1.4;
    color: #94a3b8;
}

label {
    display: block;
    text-align: left;
    font-size: 0.9rem;
    color: #cbd5e1;
    margin-top: 1rem;
    margin-bottom: 0.4rem;
}
label:first-of-type { margin-top: 0; }
.input-wrap {
    display: flex;
    align-items: center;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    overflow: hidden;
}
.input-wrap span {
    padding: 0 0.75rem;
    color: #94a3b8;
}
.input-wrap input {
    flex: 1;
    padding: 0.65rem 0.75rem;
    border: none;
    border-radius: 0;
    background: transparent;
    color: #f1f5f9;
    font-size: 1rem;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}
.input-wrap span + input {
    padding-left: 0;
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
}
.input-wrap input:-webkit-autofill {
    -webkit-text-fill-color: #f1f5f9;
    -webkit-box-shadow: 0 0 0 1000px #0f172a inset;
    box-shadow: 0 0 0 1000px #0f172a inset;
}
button {
    width: 100%;
    margin-top: 1.25rem;
    padding: 0.7rem;
    border: none;
    border-radius: 8px;
    background: #22c55e;
    color: #0f172a;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}
button:hover { background: #16a34a; }

.result {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid #334155;
    display: none;
}
.result.visible { display: block; }
.result .amount {
    font-size: 2rem;
    font-weight: 700;
    color: #22c55e;
}
.result .amount .per-person {
    font-size: 1.1rem;
    font-weight: 500;
    color: #94a3b8;
}
.result .label {
    font-size: 0.85rem;
    color: #94a3b8;
    margin-bottom: 0.25rem;
}
.breakdown-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #cbd5e1;
    padding: 0.2rem 0;
}
.breakdown-divider {
    border-top: 1px dashed #334155;
    margin: 0.6rem 0;
}

.chart-section {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid #334155;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}
.chart-section[hidden] { display: none; }
.chart-section svg { flex-shrink: 0; overflow: visible; }
.chart-section .slice {
    cursor: pointer;
    transition: opacity 0.15s ease;
}
.chart-section .slice:hover,
.chart-section .slice:focus-visible {
    opacity: 0.85;
    outline: none;
}
.chart-section .slice-label {
    font-size: 7px;
    font-weight: 600;
    fill: #0f172a;
    pointer-events: none;
    text-anchor: middle;
    /* dominant-baseline: middle is unreliable in Safari; vertical centering is
       done via a dy="0.35em" attribute set in JS instead. */
}
.chart-legend {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.chart-legend-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.chart-legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}
.chart-legend-text {
    font-size: 0.85rem;
    color: #cbd5e1;
}
.chart-legend-value {
    font-size: 0.8rem;
    color: #94a3b8;
}
.chart-tooltip {
    position: fixed;
    pointer-events: none;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
    color: #f1f5f9;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    display: none;
    z-index: 10;
}
.chart-tooltip .value { font-weight: 700; }
.chart-tooltip .series { color: #94a3b8; }

.countries {
    margin-top: 1.25rem;
    text-align: left;
}
.map-container {
    height: 320px;
    margin: 0.75rem 0 1rem;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #334155;
    background: #0f172a;
}
.map-container .leaflet-tile-pane {
    filter: invert(1) hue-rotate(180deg) brightness(0.95) contrast(0.9);
}
.map-container .leaflet-popup-content-wrapper,
.map-container .leaflet-popup-tip {
    background: #1e293b;
    color: #f1f5f9;
}
.map-container .leaflet-popup-content {
    font-size: 0.85rem;
}
.map-container .leaflet-bar a {
    background: #1e293b;
    color: #f1f5f9;
    border-bottom-color: #334155;
}
.map-container .leaflet-bar a:hover {
    background: #334155;
}
.continent-filter {
    margin-bottom: 0.85rem;
}
.question-block {
    margin-bottom: 1.5rem;
}
.question-block:last-of-type {
    margin-bottom: 0;
}
.continent-filter .filter-label {
    font-size: 0.85rem;
    color: #cbd5e1;
    margin-bottom: 0.4rem;
}
.continent-options {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.4rem 0.9rem;
}
.continent-option {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: #cbd5e1;
    cursor: pointer;
}
.continent-option input {
    accent-color: #22c55e;
    cursor: pointer;
}
.weight-sliders {
    margin-bottom: 0.85rem;
}
.weight-sliders .filter-label-hint {
    color: #64748b;
    font-weight: 400;
}
.slider-row {
    margin-top: 0.6rem;
}
.slider-row label {
    display: block;
    font-size: 0.85rem;
    color: #cbd5e1;
    margin: 0 0 0.3rem;
}
.slider-row .slider-hint {
    color: #64748b;
    font-size: 0.78rem;
}
.slider-control {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
/*
 * Fully custom range-input styling instead of relying on accent-color: Safari
 * doesn't paint the "filled" portion of the track the way Chrome/Firefox do
 * with accent-color, so it looks like a flat, uncolored slider there. The
 * --fill custom property (set from JS on load/input) drives the gradient so
 * the progress fill renders identically across browsers.
 */
.slider-control input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(to right, #22c55e var(--fill, 0%), #334155 var(--fill, 0%));
    outline: none;
    cursor: pointer;
}
.slider-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid #0f172a;
    cursor: pointer;
}
.slider-control input[type="range"]::-moz-range-track {
    height: 6px;
    border-radius: 999px;
    background: #334155;
}
.slider-control input[type="range"]::-moz-range-progress {
    height: 6px;
    border-radius: 999px;
    background: #22c55e;
}
.slider-control input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid #0f172a;
    cursor: pointer;
}
.slider-control input[type="range"]:focus-visible {
    outline: 2px solid #22c55e;
    outline-offset: 2px;
}
.slider-control .slider-value {
    min-width: 2ch;
    text-align: right;
    font-size: 0.85rem;
    color: #94a3b8;
    font-variant-numeric: tabular-nums;
}
.country-top-row {
    display: flex;
    justify-content: space-between;
}
.country-name { color: #f1f5f9; }
.country-metrics {
    display: block;
    width: 100%;
    min-width: 0;
}
.country-metrics-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.3rem;
}
.country-metric {
    display: inline-block;
    font-size: 0.72rem;
    color: #94a3b8;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
}
.country-match-score {
    color: #22c55e;
    border-color: #22c55e;
}
.countries .heading {
    font-size: 0.85rem;
    color: #cbd5e1;
    margin-bottom: 0.5rem;
}
.countries ul {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 220px;
    overflow-y: auto;
}
.countries li {
    display: block;
    padding: 0.4rem 0;
    border-bottom: 1px solid #334155;
    font-size: 0.9rem;
}
.countries li:last-child { border-bottom: none; }
.countries .country-income { color: #94a3b8; }
.countries .empty {
    color: #94a3b8;
    font-size: 0.85rem;
}
.countries .source {
    margin-top: 0.6rem;
    font-size: 0.75rem;
    color: #64748b;
}

@media (max-width: 480px) {
    body {
        padding: 1rem;
        justify-content: flex-start;
    }
    h1 { font-size: 1.75rem; }
    .card {
        max-width: none;
        padding: 1.25rem;
        border-radius: 8px;
    }
    .map-container {
        height: 240px;
    }
}
