.custom-medals-dialog {
    position: fixed;
    inset: 0;
    width: min(680px, calc(100vw - 2rem));
    max-height: min(760px, calc(100vh - 2rem));
    margin: auto;
    padding: 1.25rem;
    overflow: auto;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.custom-medals-dialog::backdrop {
    background: rgba(0, 0, 0, .6);
}

.custom-medals-dialog__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: 1rem;
}

.custom-medals-dialog__header h2 {
    margin: 0;
    font-size: 1rem;
}

.custom-medals-list {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.custom-medals-list__item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: .75rem;
    padding: .65rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.custom-medals-list__text {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: .15rem;
}

.custom-medals-list__text strong,
.custom-medals-list__text span {
    overflow-wrap: anywhere;
}

.custom-medals-list__text strong {
    font-size: .9rem;
}

.custom-medals-list__text span {
    color: var(--text-muted);
    font-size: .75rem;
}

.custom-medals-list__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: .35rem;
}

.custom-medals-list__actions .btn {
    width: auto;
    min-height: 2rem;
    padding: .35rem .55rem;
    font-size: .72rem;
}

.custom-medals-empty {
    margin: .75rem 0 0;
    color: var(--red);
    font-size: .82rem;
    font-weight: 650;
}

.custom-medals-add {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .5rem;
    align-items: flex-start;
    margin-top: 1rem;
}

.custom-medals-add .ts-wrapper {
    min-width: 0;
}

.custom-medals-add .ts-wrapper .ts-control {
    align-items: center !important;
    min-height: 2.35rem !important;
    padding-top: .45rem !important;
    padding-bottom: .45rem !important;
}

.custom-medals-add .ts-wrapper .ts-control input {
    width: 100% !important;
    min-width: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
}

.custom-medals-add .btn {
    width: auto;
    min-height: 2.35rem;
}

.custom-medals-dialog__actions {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-top: 1rem;
}

.custom-medals-dialog__actions .btn {
    width: auto;
    padding: .5rem .9rem;
}

.custom-medals-dialog__spacer {
    flex: 1 1 auto;
}

.custom-date-filter {
    display: flex;
    align-items: center;
    gap: .35rem;
    flex-wrap: wrap;
}

.custom-date-filter__field {
    display: flex;
    align-items: center;
    gap: .3rem;
    font-size: .72rem;
    font-weight: 650;
    color: var(--text-muted);
}

.custom-date-filter__field input {
    box-sizing: border-box;
    min-width: 8.4rem;
    padding: .22rem .45rem;
    font: inherit;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.custom-date-filter__field input[type="date"] {
    -webkit-appearance: none;
    appearance: none;
    color-scheme: dark;
    inline-size: 100%;
    max-width: 100%;
}

.stats-followup__content {
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.stats-followup h2 {
    margin: 0;
    color: var(--text);
    font-size: 1rem;
    font-weight: 700;
}

.stats-followup p {
    margin: 0;
    color: var(--text-muted);
    font-size: .9rem;
    line-height: 1.5;
}

.stats-followup .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    flex: 0 0 auto;
}

.stats-page .data-table td.combined-cell {
    white-space: normal;
    padding: .5rem 1rem;
    min-width: 10rem;
}

.combined-cell__row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: .5rem;
    line-height: 1.7;
}

.combined-cell__meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: .5rem;
    color: var(--text-muted);
    font-size: .75em;
    letter-spacing: .05em;
    margin-bottom: .5rem;
}

.combined-cell__meta-primary {
    color: var(--text);
}

.combined-cell__label {
    color: var(--text-muted);
    font-size: .75em;
    min-width: 4.5rem;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.combined-cell__value {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.medal-value-badge {
    display: inline-flex;
    align-items: baseline;
    justify-content: flex-end;
    padding: .15rem .45rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    line-height: 1.4;
    font-variant-numeric: tabular-nums;
}

.medal-value-badge--bronze {
    border-color: color-mix(in srgb, var(--tier-bronze) 55%, var(--border));
    background: color-mix(in srgb, var(--tier-bronze) 12%, var(--surface-2));
}

.medal-value-badge--silver {
    border-color: color-mix(in srgb, var(--tier-silver-text) 55%, var(--border));
    background: color-mix(in srgb, var(--tier-silver-text) 12%, var(--surface-2));
}

.medal-value-badge--gold {
    border-color: color-mix(in srgb, var(--tier-gold-bright) 55%, var(--border));
    background: color-mix(in srgb, var(--tier-gold-bright) 12%, var(--surface-2));
}

.medal-value-badge--platinum {
    border-color: color-mix(in srgb, #d9e7ff 60%, var(--border));
    background: color-mix(in srgb, #d9e7ff 14%, var(--surface-2));
}

.profile-stats-table .medal-tier--bronze .medal-value-badge {
    border-color: color-mix(in srgb, var(--tier-bronze) 55%, var(--border));
    background: color-mix(in srgb, var(--tier-bronze) 12%, var(--surface-2));
}

.profile-stats-table .medal-tier--silver .medal-value-badge {
    border-color: color-mix(in srgb, var(--tier-silver-text) 55%, var(--border));
    background: color-mix(in srgb, var(--tier-silver-text) 12%, var(--surface-2));
}

.profile-stats-table .medal-tier--gold .medal-value-badge {
    border-color: color-mix(in srgb, var(--tier-gold-bright) 55%, var(--border));
    background: color-mix(in srgb, var(--tier-gold-bright) 12%, var(--surface-2));
}

.profile-stats-table .medal-tier--platinum .medal-value-badge {
    border-color: color-mix(in srgb, #d9e7ff 60%, var(--border));
    background: color-mix(in srgb, #d9e7ff 14%, var(--surface-2));
}

.filename {
    font-family: 'Menlo', 'Monaco', 'Consolas', monospace;
    font-size: .8rem;
    color: var(--text-muted);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.delta {
    font-size: .75em;
    color: #50c878;
    margin-left: .3em;
    font-weight: 500;
}

.delta--neg {
    color: var(--red);
}

/* Checkbox column */
.checkbox-cell {
    width: 1px;
    padding-left: 1rem !important;
    padding-right: .5rem !important;
}

.row-checkbox {
    accent-color: var(--accent);
    width: 15px;
    height: 15px;
    cursor: pointer;
}

.row--selected td {
    background: var(--accent-dim);
}

.combined-cell__select-hint {
    color: var(--text-muted);
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
}


@media (max-width: 600px) {
    .custom-medals-dialog {
        width: calc(100vw - 1rem);
        max-height: calc(100vh - 1rem);
        padding: 1rem;
    }

    .custom-medals-list__item {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .custom-medals-list__actions {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .custom-medals-list__actions .btn {
        min-width: 0;
    }

    .custom-medals-add .btn {
        width: auto;
    }

    .custom-medals-dialog__actions {
        flex-wrap: wrap;
    }

    .custom-medals-dialog__spacer {
        display: none;
    }

    .custom-date-filter {
        width: 100%;
    }

    .custom-date-filter__field {
        flex: 1 1 9rem;
    }

    .custom-date-filter__field input {
        width: 100%;
        min-width: 0;
    }

    /* Checkboxes are not practical on mobile */
    .checkbox-cell { display: none; }

    .delta { display: block; margin-left: 0; }

    .combined-cell .delta {
        display: inline;
        margin-left: 0;
        font-size: .72em;
        font-weight: 600;
        color: color-mix(in srgb, #50c878 75%, var(--text-muted));
    }

    .combined-cell .delta--neg {
        color: color-mix(in srgb, var(--red) 80%, var(--text-muted));
    }

    .combined-cell__value {
        display: inline-flex;
        align-items: baseline;
        justify-content: flex-end;
        gap: .35rem;
        min-width: 0;
    }
    .stats-page .combined-cell__meta { display: flex; }
    .stats-page .combined-cell__row {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: .5rem;
        line-height: 1.7;
    }
    .combined-cell__label {
        color: var(--text-muted);
        font-size: .75em;
        text-transform: uppercase;
        letter-spacing: .05em;
        flex-shrink: 0;
    }
}
