.mp-users-page {
    min-height: calc(100vh - var(--mp-header-h, 64px));
    padding: 28px 20px 56px;
    background:
        radial-gradient(circle at top right, rgba(var(--mp-primary-rgb), 0.08), transparent 28%),
        var(--neutral-primary);
}

.mp-users-shell {
    width: min(1280px, 100%);
    margin: 0 auto;
    display: grid;
    gap: 18px;
}

.mp-users-panel {
    border: 1px solid rgba(var(--mp-primary-rgb), 0.10);
    border-top: 3px solid rgba(var(--mp-secondary-rgb), 0.72);
    border-radius: 18px;
    background: var(--mp-shell-gradient, var(--surface-raised));
    box-shadow: var(--mp-shadow-card, var(--shadow-md));
    overflow: hidden;
}

.mp-users-hero {
    padding: 24px 26px 22px;
    display: grid;
    gap: 14px;
}

.mp-users-eyebrow,
.mp-users-stat-label,
.mp-user-forecast-label,
.mp-user-card-label,
.mp-users-search-label {
    color: var(--mp-muted-foreground, var(--text-secondary));
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.mp-users-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.mp-users-title {
    color: var(--mp-primary, var(--brand-primary));
    font-size: 30px;
    line-height: 1.05;
    font-weight: 800;
    margin: 4px 0 0;
}

.mp-users-description {
    max-width: 760px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.65;
    margin: 0;
}

.mp-users-hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.mp-users-meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    padding: 0 12px;
    border: 1px solid rgba(var(--mp-primary-rgb), 0.10);
    border-radius: 999px;
    background: rgba(var(--mp-primary-rgb), 0.04);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 700;
}

.mp-users-meta-pill strong {
    color: var(--mp-primary, var(--brand-primary));
    font-weight: 800;
}

.mp-users-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    padding: 0 26px 24px;
}

.mp-users-stat-card {
    min-height: 120px;
    padding: 16px;
    border: 1px solid rgba(var(--mp-primary-rgb), 0.10);
    border-radius: 16px;
    background: var(--mp-card, var(--neutral-light));
    box-shadow: var(--mp-shadow-card, var(--shadow-sm));
    display: grid;
    gap: 10px;
    align-content: start;
}

.mp-users-stat-value {
    color: var(--mp-primary, var(--brand-primary));
    font-size: 28px;
    line-height: 1;
    font-weight: 800;
}

.mp-users-stat-copy {
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.55;
}

.mp-users-toolbar {
    padding: 18px 26px 24px;
    border-top: 1px solid rgba(var(--mp-primary-rgb), 0.08);
    display: grid;
    gap: 14px;
}

.mp-users-search-box {
    position: relative;
    max-width: 680px;
}

.mp-users-toolbar-row {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.mp-users-toolbar-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.mp-users-toolbar-control {
    min-width: 180px;
    display: grid;
    gap: 6px;
}

.mp-users-toolbar-select {
    min-height: 44px;
    padding: 0 38px 0 14px;
    border: 1px solid rgba(var(--mp-primary-rgb), 0.12);
    border-radius: 14px;
    background-color: var(--mp-card, var(--neutral-light));
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    box-shadow: none;
    transition: 0.18s ease;
}

.mp-users-toolbar-select:focus {
    outline: none;
    border-color: rgba(var(--mp-primary-rgb), 0.22);
    box-shadow: 0 0 0 3px rgba(var(--mp-primary-rgb), 0.10);
}

.mp-users-search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--mp-muted-foreground, var(--text-secondary));
    pointer-events: none;
}

.mp-users-search-input {
    width: 100%;
    min-height: 48px;
    padding: 0 52px 0 46px;
    border: 1px solid rgba(var(--mp-primary-rgb), 0.12);
    border-radius: 14px;
    background: var(--mp-card, var(--neutral-light));
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    box-shadow: none;
    transition: 0.18s ease;
}

.mp-users-search-input:focus {
    outline: none;
    border-color: rgba(var(--mp-primary-rgb), 0.22);
    box-shadow: 0 0 0 3px rgba(var(--mp-primary-rgb), 0.10);
}

.mp-users-search-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.8;
}

.mp-users-search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    min-width: 32px;
    min-height: 32px;
    border: 1px solid rgba(var(--mp-primary-rgb), 0.12);
    border-radius: 10px;
    background: var(--surface-raised, var(--neutral-light));
    color: var(--mp-primary, var(--brand-primary));
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.18s ease;
}

.mp-users-search-clear:hover {
    border-color: rgba(var(--mp-primary-rgb), 0.2);
    transform: translateY(-50%) scale(1.03);
}

.mp-users-search-meta {
    margin-top: 12px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

.mp-users-search-meta .is-active {
    color: var(--mp-primary, var(--brand-primary));
    font-weight: 700;
}

.mp-users-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
    padding: 0 26px 28px;
}

.mp-user-card {
    display: grid;
    gap: 14px;
    padding: 18px;
    border: 1px solid rgba(var(--mp-primary-rgb), 0.10);
    border-radius: 18px;
    background: var(--mp-card, var(--neutral-light));
    box-shadow: var(--mp-shadow-card, var(--shadow-sm));
    transition: 0.18s ease;
}

.mp-user-card:hover {
    transform: translateY(-2px);
    border-color: rgba(var(--mp-primary-rgb), 0.16);
    box-shadow: 0 12px 28px rgba(var(--mp-primary-rgb), 0.10);
}

.mp-user-card__head {
    display: grid;
    gap: 12px;
}

.mp-user-card__identity {
    display: flex;
    gap: 12px;
    min-width: 0;
    align-items: flex-start;
}

.mp-user-card__identity > div {
    min-width: 0;
    flex: 1 1 auto;
}

.mp-user-avatar {
    width: 50px;
    height: 50px;
    border: 1px solid rgba(var(--mp-primary-rgb), 0.12);
    border-radius: 16px;
    background: rgba(var(--mp-primary-rgb), 0.05);
    color: var(--mp-primary, var(--brand-primary));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex: 0 0 auto;
}

.mp-user-name {
    color: var(--mp-primary, var(--brand-primary));
    font-size: 18px;
    line-height: 1.25;
    font-weight: 800;
    margin: 0;
    overflow-wrap: break-word;
}

.mp-user-meta-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.mp-user-meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    min-height: 28px;
    padding: 0 10px;
    border: 1px solid rgba(var(--mp-primary-rgb), 0.08);
    border-radius: 999px;
    background: rgba(var(--mp-primary-rgb), 0.04);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.mp-user-card__metrics {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
    gap: 8px;
    width: 100%;
}

.mp-user-card__metric {
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid rgba(var(--mp-primary-rgb), 0.08);
    border-radius: 14px;
    background: rgba(var(--mp-primary-rgb), 0.04);
    text-align: left;
}

.mp-user-card__metric-value {
    color: var(--mp-primary, var(--brand-primary));
    font-size: 18px;
    line-height: 1.15;
    font-weight: 800;
    margin-top: 4px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.mp-user-card__metric-unit {
    margin-left: 3px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.mp-user-card__forecast-shell {
    padding: 14px;
    border: 1px solid rgba(var(--mp-primary-rgb), 0.08);
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(var(--mp-primary-rgb), 0.03), rgba(var(--mp-primary-rgb), 0.015));
}

.mp-user-card__forecast-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.mp-user-card__forecast-title {
    color: var(--mp-primary, var(--brand-primary));
    font-size: 15px;
    font-weight: 800;
}

.mp-user-card__forecast-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.mp-user-forecast-item {
    min-height: 86px;
    padding: 12px;
    border: 1px solid rgba(var(--mp-primary-rgb), 0.08);
    border-radius: 14px;
    background: var(--mp-card, var(--neutral-light));
    display: grid;
    gap: 8px;
    align-content: start;
}

.mp-user-forecast-value {
    color: var(--text-primary);
    font-size: 24px;
    line-height: 1;
    font-weight: 800;
}

.mp-user-card__footer {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.5;
}

.mp-user-card__footer strong {
    color: var(--text-primary);
    font-weight: 800;
}

.mp-user-achievements {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--interactive-bg, #d6b56c);
    color: #1c1408;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
}

.mp-user-achievements:hover,
.mp-user-achievements:focus-visible {
    background: var(--interactive-hover, #c7a450);
    color: #1c1408;
}

.mp-users-empty,
.mp-users-no-results {
    padding: 46px 20px;
    border: 1px dashed rgba(var(--mp-primary-rgb), 0.18);
    border-radius: 18px;
    background: rgba(var(--mp-primary-rgb), 0.03);
    text-align: center;
    color: var(--text-secondary);
}

.mp-users-empty h3,
.mp-users-no-results h3 {
    color: var(--text-primary);
    font-size: 20px;
    margin: 14px 0 8px;
}

.mp-users-no-results {
    display: none;
    margin: 0 26px 28px;
}

html[data-theme="dark"] .mp-users-page {
    background:
        radial-gradient(circle at top right, rgba(var(--mp-primary-rgb), 0.12), transparent 30%),
        var(--neutral-primary);
}

html[data-theme="dark"] .mp-user-card,
html[data-theme="dark"] .mp-users-stat-card,
html[data-theme="dark"] .mp-users-search-input,
html[data-theme="dark"] .mp-user-forecast-item {
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
}

.mp-users-view-toggle {
    display: inline-flex;
    padding: 4px;
    border: 1px solid rgba(var(--mp-primary-rgb), 0.12);
    border-radius: 14px;
    background: var(--mp-card, var(--neutral-light));
}

.mp-users-view-toggle button {
    min-height: 36px;
    padding: 0 14px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

html:not([data-mp-users-view="table"]) #usersViewCards,
html[data-mp-users-view="table"] #usersViewTable {
    background: rgba(var(--mp-primary-rgb), 0.10);
    color: var(--mp-primary, var(--brand-primary));
}

.mp-users-table-wrap {
    margin: 0 26px 28px;
    overflow-x: auto;
    border: 1px solid rgba(var(--mp-primary-rgb), 0.10);
    border-radius: 18px;
    background: var(--mp-card, var(--neutral-light));
}

html[data-mp-users-view="table"] #usersGrid,
html:not([data-mp-users-view="table"]) #usersTableWrap {
    display: none;
}

.mp-users-table {
    display: table !important;
    width: 100%;
    min-width: 920px;
    border-collapse: collapse;
    table-layout: auto;
}

.mp-users-page .mp-users-table thead {
    display: table-header-group !important;
    position: static;
    width: auto;
    height: auto;
    max-width: none;
}

.mp-users-page .mp-users-table tbody {
    display: table-row-group !important;
}

.mp-users-page .mp-users-table tr {
    display: table-row !important;
    width: auto;
}

/* The !important above also beats the inline display:none that search
   and the activity filter set, so filtered rows need their own rule. */
.mp-users-page .mp-users-table tr.is-filtered-out {
    display: none !important;
}

.mp-users-page .mp-users-table th,
.mp-users-page .mp-users-table td {
    display: table-cell !important;
    flex: none !important;
    width: auto;
    height: auto;
    overflow: visible;
    text-overflow: clip;
}

.mp-users-table th,
.mp-users-table td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(var(--mp-primary-rgb), 0.08);
    color: var(--text-primary);
    font-size: 13px;
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
}

.mp-users-table th {
    color: var(--mp-muted-foreground, var(--text-secondary));
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: rgba(var(--mp-primary-rgb), 0.04);
}

.mp-users-table tbody tr:last-child td {
    border-bottom: 0;
}

.mp-users-table tbody tr:hover td {
    background: rgba(var(--mp-primary-rgb), 0.04);
}

.mp-users-table__sort {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    cursor: pointer;
}

.mp-users-table__sort.is-active {
    color: var(--mp-primary, var(--brand-primary));
}

.mp-users-table__num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.mp-users-table__name {
    font-weight: 800;
    color: var(--mp-primary, var(--brand-primary));
}

html[data-theme="dark"] .mp-users-table-wrap,
html[data-theme="dark"] .mp-users-view-toggle {
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
}
html[data-theme="dark"] .mp-user-card__forecast-shell,
html[data-theme="dark"] .mp-users-meta-pill,
html[data-theme="dark"] .mp-user-meta-pill,
html[data-theme="dark"] .mp-user-card__metric {
    background: rgba(var(--mp-primary-rgb), 0.08);
}

@media (max-width: 900px) {
    .mp-users-page {
        padding: 22px 14px 42px;
    }

    .mp-users-hero,
    .mp-users-toolbar,
    .mp-users-stats-grid,
    .mp-users-grid {
        padding-left: 16px;
        padding-right: 16px;
    }
}

@media (max-width: 640px) {
    .mp-users-title {
        font-size: 24px;
    }

    .mp-users-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .mp-user-card__forecast-grid {
        grid-template-columns: 1fr;
    }

    .mp-users-toolbar-row,
    .mp-users-toolbar-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .mp-users-toolbar-control {
        min-width: 0;
    }

}

.mp-user-name a,
.mp-users-table__name a {
    color: inherit;
    text-decoration: none;
}

.mp-user-name a:hover,
.mp-users-table__name a:hover {
    text-decoration: underline;
}

.mp-user-profile-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 18px;
    color: var(--mp-primary, var(--brand-primary));
    font-weight: 700;
    text-decoration: none;
}

.mp-user-profile-back:hover {
    text-decoration: underline;
}

.mp-user-profile-missing {
    margin: 0 26px 28px;
}

.mp-user-profile-missing h1 {
    margin: 0 0 8px;
    color: var(--mp-primary, var(--brand-primary));
    font-size: 28px;
}
