body {
    overflow: auto;
}

.pageMain--country {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.panel {
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(180deg,
            rgba(255, 255, 255, 0.05),
            rgba(255, 255, 255, 0.03));
    border-radius: 18px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
    overflow: visible;
}

.panelHead {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.panelHead h2 {
    margin: 0;
    font-size: 18px;
}

.panelSub {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

.tableFilters {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    flex: 0 0 auto;
}

.tableFilters[hidden] {
    display: none;
}

.tableFilter {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 130px;
}

.tableFilter span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.tableFilter select {
    height: 34px;
    max-width: 180px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    border-radius: 10px;
    padding: 0 10px;
    font-size: 13px;
}

.tableFilter select option {
    background-color: #111827;
    color: #e5e7eb;
}

.panelBody {
    padding: 18px;
}

.countrySearchForm {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 12px;
    align-items: flex-end;
}

.searchField {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 0 0 auto;
}

.searchField--wide {
    min-width: 280px;
    flex: 1 1 360px;
}

.searchField label {
    font-size: 14px;
    opacity: 0.75;
    color: var(--muted);
    font-weight: 600;
}

.fieldLabelWithHelp {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: fit-content;
}

.fieldHelpBtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--muted);
    cursor: help;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
}

.fieldHelpBtn:hover,
.fieldHelpBtn:focus {
    color: #bfdbfe;
    border-color: rgba(96, 165, 250, 0.6);
    background: rgba(96, 165, 250, 0.14);
    outline: none;
}

.fieldTooltip {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 20;
    width: min(380px, calc(100vw - 36px));
    padding: 10px 12px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 10px;
    background: #111827;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.35);
    color: #dbeafe;
    font-size: 12px;
    line-height: 1.4;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-3px);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.fieldTooltip div + div {
    margin-top: 7px;
}

.fieldTooltip strong {
    color: #f8fafc;
}

.fieldLabelWithHelp:hover .fieldTooltip,
.fieldLabelWithHelp:focus-within .fieldTooltip {
    opacity: 1;
    transform: translateY(0);
}

.searchField input[type="search"],
.searchField select {
    height: 38px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    border-radius: 10px;
    padding: 0 12px;
    font-size: 14px;
}

.searchField input[type="search"] {
    width: 100%;
}

.searchField select,
.searchField select option {
    background-color: #111827;
    color: #e5e7eb;
}

.searchField input:focus,
.searchField select:focus {
    outline: none;
    border-color: rgba(96, 165, 250, 0.75);
    background: rgba(255, 255, 255, 0.07);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.16);
}

.searchActions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-left: auto;
}

#loadBtn,
#resetBtn {
    height: 38px;
    padding: 0 14px;
    border-radius: 10px;
    font-weight: 700;
    border: 1px solid var(--stroke);
    cursor: pointer;
    color: var(--text);
}

#loadBtn {
    background: rgba(96, 165, 250, 0.18);
    border-color: rgba(96, 165, 250, 0.35);
}

#resetBtn {
    background: rgba(255, 255, 255, 0.06);
}

#loadBtn:hover,
#resetBtn:hover {
    background: rgba(255, 255, 255, 0.12);
}

.summaryCards {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
}

.summaryCard {
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    border-radius: 14px;
    padding: 10px 14px;
}

.summaryCardLabel {
    font-size: 12px;
    color: var(--muted);
}

.summaryCardValue {
    margin-top: 4px;
    font-size: 24px;
    font-weight: 800;
    line-height: 1.05;
}

.countryGrid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 16px;
}

.tableWrap {
    overflow: auto;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.countryTable {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
    background: rgba(255, 255, 255, 0.03);
}

.countryTable th,
.countryTable td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    vertical-align: middle;
    line-height: 1.25;
}

.countryTable th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: rgba(11, 15, 20, 0.96);
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    text-align: left;
}

.tuneNameLink {
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    min-width: 0;
    overflow-wrap: anywhere;
}

.tuneNameLink:hover {
    color: #93c5fd;
    text-decoration: underline;
}

.countryTuneRow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    max-width: 100%;
}

.sessionIconLink {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.06);
    transition: all 0.15s ease;
    flex: 0 0 auto;
}

.sessionIconLink:hover {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.3);
    transform: translateY(-1px);
}

.sessionIconLink img {
    width: 22px;
    height: 22px;
    display: block;
    object-fit: contain;
}

.trackOverviewLink {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.trackOverviewDot {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    background: radial-gradient(circle at 30% 30%, #fde68a, #f59e0b);
    box-shadow:
        0 0 0 1px rgba(245, 158, 11, 0.5),
        0 0 6px rgba(245, 158, 11, 0.6);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.trackOverviewLink:hover .trackOverviewDot {
    transform: scale(1.2);
    box-shadow:
        0 0 0 1px rgba(245, 158, 11, 0.7),
        0 0 10px rgba(245, 158, 11, 0.9);
}

.abcToolsIconBtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 24px;
    padding: 0;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    flex: 0 0 auto;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.abcToolsIconBtn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.18);
}

.abcToolsIconBtn img {
    display: block;
    max-width: 22px;
    max-height: 17px;
    object-fit: contain;
}

.typePill,
.modePill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.typePill {
    background: rgba(245, 158, 11, 0.14);
    border-color: rgba(245, 158, 11, 0.28);
    color: #fde68a;
}

.modePill {
    background: rgba(167, 139, 250, 0.14);
    border-color: rgba(167, 139, 250, 0.28);
    color: #ddd6fe;
}

.scoreCell {
    font-variant-numeric: tabular-nums;
    color: #bfdbfe;
    white-space: nowrap;
}

.countCell {
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    white-space: nowrap;
}

.tableMuted {
    color: var(--muted);
    font-size: 12px;
}

.emptyState,
.errorState,
.loadingState {
    padding: 10px 0;
    color: var(--muted);
    font-size: 14px;
}

.errorState {
    color: #fca5a5;
}

.barList {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.barRow {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr) 70px;
    gap: 10px;
    align-items: center;
}

.barLabel {
    color: var(--text);
    font-weight: 700;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.barTrack {
    height: 12px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.08);
}

.barFill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(96, 165, 250, 0.85), rgba(34, 197, 94, 0.75));
}

.barValue {
    color: var(--muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.similarCards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.similarCard {
    display: block;
    color: inherit;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    border-radius: 14px;
    padding: 12px 14px;
    transition: all 0.15s ease;
}

.similarCard:hover {
    border-color: rgba(96, 165, 250, 0.45);
    background: rgba(96, 165, 250, 0.1);
    transform: translateY(-1px);
}

.similarCountry {
    font-size: 15px;
    font-weight: 800;
}

.similarMeta {
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

@media (max-width: 1000px) {
    .countryGrid {
        grid-template-columns: 1fr;
    }

    .summaryCards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .similarCards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {

    .summaryCards,
    .similarCards {
        grid-template-columns: 1fr;
    }

    .searchField,
    .searchField--wide {
        flex: 1 1 100%;
        min-width: 100%;
    }

    .searchActions {
        margin-left: 0;
    }

    .panelHead {
        flex-direction: column;
        padding-left: 14px;
        padding-right: 14px;
    }

    .tableFilters {
        justify-content: flex-start;
        width: 100%;
    }

    .tableFilter {
        flex: 1 1 140px;
    }

    .tableFilter select {
        max-width: none;
        width: 100%;
    }

    .panelBody {
        padding-left: 14px;
        padding-right: 14px;
    }

    .barRow {
        grid-template-columns: 86px minmax(0, 1fr) 58px;
    }

}

.tableSortBtn {
    appearance: none;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    padding: 0;
}

.tableSortBtn:hover {
    color: #93c5fd;
    text-decoration: underline;
}

/* Responsive refinements for the country repertoire page. */
@media (max-width: 1180px) {
    .countryGrid {
        grid-template-columns: 1fr;
    }

    .summaryCards {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .similarCards {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .searchField--wide {
        flex-basis: 100%;
    }

    .searchActions {
        margin-left: 0;
    }
}

@media (max-width: 900px) {
    .header {
        padding: 12px 14px 10px;
    }

    .leftHead {
        align-items: flex-start;
        min-width: 0;
        width: 100%;
    }

    .leftHead h1 {
        font-size: clamp(22px, 5vw, 30px);
        line-height: 1.08;
    }

    .leftHead .sub {
        max-width: none;
        font-size: 13px;
        line-height: 1.45;
    }

    .pageMain--country {
        gap: 14px;
    }

    .panel {
        border-radius: 14px;
        box-shadow: 0 12px 34px rgba(0, 0, 0, 0.24);
    }

    .panelHead {
        flex-direction: column;
        padding: 14px 14px 10px;
    }

    .panelBody {
        padding: 14px;
    }

    .countrySearchForm {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: end;
    }

    .searchField,
    .searchField--wide {
        min-width: 0;
        width: 100%;
        flex: none;
    }

    .searchField--wide,
    .searchActions {
        grid-column: 1 / -1;
    }

    .searchField select {
        width: 100%;
    }

    .searchActions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    #loadBtn,
    #resetBtn {
        width: 100%;
    }

    .summaryCards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .similarCards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .tableFilters {
        justify-content: flex-start;
        width: 100%;
    }

    .tableFilter {
        flex: 1 1 150px;
        min-width: 0;
    }

    .tableFilter select {
        max-width: none;
        width: 100%;
    }

    .tableWrap {
        max-width: 100%;
        -webkit-overflow-scrolling: touch;
    }

    .countryTable {
        min-width: 760px;
    }
}

@media (max-width: 640px) {
    .header {
        padding: 10px 10px 8px;
    }

    .leftHead {
        display: grid;
        grid-template-columns: 38px 38px 38px minmax(0, 1fr);
        gap: 8px;
        align-items: center;
    }

    .leftHead>div {
        grid-column: 1 / -1;
        padding-top: 4px;
    }

    .homeBtn,
    .statsBtn {
        width: 38px;
        height: 38px;
    }

    .leftHead h1 {
        font-size: 24px;
    }

    .pageMain {
        padding-left: 10px;
        padding-right: 10px;
    }

    .pageMain--country {
        gap: 12px;
    }

    .panel {
        border-radius: 12px;
    }

    .countrySearchForm {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .searchActions {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .fieldLabelWithHelp {
        width: 100%;
    }

    .fieldTooltip {
        width: calc(100vw - 44px);
        max-width: none;
    }

    .summaryCards,
    .similarCards {
        grid-template-columns: 1fr;
    }

    .summaryCard {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 12px;
        padding: 11px 12px;
    }

    .summaryCardValue {
        margin-top: 0;
        font-size: 22px;
        text-align: right;
    }

    .barRow {
        grid-template-columns: 82px minmax(0, 1fr) 54px;
        gap: 8px;
    }

    .barLabel,
    .barValue {
        font-size: 12px;
    }

    .countryTable {
        min-width: 700px;
    }

    .countryTable th,
    .countryTable td {
        padding: 8px;
    }

    .countryTuneRow {
        gap: 5px;
    }

    .sessionIconLink,
    .trackOverviewDot {
        width: 20px;
        height: 20px;
    }

    .abcToolsIconBtn {
        width: 26px;
        height: 22px;
    }
}

@media (max-width: 430px) {
    .panelHead h2 {
        font-size: 17px;
    }

    .panelSub {
        font-size: 12px;
    }

    .summaryCard {
        align-items: flex-start;
        flex-direction: column;
    }

    .summaryCardValue {
        text-align: left;
    }

    .barRow {
        grid-template-columns: 1fr 52px;
        gap: 6px 8px;
    }

    .barLabel {
        grid-column: 1 / -1;
        white-space: normal;
    }

    .barTrack {
        height: 10px;
    }

    .similarCard {
        padding: 11px 12px;
    }
}

@media (max-width: 900px) and (max-height: 520px) and (orientation: landscape) {
    .header {
        padding: 6px 10px;
    }

    .leftHead {
        align-items: center;
        gap: 8px;
    }

    .homeBtn,
    .statsBtn {
        width: 34px;
        height: 34px;
    }

    .leftHead h1 {
        font-size: 20px;
        line-height: 1.05;
    }

    .leftHead .sub {
        display: none;
    }

    .pageMain {
        padding: 0 8px 8px;
    }

    .pageMain--country {
        gap: 8px;
    }

    .panel {
        border-radius: 10px;
    }

    .panelHead {
        padding: 9px 10px 7px;
    }

    .panelHead h2 {
        font-size: 16px;
    }

    .panelSub {
        font-size: 11px;
        line-height: 1.3;
    }

    .panelBody {
        padding: 10px;
    }

    .countrySearchForm {
        grid-template-columns: minmax(180px, 1.2fr) minmax(118px, 0.7fr) minmax(170px, 1fr) auto;
        gap: 8px;
    }

    .searchField--wide,
    .searchActions {
        grid-column: auto;
    }

    .searchField label,
    .tableFilter span {
        font-size: 12px;
    }

    .searchField select,
    .tableFilter select {
        height: 34px;
        font-size: 13px;
        border-radius: 8px;
    }

    .searchActions {
        align-self: end;
        display: flex;
        gap: 6px;
        width: auto;
    }

    #loadBtn,
    #resetBtn {
        height: 34px;
        width: auto;
        padding: 0 10px;
        border-radius: 8px;
        font-size: 13px;
    }

    .fieldTooltip {
        top: auto;
        bottom: calc(100% + 8px);
        width: min(360px, calc(100vw - 28px));
    }

    .summaryCards {
        grid-template-columns: repeat(6, minmax(0, 1fr));
        gap: 8px;
    }

    .summaryCard {
        padding: 8px 10px;
    }

    .summaryCardLabel {
        font-size: 11px;
    }

    .summaryCardValue {
        font-size: 19px;
    }

    .countryGrid {
        gap: 8px;
    }

    .barList {
        gap: 7px;
    }

    .barRow {
        grid-template-columns: 90px minmax(0, 1fr) 54px;
        gap: 8px;
    }

    .barTrack {
        height: 9px;
    }

    .tableFilters {
        gap: 6px;
    }

    .tableFilter {
        flex: 1 1 120px;
    }

    .countryTable th,
    .countryTable td {
        padding: 6px 8px;
    }

    .similarCards {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    .similarCard {
        padding: 9px 10px;
    }
}
