/* ── Stats page (matches roster layout) ── */
.stats-container {
    flex: 1;
    padding: 2rem;
}

.stats-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.stats-title {
    color: var(--text-primary);
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
}

/* ── Chart ── */
.stats-chart {
    display: flex;
    gap: 0.3rem;
    align-items: stretch;
}

.stats-chart__y-axis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2px 0;
    flex-shrink: 0;
}

.stats-chart__y-label {
    font-size: 0.6rem;
    color: var(--text-subtle);
    line-height: 1;
}

.stats-chart__spark-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
    min-width: 0;
}

.stats-chart__sparkline {
    width: 100%;
    height: 50px;
    background: var(--bg-input-faint);
    border: 1px solid var(--border-faint);
    position: relative;
    border-radius: var(--r, 6px);
    overflow: hidden;
    padding: 4px 6px;
    box-sizing: border-box;
}

.stats-chart__sparkline svg {
    width: 100%;
    height: 100%;
    display: block;
}

.stats-chart__dot {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 1.5px solid var(--bg-surface);
    transform: translate(-50%, 50%);
    cursor: default;
    transition: transform 0.15s, width 0.15s, height 0.15s;
    z-index: 1;
}

.stats-chart__dot:hover {
    width: 9px;
    height: 9px;
}

.stats-chart__x-axis {
    position: relative;
    height: 14px;
}

.stats-chart__x-tick {
    position: absolute;
    transform: translateX(-50%);
    font-size: 0.55rem;
    color: var(--text-subtle);
    white-space: nowrap;
    line-height: 1;
}

.stats-chart__x-tick:first-child {
    transform: translateX(0);
}

.stats-chart__x-tick:last-child {
    transform: translateX(-100%);
}

.stats-chart__empty {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
}

/* ── Stats table ── */
.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.stats-table--compact {
    font-size: 0.72rem;
}

.stats-table th {
    text-align: left;
    padding: 0.4rem 0.5rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.stats-table__date {
    font-size: 0.65rem;
    color: var(--text-subtle);
    text-align: center;
    min-width: 38px;
}

.stats-table__delta {
    text-align: center;
    font-weight: 700;
}

.stats-table td {
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid var(--border-faint);
}

.stats-table__name {
    white-space: nowrap;
    font-weight: 600;
    position: sticky;
    left: 0;
    background: var(--bg-surface);
    z-index: 1;
}

.stats-table__ilvl {
    text-align: center;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}

.stats-table__ilvl--up {
    color: var(--color-success-alt);
    font-weight: 600;
}

.stats-table__ilvl--down {
    color: var(--color-danger);
    font-weight: 600;
}

.stats-table__ilvl--avg {
    font-weight: 700;
    color: var(--text-primary);
}

.stats-table__vault {
    text-align: center;
    white-space: nowrap;
}

.stats-table__vault--empty {
    color: var(--text-subtle);
}

.stats-table__mplus {
    text-align: center;
    white-space: nowrap;
}

.stats-table__mplus--empty {
    color: var(--text-subtle);
}

/* ── Class names ── */
.class-name {
    color: var(--class-color, var(--text-primary));
    font-weight: 600;
}

/* ── Delta badges ── */
.delta-up {
    color: var(--color-success-alt);
    font-size: 0.7rem;
    font-weight: 700;
}

.delta-down {
    color: var(--color-danger);
    font-size: 0.7rem;
    font-weight: 700;
}

/* ── Vault pills ── */
.vault-pill {
    display: inline-block;
    padding: 1px 4px;
    border-radius: var(--r, 4px);
    font-size: 0.62rem;
    font-weight: 600;
    margin-right: 2px;
}

.vault-pill--raid {
    background: rgba(255, 183, 0, 0.15);
    color: #d9a300;
    border: 1px solid rgba(255, 183, 0, 0.3);
}

.vault-pill--mplus {
    background: rgba(100, 149, 237, 0.15);
    color: #5b8def;
    border: 1px solid rgba(100, 149, 237, 0.3);
}

/* ── M+ score ── */
.mplus-score {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.72rem;
}

.mplus-key {
    font-size: 0.65rem;
    color: var(--text-subtle);
    margin-left: 2px;
}

/* ── Hint banner (no data yet) ── */
.stats-hint {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    margin-bottom: 0.5rem;
    background: rgba(255, 183, 0, 0.08);
    border: 1px solid rgba(255, 183, 0, 0.25);
    border-radius: var(--r, 8px);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.stats-hint svg {
    color: #d9a300;
    flex-shrink: 0;
}

.stats-hint code {
    background: var(--bg-input);
    padding: 2px 6px;
    border-radius: var(--r, 4px);
    font-size: 0.75rem;
}

/* ── Empty state (old, kept for reference) ── */
.stats-empty {
    text-align: center;
    padding: 4rem 1rem;
}

.stats-empty svg {
    color: var(--text-subtle);
    margin-bottom: 1rem;
}

.stats-empty h2 {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.stats-empty p {
    font-size: 0.85rem;
    color: var(--text-subtle);
    margin-bottom: 1rem;
}

.stats-empty code {
    background: var(--bg-input);
    padding: 0.4rem 0.8rem;
    border-radius: var(--r, 6px);
    font-size: 0.8rem;
    border: 1px solid var(--border-faint);
}

/* ── Filtered empty state ── */
.stats-empty-state--filtered {
    padding: 2.5rem 1rem;
    color: var(--text-muted);
}

/* ── Roster-style role separators & char rows (reused from roster) ── */
.roster-role-separator td {
    background: transparent;
    border: none !important;
    padding: 1.6rem 1.5rem 0.5rem;
}

.roster-role-separator:first-child td {
    padding-top: 0.8rem;
}

.roster-role-sep-inner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.roster-role-sep-inner::before,
.roster-role-sep-inner::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, color-mix(in srgb, var(--role-color) 45%, transparent), transparent);
}

.roster-role-sep-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 6px 1px color-mix(in srgb, var(--role-color) 50%, transparent);
}

.roster-role-sep-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--role-color);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.roster-role-sep-count {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--role-color);
    background: color-mix(in srgb, var(--role-color) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--role-color) 30%, transparent);
    padding: 1px 8px;
    border-radius: var(--r, 10px);
}

.roster-char-item {
    border-left: 3px solid transparent;
    transition: border-left-color 0.15s ease, background 0.15s ease;
}

.roster-char-item:hover {
    border-left-color: var(--row-role-color, var(--color-primary));
}

.char-link {
    text-decoration: none;
    font-weight: 600;
}

.char-link:hover {
    opacity: 0.8;
}

.player-name {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ── Mobile ── */
@media (max-width: 980px) {
    .stats-container {
        padding: 1rem;
    }

    .stats-header {
        margin-bottom: 1rem;
    }

    .stats-table {
        font-size: 0.72rem;
    }

    .stats-table--compact {
        font-size: 0.68rem;
    }
}

/* ── M+ Evolution: clickable char rows + per-dungeon detail panel ── */
.mplus-char-row {
    cursor: pointer;
    outline: none;
    border-left: 3px solid transparent;
    transition: border-left-color 0.15s ease, background 0.15s ease;
}

.mplus-char-row:hover {
    border-left-color: var(--row-role-color, var(--color-primary));
}

.mplus-char-row--selected {
    border-left-color: var(--color-primary);
    background: color-mix(in srgb, var(--color-primary) 10%, transparent);
}

.vault-char-row {
    cursor: pointer;
    outline: none;
    border-left: 3px solid transparent;
    transition: border-left-color 0.15s ease, background 0.15s ease;
}

.vault-char-row:hover {
    border-left-color: var(--row-role-color, var(--color-primary));
}

.slotilvl-char-row {
    cursor: pointer;
    outline: none;
    border-left: 3px solid transparent;
    transition: border-left-color 0.15s ease, background 0.15s ease;
}

.slotilvl-char-row:hover {
    border-left-color: var(--row-role-color, var(--color-primary));
}

.slotilvl-char-row--selected {
    border-left-color: var(--color-primary);
    background: color-mix(in srgb, var(--color-primary) 10%, transparent);
}

.vault-char-row--selected {
    border-left-color: var(--color-primary);
    background: color-mix(in srgb, var(--color-primary) 10%, transparent);
}

.ilvl-char-row {
    cursor: pointer;
    outline: none;
    border-left: 3px solid transparent;
    transition: border-left-color 0.15s ease, background 0.15s ease;
}

.ilvl-char-row:hover {
    border-left-color: var(--row-role-color, var(--color-primary));
}

.ilvl-char-row--selected {
    border-left-color: var(--color-primary);
    background: color-mix(in srgb, var(--color-primary) 10%, transparent);
}

.stats-char-detail-row {
    background: color-mix(in srgb, var(--bg-elevated, #1f1f29) 70%, transparent);
}

.stats-char-detail-cell {
    padding: 1rem 1.25rem;
    border-top: none;
}

.stats-char-detail--loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80px;
    color: var(--text-muted);
}

.vault-section {
    margin-bottom: 1rem;
}

.vault-section:last-child {
    margin-bottom: 0;
}

.vault-section__head {
    display: flex;
    align-items: baseline;
    margin-bottom: 0.35rem;
}

.vault-section__title {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--color-primary);
}

.apex-reset-marker {
    pointer-events: none;
}

.mplus-char-detail__header {
    display: flex;
    align-items: center;
    margin-bottom: 1rem 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
}

.mplus-char-detail__header .class-name {
    font-size: 1.5rem;
    font-weight: 700;
    text-decoration: none;
}

.mplus-score-overview {
    margin-bottom: 1.25rem;
    padding: 1rem 1.25rem;
    background: color-mix(in srgb, var(--color-primary) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--color-primary) 25%, transparent);
    border-radius: var(--r, 10px);
}

.mplus-score-overview__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.mplus-score-overview__title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--color-primary);
}

.mplus-score-overview__range {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.mplus-dungeon-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mplus-dungeon-row {
    display: grid;
    grid-template-columns: minmax(120px, 180px) 1fr;
    align-items: center;
    gap: 1.25rem;
    padding: 0.6rem 0.85rem;
    background: color-mix(in srgb, var(--color-primary) 4%, transparent);
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
    border-radius: var(--r, 8px);
}

.mplus-dungeon-row--empty {
    opacity: 0.5;
}

.mplus-dungeon-row__name {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.mplus-dungeon-row__icon {
    width: 28px;
    height: 28px;
    border-radius: var(--r, 6px);
    object-fit: cover;
    flex-shrink: 0;
}

.mplus-dungeon-row__icon--placeholder {
    background: var(--bg-elevated, #2a2a35);
    display: inline-block;
}

.mplus-dungeon-row__row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 0;
}

.mplus-dungeon-row__title {
    font-weight: 600;
    font-size: 0.86rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mplus-dungeon-row__range {
    font-size: 0.68rem;
    color: var(--text-muted);
}

.mplus-chart {
    min-width: 0;
}

.mplus-chart--dungeon {
    overflow-x: auto;
    overflow-y: hidden;
}

.mplus-score-overview,
.vault-section {
    overflow-x: auto;
    overflow-y: hidden;
}

.mplus-dungeon-row__na {
    text-align: right;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@media (max-width: 980px) {
    .mplus-dungeon-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
}
