:root {
    color-scheme: light;
    --bg: #f6f6f4;
    --panel: #ffffff;
    --ink: #080808;
    --muted: #7c838a;
    --line: #dedede;
    --soft: #eeeeec;
    --accent: #111111;
    --ok: #0a7d42;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, Manrope, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.page {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 48px;
}

.hero {
    min-height: 220px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--line);
}

.brand {
    font-weight: 800;
    letter-spacing: 0;
    font-size: 15px;
    margin-bottom: 18px;
}

h1, h2, p { margin: 0; }
h1 {
    font-size: clamp(42px, 7vw, 88px);
    line-height: .92;
    letter-spacing: 0;
}

.hero p {
    margin-top: 18px;
    max-width: 620px;
    color: var(--muted);
    font-size: 18px;
    line-height: 1.45;
}

.panel, .stat, .coverage {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.mode-tabs {
    margin-top: 22px;
    display: inline-flex;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.mode-tab {
    height: 44px;
    border: 0;
    border-right: 1px solid var(--line);
    background: transparent;
    padding: 0 18px;
    cursor: pointer;
}

.mode-tab:last-child { border-right: 0; }
.mode-tab.is-active {
    background: var(--ink);
    color: #fff;
}

.mode-view[hidden] {
    display: none;
}

.filters {
    margin-top: 24px;
    padding: 18px;
    display: grid;
    grid-template-columns: 1.5fr .85fr .9fr auto;
    gap: 14px;
    align-items: end;
}

label span, .field-title {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 8px;
}

input, select, button {
    font: inherit;
}

input, select {
    width: 100%;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    padding: 0 12px;
}

#artistSearch {
    margin-bottom: 8px;
}

.scenario-bar {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    margin: 18px 0;
}

.advanced-panel {
    margin: 14px 0 18px;
    padding: 0;
}

.advanced-panel summary {
    cursor: pointer;
    padding: 14px 18px;
    color: var(--muted);
    font-weight: 700;
    list-style-position: inside;
}

.advanced-grid {
    padding: 0 18px 18px;
    display: grid;
    grid-template-columns: 1.2fr auto 1fr;
    gap: 14px;
    align-items: end;
    border-top: 1px solid var(--soft);
}

.advanced-grid label,
.advanced-grid > div {
    padding-top: 16px;
}

.segments {
    display: flex;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.segment {
    border: 0;
    border-right: 1px solid var(--line);
    background: transparent;
    height: 42px;
    padding: 0 18px;
    cursor: pointer;
}

.segment:last-child { border-right: 0; }
.segment.is-active {
    background: var(--ink);
    color: #fff;
}

.slider-wrap {
    display: grid;
    grid-template-columns: auto minmax(160px, 280px) 48px auto;
    align-items: center;
    gap: 10px;
    color: var(--muted);
}

.slider-wrap input { padding: 0; height: 24px; }
.slider-wrap strong { color: var(--ink); text-align: center; }

.message {
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: 8px;
    background: #fff8dd;
    border: 1px solid #ead99b;
}

.calculator-panel {
    margin-top: 24px;
    padding: 18px;
}

.calc-controls {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.calc-note {
    margin-top: 14px;
    padding: 14px 16px;
    border: 1px solid var(--soft);
    border-radius: 8px;
    background: #fafafa;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    color: var(--muted);
}

.calc-note strong {
    color: var(--ink);
}

.country-editor {
    margin-top: 14px;
    padding-top: 16px;
    border-top: 1px solid var(--soft);
}

.country-rows {
    display: grid;
    gap: 10px;
}

.country-row {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) 110px 42px;
    gap: 10px;
}

.calc-share {
    text-align: right;
}

#calcCountryTotal {
    color: var(--ok);
}

#calcCountryTotal.is-bad {
    color: #b42318;
}

.primary-button {
    margin-top: 16px;
    height: 42px;
    border: 0;
    border-radius: 6px;
    background: var(--ink);
    color: #fff;
    padding: 0 18px;
    cursor: pointer;
}

.secondary-button,
.icon-button {
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
}

.secondary-button {
    margin-top: 10px;
    padding: 0 14px;
}

.icon-button {
    padding: 0;
    font-size: 20px;
    line-height: 1;
}

.compact-button {
    margin-top: 0;
    white-space: nowrap;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.stat {
    padding: 20px;
    min-height: 116px;
}

.stat span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 18px;
}

.stat strong {
    display: block;
    font-size: 31px;
    line-height: 1.05;
}

.coverage {
    margin: 14px 0;
    padding: 15px 18px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    color: var(--muted);
}

.coverage strong { color: var(--ink); }

.chart-panel {
    padding: 18px;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

h2 {
    font-size: 18px;
    letter-spacing: 0;
}

.legend {
    display: flex;
    gap: 14px;
    color: var(--muted);
    font-size: 13px;
}

.dot {
    width: 8px;
    height: 8px;
    display: inline-block;
    border-radius: 50%;
    margin-right: 6px;
}

.dot.actual { background: var(--ink); }
.dot.forecast { background: var(--ok); }

#chart {
    display: block;
    width: 100%;
    min-height: 320px;
}

.axis { stroke: var(--line); stroke-width: 1; }
.line {
    fill: none;
    stroke-width: 3;
}
.actual-line { stroke: var(--ink); }
.forecast-line {
    stroke: var(--ok);
    stroke-dasharray: 9 7;
}
.point.actual { fill: var(--ink); }
.point.forecast { fill: var(--ok); }
.tick, .empty-chart {
    fill: var(--muted);
    font-size: 12px;
}

.tables {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-top: 14px;
}

.tables .panel {
    padding: 18px;
    min-width: 0;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 540px;
}

th, td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--soft);
    text-align: right;
    white-space: nowrap;
}

th:first-child, td:first-child {
    text-align: left;
}

th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

body.is-loading .stat strong,
body.is-loading #chart {
    opacity: .45;
}

.disclaimer {
    margin-top: 20px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

@media (max-width: 920px) {
    .filters, .stats, .tables, .calc-controls, .advanced-grid, .country-row {
        grid-template-columns: 1fr;
    }
    .scenario-bar, .coverage, .section-head, .calc-note {
        align-items: stretch;
        flex-direction: column;
    }
    .segments {
        width: 100%;
    }
    .segment {
        flex: 1;
        padding: 0 8px;
    }
    .slider-wrap {
        grid-template-columns: auto 1fr 48px auto;
    }
    .mode-tabs {
        display: flex;
        width: 100%;
    }
    .mode-tab {
        flex: 1;
        padding: 0 8px;
    }
}
