:root {
    --brand-primary: #630f46;
    --brand-primary-hover: #4a0b34;
    --brand-primary-active: #3d092b;
    --brand-primary-rgb: 99, 15, 70;
    --bs-primary: var(--brand-primary);
    --bs-primary-rgb: var(--brand-primary-rgb);
    --bs-link-color: var(--brand-primary);
    --bs-link-hover-color: var(--brand-primary-hover);
    --bs-primary-text-emphasis: var(--brand-primary-hover);
    --bs-primary-bg-subtle: #f5eaf1;
    --bs-primary-border-subtle: #d9b3cc;
}

.btn-primary {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--brand-primary);
    --bs-btn-border-color: var(--brand-primary);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--brand-primary-hover);
    --bs-btn-hover-border-color: var(--brand-primary-hover);
    --bs-btn-focus-shadow-rgb: var(--brand-primary-rgb);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--brand-primary-active);
    --bs-btn-active-border-color: var(--brand-primary-active);
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--brand-primary);
    --bs-btn-disabled-border-color: var(--brand-primary);
}

.btn-outline-primary {
    --bs-btn-color: var(--brand-primary);
    --bs-btn-border-color: var(--brand-primary);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--brand-primary);
    --bs-btn-hover-border-color: var(--brand-primary);
    --bs-btn-focus-shadow-rgb: var(--brand-primary-rgb);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--brand-primary-active);
    --bs-btn-active-border-color: var(--brand-primary-active);
    --bs-btn-disabled-color: var(--brand-primary);
    --bs-btn-disabled-bg: transparent;
    --bs-btn-disabled-border-color: var(--brand-primary);
}

.form-check-input:checked,
.form-check-input[type="checkbox"]:indeterminate {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.form-check-input:focus {
    border-color: rgba(var(--brand-primary-rgb), 0.5);
    box-shadow: 0 0 0 0.25rem rgba(var(--brand-primary-rgb), 0.25);
}

input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--brand-primary);
}

.text-primary {
    color: var(--brand-primary) !important;
}

.badge.bg-primary {
    background-color: var(--brand-primary) !important;
}

.spinner-border.text-primary {
    color: var(--brand-primary) !important;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

.navbar-brand i {
    margin-right: 0.3rem;
}

.navbar-logo {
    filter: brightness(0) invert(1);
}

.navbar-brand {
    gap: 0.75rem;
}

@media (max-width: 991.98px) {
    .navbar > .container {
        flex-wrap: wrap;
    }

    .navbar-mobile-toggle-area {
        width: 100%;
        cursor: pointer;
        user-select: none;
    }

    .navbar-mobile-toggle-area .navbar-brand {
        cursor: pointer;
    }
}

.navbar-role {
    color: #fff;
    font-weight: 700;
    font-size: 1.125rem;
    line-height: 1;
    letter-spacing: 0.02em;
    white-space: nowrap;
    padding-left: 0.75rem;
    border-left: 1px solid rgba(255, 255, 255, 0.4);
    text-decoration: none;
}

.navbar-role:hover,
.navbar-role:focus {
    color: #fff;
    text-decoration: none;
}

.navbar-user-name {
    color: #ffffff4a;
    font-weight: 400;
    font-size: 0.95rem;
    margin-left: 0.35rem;
}

@media (max-width: 575.98px) {
    .navbar-role {
        font-size: 0.95rem;
        padding-left: 0.5rem;
    }

    .navbar-user-name {
        font-size: 0.85rem;
    }
}

.navbar-nav .nav-link.active {
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 0.25rem;
}

.card {
    border: none;
}

.table th {
    font-weight: 600;
}

.document-form-row:last-child {
    margin-bottom: 0 !important;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 0.2rem rgba(var(--brand-primary-rgb), 0.15);
}

.alert-dismissible .btn-close {
    padding: 1rem;
}

.badge.fs-6 {
    font-size: 0.9rem !important;
    padding: 0.5em 0.75em;
}

.status-icon {
    font-size: 1.25rem;
    line-height: 1;
    vertical-align: middle;
}

.status-icon-sm {
    font-size: 1rem;
}

footer {
    margin-top: auto;
}

.athlete-card {
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.athlete-card .card-title {
    font-weight: 600;
}

.athlete-row-clickable {
    cursor: pointer;
}

.athlete-row-clickable:hover {
    background-color: rgba(var(--brand-primary-rgb), 0.06);
}

.athlete-row-clickable:focus {
    outline: 2px solid var(--brand-primary);
    outline-offset: -2px;
}

.athlete-card-clickable {
    cursor: pointer;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.athlete-card-clickable:hover {
    border-color: rgba(var(--brand-primary-rgb), 0.35);
    box-shadow: 0 0.25rem 0.75rem rgba(var(--brand-primary-rgb), 0.12) !important;
}

.athlete-card-clickable:focus {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

.status-stepper .stepper-icon {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: #e9ecef;
    color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.status-stepper .stepper-line {
    height: 2px;
    background: #dee2e6;
    margin: 0 0.25rem;
    margin-top: 1rem;
}

.status-stepper .stepper-step-active .stepper-icon {
    background: #ffc107;
    color: #212529;
}

.status-stepper .stepper-step-done .stepper-icon {
    background: var(--brand-primary);
    color: #fff;
}

.status-stepper .stepper-step-success .stepper-icon {
    background: #198754;
    color: #fff;
}

.status-stepper .stepper-step-danger .stepper-icon {
    background: #dc3545;
    color: #fff;
}

.status-stepper .stepper-label {
    color: #6c757d;
    line-height: 1.2;
}

.status-stepper .stepper-step-active .stepper-label,
.status-stepper .stepper-step-done .stepper-label {
    color: #212529;
}

@media (max-width: 767.98px) {
    .status-stepper .stepper-label {
        font-size: 0.58rem;
        line-height: 1.15;
    }

    .status-stepper .stepper-icon {
        width: 1.65rem;
        height: 1.65rem;
        font-size: 0.75rem;
    }

    .status-stepper .stepper-line {
        margin-top: 0.85rem;
    }
}

/* ── Athlete photos ─────────────────────────────────────────────── */

.athlete-photo-lg {
    width: 150px;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
    border: 3px solid var(--bs-primary);
    display: block;
    margin: 0 auto;
}

.athlete-photo-placeholder-lg {
    width: 150px;
    height: 200px;
    border-radius: 8px;
    border: 3px dashed #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    color: #aaa;
    font-size: 3.5rem;
    background: #f8f9fa;
}

.athlete-photo-sm {
    width: 48px;
    height: 64px;
    object-fit: cover;
    border-radius: 5px;
    border: 2px solid var(--bs-primary);
}

.athlete-photo-placeholder-sm {
    width: 48px;
    height: 64px;
    border-radius: 5px;
    border: 2px dashed #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #aaa;
    font-size: 1.6rem;
    background: #f8f9fa;
}

.athlete-photo-xs {
    width: 33px;
    height: 44px;
    object-fit: cover;
    border-radius: 4px;
    border: 2px solid var(--bs-primary);
}

.athlete-photo-placeholder-xs {
    width: 33px;
    height: 44px;
    border-radius: 4px;
    border: 2px dashed #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #aaa;
    font-size: 1.1rem;
    background: #f8f9fa;
}

.athlete-photo-label {
    position: relative;
    display: inline-block;
    cursor: pointer;
}

.athlete-photo-label .athlete-photo-lg,
.athlete-photo-label .athlete-photo-placeholder-lg {
    transition: opacity 0.2s;
}

.athlete-photo-label:hover .athlete-photo-lg,
.athlete-photo-label:hover .athlete-photo-placeholder-lg {
    opacity: 0.7;
}

.athlete-photo-hint {
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
    pointer-events: none;
}

.group-athlete-search-results {
    margin-top: 0.5rem;
}

.group-athlete-search-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    background: #fff;
}

.group-athlete-search-item + .group-athlete-search-item {
    margin-top: 0.5rem;
}

.group-athlete-search-name {
    flex: 1;
    min-width: 0;
}

.group-athlete-selected-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    background: #f8f9fa;
}

.group-athlete-selected-item + .group-athlete-selected-item {
    margin-top: 0.5rem;
}

.group-athlete-remove {
    line-height: 1;
    padding: 0.15rem 0.45rem;
}

/* Rank badges and album */
.album-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.album-cell {
    text-align: center;
    padding: 0.6rem 0.4rem;
    border-radius: 8px;
    transition: box-shadow 0.3s ease;
    border: none;
    background: transparent;
    width: 100%;
}

.album-cell-clickable {
    cursor: pointer;
}

.album-cell-clickable:hover,
.album-cell-clickable:focus-visible {
    box-shadow: 0 0 0 2px rgba(var(--brand-primary-rgb), 0.35);
    outline: none;
}

.album-cell.earned {
    cursor: default;
}

.album-cell-earned-menu {
    cursor: context-menu;
    -webkit-touch-callout: none;
    user-select: none;
}

.album-cell.pending {
    box-shadow: 0 0 0 2px rgba(255, 193, 7, 0.65);
}

.album-cell.current {
    animation: pulse-ring 2s ease-in-out infinite;
    border-radius: 8px;
}

@keyframes pulse-ring {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(var(--brand-primary-rgb), 0.45);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(var(--brand-primary-rgb), 0);
    }
}

.album-cell img {
    width: 56px;
    height: 56px;
    display: block;
    margin: 0 auto 0.4rem;
}

.album-label {
    font-size: 0.62rem;
    color: #6c757d;
    line-height: 1.2;
}

.rank-badge-sm {
    vertical-align: middle;
}

.rank-history .list-group-item {
    border-left: none;
    border-right: none;
}

@media (max-width: 575.98px) {
    .rank-order-btn {
        padding: 0.15rem 0.35rem;
        font-size: 0.7rem;
        line-height: 1;
    }

    .rank-order-btn__label {
        display: none;
    }

    .rank-order-btn .bi {
        font-size: 0.85rem;
        margin: 0;
    }
}

.section-icon {
    color: var(--brand-primary);
    margin-right: 0.35rem;
}

@media (max-width: 575.98px) {
    .album-label {
        font-size: 0.55rem;
    }
}

@media (min-width: 576px) {
    .album-grid {
        max-width: 480px;
    }
}

.rank-context-menu {
    position: fixed;
    z-index: 1080;
    min-width: 240px;
    padding: 0.35rem 0;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.rank-context-menu__item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.55rem 0.9rem;
    border: none;
    background: transparent;
    text-align: left;
    font-size: 0.875rem;
    color: #212529;
}

.rank-context-menu__item:hover:not(:disabled):not(.is-disabled),
.rank-context-menu__item:focus-visible:not(:disabled):not(.is-disabled) {
    background: #f8f9fa;
    outline: none;
}

.rank-context-menu__item--danger {
    color: #dc3545;
}

.rank-context-menu__item:disabled,
.rank-context-menu__item.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
