/* 高於全站 SideTab（category 1001、collab/cart 最高 1085）與相關 backdrop */
#customerGradeScheduleModal {
    z-index: 1095;
}

.modal-backdrop.customer-grade-schedule-modal-backdrop {
    z-index: 1090;
}

#customerGradeScheduleModal .customer-grade-schedule-modal-dialog {
    min-width: min(960px, 96vw);
    max-width: min(1040px, 96vw);
    margin: 1rem auto;
}

#customerGradeScheduleModal .modal-content {
    border: 1px solid #d7dee8;
    border-radius: 0.75rem;
    box-shadow: 0 0.75rem 1.5rem rgba(16, 40, 72, 0.18);
}

#customerGradeScheduleModal .modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    border-bottom: none;
    padding: 1rem 1.25rem;
}

#customerGradeScheduleModal .modal-title-wrap {
    flex: 1;
    min-width: 0;
}

#customerGradeScheduleModal .modal-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: #1a3a5c;
}

#customerGradeScheduleModal .modal-subtitle {
    margin: 0.35rem 0 0;
    font-size: 0.875rem;
    color: #5a6b7d;
    line-height: 1.5;
}

#customerGradeScheduleModal .modal-body {
    max-height: min(85vh, 720px);
    overflow-y: auto;
    padding: 0 1.25rem 1.25rem;
    color: #243447;
    line-height: 1.65;
}

#navGradeProgressItem:not(.notShow) {
    cursor: pointer;
}

#navGradeProgressItem:not(.notShow):focus {
    outline: none;
}

#navGradeProgressItem:not(.notShow):focus-visible .nav-grade-progress {
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.35);
    border-radius: 0.25rem;
}

.customer-grade-schedule-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.customer-grade-schedule-intro {
    display: none;
}

#customerGradeScheduleModalBody .customer-grade-schedule-intro {
    display: none;
}

.customer-grade-schedule-intro-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    color: #1a3a5c;
}

.customer-grade-schedule-intro-icon {
    color: #e8a317;
    font-size: 1.1rem;
}

.customer-grade-schedule-intro-sub {
    margin: 0.35rem 0 0;
    font-size: 0.875rem;
    color: #5a6b7d;
}

.customer-grade-schedule-current-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 0.8rem 9rem 0.8rem 2.5rem;
    background: #fff;
    border: 1px solid #e8edf3;
    border-radius: 0.75rem;
    box-shadow: 0 2px 8px rgba(26, 58, 92, 0.06);
}

.customer-grade-schedule-current-main {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.customer-grade-schedule-current-text {
    flex: 1;
    min-width: 0;
}

.customer-grade-schedule-label {
    font-size: 0.8125rem;
    color: #6b7c8f;
    margin-bottom: 0.25rem;
}

.customer-grade-schedule-current-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a3a5c;
    line-height: 1.2;
}

.customer-grade-schedule-current-stats {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.customer-grade-schedule-amount {
    font-size: 2rem;
    font-weight: 700;
    color: #1a3a5c;
    line-height: 1.1;
}

.customer-grade-schedule-period {
    font-size: 0.8125rem;
    color: #8a96a3;
    text-align: right;
}

.customer-grade-schedule-period--desktop {
    display: none;
    margin-top: 0.5rem;
    text-align: left;
}

.customer-grade-schedule-period--mobile {
    display: block;
}

.customer-grade-schedule-upgrade-card {
    padding: 0.8rem 2.5rem;
    background: linear-gradient(180deg, #fff9f0 0%, #fff5e8 100%);
    border: 1px solid #f0e0c8;
    border-radius: 0.75rem;
    overflow: visible;
}

.customer-grade-schedule-upgrade-card .customer-grade-medal--size-sm {
    --medal-size-px: 106;
}

.customer-grade-schedule-upgrade-layout {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1rem;
}

.customer-grade-schedule-upgrade-main {
    flex: 1;
    min-width: 0;
}

.customer-grade-schedule-max-message {
    font-size: 1rem;
    font-weight: 600;
    color: #3d4f63;
    text-align: center;
    padding: 0.5rem 0;
}

.customer-grade-schedule-upgrade-visual {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    --upgrade-medal-size-px: 106;
    --grade-blend-end-pct: 45;
    --grade-progress-fill-green: #2e7d32;
}

.customer-grade-schedule-progress-track {
    position: relative;
    width: 100%;
}

.customer-grade-schedule-progress-rail-wrap {
    --progress-rail-height-px: 10.4;
    position: relative;
    width: 100%;
    padding-top: calc(var(--upgrade-medal-size-px) * 1px + 0.35rem);
}

.customer-grade-schedule-upgrade-overbar {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 3;
    max-width: 50%;
}

.customer-grade-schedule-progress-medal-current-stack {
    position: absolute;
    top: 0;
    left: calc(var(--grade-split-pct, 40) * 1%);
    transform: translateX(calc(-100% + var(--upgrade-medal-size-px) * 0.5px));
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 0.35rem;
    z-index: 2;
    max-width: min(100%, 14rem);
}

.customer-grade-schedule-progress-medal-current {
    line-height: 0;
}

.customer-grade-schedule-progress-medal-end-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    gap: 0.35rem;
}

.customer-grade-schedule-progress-medal-end {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}

.customer-grade-schedule-progress-medal-end .customer-grade-medal--size-sm {
    --medal-size-px: 200;
}

.customer-grade-schedule-next-caption {
    text-align: right;
}

.customer-grade-schedule-next-caption.customer-grade-schedule-progress-medal-current-caption {
    flex-shrink: 0;
    text-align: right;
    width: auto;
    max-width: 5.5rem;
}

.customer-grade-schedule-next-name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #c77a12;
    line-height: 1.3;
}

.customer-grade-schedule-progress-rail {
    position: relative;
    display: flex;
    width: 100%;
    height: calc(var(--progress-rail-height-px) * 1px);
    background-color: #dce8f5;
    border-radius: 999px;
    overflow: visible;
}

.customer-grade-schedule-progress-fill {
    height: 100%;
    background-color: #1a3a5c;
    border-radius: 999px 0 0 999px;
    flex-shrink: 0;
    min-width: 0;
}

/* 軌道 40%～45%：深藍過渡至綠色（漸層依整條軌道比例映射至 fill 寬度） */
.customer-grade-schedule-upgrade-visual .customer-grade-schedule-progress-fill {
    background-image: linear-gradient(
        to right,
        #1a3a5c 0%,
        #1a3a5c calc(100% * var(--grade-split-pct, 40) / max(var(--progress-pct, 1), 1)),
        var(--grade-progress-fill-green) calc(100% * var(--grade-blend-end-pct, 45) / max(var(--progress-pct, 1), 1)),
        var(--grade-progress-fill-green) 100%
    );
}

.customer-grade-schedule-progress-rail .customer-grade-schedule-progress-fill[style*="width: 100"] {
    border-radius: 999px;
}

.customer-grade-schedule-upgrade-underbar {
    position: relative;
    width: 100%;
    min-height: 2.75rem;
    margin-top: 0.25rem;
}

.customer-grade-schedule-stat {
    position: absolute;
    top: 0;
    width: max-content;
    max-width: calc(100% - 1rem);
}

.customer-grade-schedule-stat--accumulated {
    left: calc(var(--progress-pct) * 1%);
    right: auto;
    transform: translateX(-50%);
    text-align: center;
}

.customer-grade-schedule-upgrade-visual.is-progress-above-floor .customer-grade-schedule-stat--accumulated {
    left: 70%;
    transform: translateX(-50%);
}

.customer-grade-schedule-stat--remaining {
    left: 100%;
    right: auto;
    transform: translateX(-50%);
    text-align: center;
    max-width: calc(100% - var(--progress-pct) * 1% - 0.5rem);
}

.customer-grade-schedule-metric-label {
    font-size: 0.75rem;
    color: #6b7c8f;
    margin-bottom: 0.2rem;
}

.customer-grade-schedule-metric-value {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #1a3a5c;
}

.customer-grade-schedule-metric-value--accent {
    color: #d35400;
}

.customer-grade-schedule-timeline {
    --timeline-medal-size-px: 168;
    /* 小章 56px × 3 = 168px */
    display: none;
    flex-wrap: nowrap;
    justify-content: space-between;
    gap: 0.25rem;
    padding: 1rem 0.5rem 0.5rem;
    overflow-x: auto;
}

.customer-grade-schedule-timeline-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 6rem;
    text-align: center;
}

/* 時間軸徽章：小章 56px × 1.5 = 84px，僅此區塊 */
.customer-grade-schedule-timeline .customer-grade-medal--size-sm {
    --medal-size-px: var(--timeline-medal-size-px);
}

.customer-grade-schedule-timeline-connector {
    position: absolute;
    top: calc(var(--timeline-medal-size-px) * 0.5 * 1px);
    right: 50%;
    width: 100%;
    height: 3px;
    background: #c5d0dc;
    transform: translateY(-50%);
    z-index: 0;
}

.customer-grade-schedule-timeline-connector.is-reached {
    background: linear-gradient(90deg, #e8a317, #1a3a5c);
}

.customer-grade-schedule-timeline-medal {
    position: relative;
    z-index: 1;
}

.customer-grade-schedule-timeline-name {
    margin-top: 0.35rem;
    font-size: 0.6875rem;
    color: #3d4f63;
    line-height: 1.3;
}

.customer-grade-schedule-timeline-threshold {
    font-size: 0.6875rem;
    color: #8a96a3;
}

.customer-grade-schedule-timeline-item.is-future .customer-grade-schedule-timeline-name,
.customer-grade-schedule-timeline-item.is-future .customer-grade-schedule-timeline-threshold {
    opacity: 0.55;
}

.customer-grade-schedule-timeline-badge {
    margin-top: 0.35rem;
    padding: 0.15rem 0.5rem;
    font-size: 0.625rem;
    font-weight: 600;
    color: #fff;
    background: #1a3a5c;
    border-radius: 999px;
}

#CustomerGradeSchedule .customer-grade-schedule-intro {
    display: none;
}

#CustomerGradeSchedule .customer-grade-schedule-panel {
    padding: 0.5rem 0;
}

@media (min-width: 768px) {
    #customerGradeScheduleModal .customer-grade-schedule-modal-dialog {
        margin: 1.75rem auto;
    }

    .customer-grade-schedule-current-card {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .customer-grade-schedule-current-stats {
        align-items: flex-end;
        text-align: right;
    }

    .customer-grade-schedule-period--desktop {
        display: block;
    }

    .customer-grade-schedule-period--mobile {
        display: none;
    }
}

@media (min-width: 992px) {
    .customer-grade-schedule-timeline {
        display: flex;
    }

    .customer-grade-schedule-current-main {
        gap: 1.5rem;
    }
}

@media (max-width: 767.98px) {
    .customer-grade-schedule-upgrade-card .customer-grade-medal--size-sm {
        --medal-size-px: 74;
    }

    .customer-grade-schedule-upgrade-visual {
        --upgrade-medal-size-px: 74;
    }

    .customer-grade-schedule-progress-medal-end .customer-grade-medal--size-sm {
        --medal-size-px: 95;
    }

    .customer-grade-schedule-upgrade-layout {
        gap: 0.35rem;
    }

    .customer-grade-schedule-upgrade-card {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    #customerGradeScheduleModal .customer-grade-schedule-current-card {
        display: grid;
        grid-template-columns: auto 1fr;
        column-gap: 1rem;
        row-gap: 0.5rem;
        padding: 0.8rem 1rem;
        align-items: start;
    }

    #customerGradeScheduleModal .customer-grade-schedule-current-main {
        display: contents;
    }

    #customerGradeScheduleModal .customer-grade-schedule-current-main > .customer-grade-medal {
        grid-column: 1;
        grid-row: 1 / span 2;
        align-self: center;
        --medal-size-px: 140;
    }

    #customerGradeScheduleModal .customer-grade-schedule-current-text {
        grid-column: 2;
        grid-row: 1;
    }

    #customerGradeScheduleModal .customer-grade-schedule-current-stats {
        grid-column: 2;
        grid-row: 2;
        align-items: flex-start;
        text-align: left;
    }

    #customerGradeScheduleModal .customer-grade-schedule-current-stats .customer-grade-schedule-period {
        text-align: left;
    }
}

@media (max-width: 575px) {
    #customerGradeScheduleModal .customer-grade-schedule-modal-dialog {
        min-width: calc(100vw - 0.5rem);
        max-width: calc(100vw - 0.5rem);
        margin: 0.25rem auto;
    }

    #customerGradeScheduleModal .modal-body {
        padding: 0 0.75rem 1rem;
    }

    .customer-grade-schedule-stat {
        font-size: 0.6875rem;
        padding: 0.3rem 0.45rem;
    }

    .customer-grade-schedule-amount {
        font-size: 1.65rem;
    }
}
