:root {
    color-scheme: dark;
    --bg: #080e18;
    --surface: #0d1622;
    --surface-2: #111d2c;
    --surface-3: #172535;
    --surface-4: #1d2e42;
    --line: rgba(80, 148, 220, 0.1);
    --line-strong: rgba(80, 148, 220, 0.22);
    --text: #d4e4f0;
    --muted: #6a8fa8;
    --muted-2: #3e6278;
    --green: #34d399;
    --amber: #fbbf24;
    --azure-strong: #38bdf8;
    --azure-soft: #7dd3fc;
    --rose: #fb7185;
    --teal: #2dd4bf;
    --violet: #a78bfa;
    --gold: #f5c518;
    --shadow: 0 20px 60px rgba(0, 6, 20, 0.65), 0 4px 16px rgba(0, 2, 10, 0.4);
    --shadow-sm: 0 4px 16px rgba(0, 4, 14, 0.4);
    --radius: 10px;
    --radius-sm: 7px;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background:
        radial-gradient(ellipse 70% 45% at 15% 0%, rgba(14, 100, 160, 0.14), transparent),
        radial-gradient(ellipse 50% 35% at 85% 0%, rgba(100, 40, 180, 0.07), transparent),
        radial-gradient(ellipse 100% 60% at 50% 110%, rgba(0, 20, 50, 0.5), transparent),
        var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

button,
input,
select {
    font: inherit;
}

button,
a,
select,
input {
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

a {
    color: inherit;
}

.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.shell {
    width: min(calc(100% - 24px), 1440px);
    margin: 0 auto;
    padding: 12px 0 64px;
}

/* ─── Topbar ─── */

.topbar {
    position: sticky;
    top: 10px;
    z-index: 30;
    display: grid;
    grid-template-columns: auto minmax(180px, 340px) auto;
    align-items: center;
    gap: 14px;
    min-height: 60px;
    padding: 10px 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: rgba(10, 18, 32, 0.94);
    backdrop-filter: blur(20px) saturate(1.5);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 1px 0 rgba(255, 255, 255, 0.03) inset;
}

.brand {
    display: inline-flex;
    align-items: center;
    min-width: 0;
}

.brand img {
    width: 132px;
    height: auto;
}

.team-switcher select,
.detail-select-wrap select,
.detail-select-wrap input,
.push-form select,
.push-form input,
.workout-builder select,
.workout-builder input,
.create-team-form input,
.group-create-form select,
.group-create-form input,
.modal-card select,
.modal-card input {
    width: 100%;
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-3);
    color: var(--text);
}

.team-switcher select:focus,
.detail-select-wrap select:focus,
.detail-select-wrap input:focus,
.push-form select:focus,
.push-form input:focus,
.workout-builder select:focus,
.workout-builder input:focus,
.create-team-form input:focus,
.group-create-form select:focus,
.group-create-form input:focus,
.modal-card select:focus,
.modal-card input:focus {
    outline: none;
    border-color: rgba(56, 189, 248, 0.45);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1);
}

.team-switcher select:disabled {
    color: var(--muted-2);
    opacity: 0.6;
}

.account {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    min-width: 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.account span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ─── Buttons ─── */

.ghost-button,
.primary-button {
    min-height: 40px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.ghost-button {
    padding: 0 14px;
    border: 1px solid var(--line-strong);
    color: var(--text);
    background: transparent;
}

.ghost-button:hover,
.ghost-button:focus-visible,
.page-tab:hover,
.page-tab:focus-visible {
    border-color: rgba(80, 148, 220, 0.35);
    background: rgba(56, 189, 248, 0.06);
}

.icon-button {
    min-width: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 400;
}

.primary-button {
    padding: 0 18px;
    border: 1px solid rgba(56, 189, 248, 0.4);
    background: linear-gradient(135deg, #0f7fc4, #38bdf8);
    color: #ffffff;
    font-weight: 800;
    box-shadow: 0 2px 12px rgba(56, 189, 248, 0.22);
}

.primary-button:hover,
.primary-button:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 6px 22px rgba(56, 189, 248, 0.38);
    background: linear-gradient(135deg, #1a8fd4, #4dcaff);
}

/* ─── Loading / Auth / Empty states ─── */

.center-state,
.auth-panel,
.empty-state {
    width: min(100%, 620px);
    margin: 100px auto 0;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.center-state {
    display: grid;
    place-items: center;
    gap: 14px;
    padding: 48px;
    color: var(--muted);
}

.spinner {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 3px solid var(--line-strong);
    border-top-color: var(--azure-strong);
    animation: spin 900ms linear infinite;
}

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

.auth-panel,
.empty-state {
    display: grid;
    gap: 22px;
    padding: 32px;
    position: relative;
    overflow: hidden;
}

.auth-panel::before,
.empty-state::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--azure-strong), var(--teal));
}

.auth-panel h1,
.empty-state h1,
.page-heading h1,
.panel h2,
.chart-head h3,
.leaderboard-header h3,
.detail-card h3,
.detail-copy h3 {
    margin: 0;
    letter-spacing: 0;
}

.auth-panel h1,
.empty-state h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    line-height: 1;
}

.auth-copy,
.empty-state p,
.helper,
.heading-copy,
.panel-head p,
.detail-card p,
.chart-head p,
.leaderboard-header p {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.eyebrow {
    display: inline-flex;
    width: fit-content;
    margin: 0 0 10px;
    padding: 4px 10px;
    border: 1px solid rgba(56, 189, 248, 0.22);
    border-radius: 999px;
    color: var(--azure-soft);
    background: rgba(56, 189, 248, 0.08);
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.auth-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.secondary-link {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
}

.secondary-link:hover,
.secondary-link:focus-visible {
    border-color: rgba(80, 148, 220, 0.35);
    background: rgba(56, 189, 248, 0.06);
}

.error {
    margin: 0;
    color: var(--rose);
}

/* ─── Dashboard shell ─── */

.dashboard {
    margin-top: 20px;
}

.page-heading {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    padding: 10px 0 22px;
}

.page-heading h1 {
    font-size: clamp(2rem, 4.4vw, 3.4rem);
    line-height: 0.96;
    color: #f0f8ff;
}

.heading-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.invite-card {
    display: grid;
    gap: 6px;
    min-width: 160px;
    padding: 14px 18px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface-2);
    position: relative;
    overflow: hidden;
}

.invite-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--azure-strong), rgba(56, 189, 248, 0.3));
}

.invite-card.subtle::before {
    background: linear-gradient(90deg, var(--teal), rgba(45, 212, 191, 0.3));
}

.invite-card span,
.kpi span,
.detail-stat-label,
.calendar-legend span,
.workout-meta,
.form-field label {
    color: var(--muted-2);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.invite-card strong {
    font-size: 1.3rem;
    color: #f0f8ff;
}

/* ─── KPI cards ─── */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.kpi {
    display: grid;
    gap: 8px;
    min-height: 130px;
    padding: 20px;
    border: 1px solid var(--line);
    border-left-width: 3px;
    border-radius: var(--radius);
    background: var(--surface);
    position: relative;
    overflow: hidden;
}

.kpi::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.022) 0%, transparent 60%);
    pointer-events: none;
}

.kpi:nth-child(1) { border-left-color: var(--azure-strong); }
.kpi:nth-child(2) { border-left-color: var(--teal); }
.kpi:nth-child(3) { border-left-color: var(--green); }
.kpi:nth-child(4) { border-left-color: var(--gold); }

.kpi strong {
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    line-height: 1;
    color: #f0f8ff;
}

.kpi small,
.muted,
.inline-feedback {
    color: var(--muted);
    font-size: 0.82rem;
}

/* ─── Page navigation ─── */

/* ─── Sidebar layout ─── */

.dash-shell {
    display: grid;
    grid-template-columns: 216px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
    margin-top: 4px;
}

.side-rail {
    position: sticky;
    top: 84px;
    display: grid;
    gap: 8px;
    padding: 14px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.rail-label {
    margin: 2px 8px 6px;
    color: var(--muted-2);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.page-nav {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.page-nav::-webkit-scrollbar {
    display: none;
}

.page-tab {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    min-height: 42px;
    padding: 0 12px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.92rem;
    text-align: left;
    letter-spacing: 0.01em;
}

.page-tab svg {
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity 160ms ease;
}

.page-tab:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.035);
    border-color: transparent;
}

.page-tab:hover svg {
    opacity: 1;
}

.page-tab:focus-visible {
    outline: 2px solid rgba(56, 189, 248, 0.5);
    outline-offset: -2px;
}

.page-tab.is-active {
    color: #f0f8ff;
    background: linear-gradient(90deg, rgba(56, 189, 248, 0.16), rgba(56, 189, 248, 0.03));
}

.page-tab.is-active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    border-radius: 0 3px 3px 0;
    background: var(--azure-strong);
}

.page-tab.is-active svg {
    opacity: 1;
    color: var(--azure-strong);
}

.dash-main {
    min-width: 0;
    display: grid;
    gap: 0;
}

.dash-main .page-heading {
    padding-top: 0;
}

.dash-main .kpi-grid {
    margin-bottom: 18px;
}

.dashboard-page {
    display: none;
}

.dashboard-page.is-active {
    display: block;
}

/* ─── Grid + Panel ─── */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 14px;
}

.panel {
    display: grid;
    gap: 0;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    min-width: 0;
    position: relative;
    overflow: hidden;
}

.panel > * + * {
    margin-top: 16px;
}

.panel.panel-overflow-visible {
    overflow: visible;
}

.panel.wide {
    grid-column: span 8;
}

.panel.full {
    grid-column: 1 / -1;
}

.settings-grid > .panel:nth-child(2) {
    grid-column: span 4;
}

.panel-head,
.chart-head,
.leaderboard-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 2px;
}

.panel-head strong,
.chart-head strong {
    font-size: 1rem;
}

.panel-head.compact {
    align-items: center;
    padding-bottom: 10px;
}

.panel h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
}

/* ─── Overview page ─── */

.activity-stat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.activity-stat-card {
    display: grid;
    gap: 8px;
    min-height: 112px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    position: relative;
    overflow: hidden;
}

.activity-stat-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
}

.activity-stat-card:nth-child(1)::after { background: var(--green); }
.activity-stat-card:nth-child(2)::after { background: var(--teal); }
.activity-stat-card:nth-child(3)::after { background: var(--azure-strong); }
.activity-stat-card:nth-child(4)::after { background: var(--gold); }
.activity-stat-card:nth-child(5)::after { background: var(--violet); }
.activity-stat-card:nth-child(6)::after { background: var(--rose); }

.activity-stat-card strong {
    font-size: 1.55rem;
    line-height: 1;
    color: #f0f8ff;
}

.activity-stat-card small {
    color: var(--muted);
}

/* ─── List / card items ─── */

.rank-list,
.session-list,
.alert-list,
.workout-library,
.push-list,
.leaderboard-list,
.detail-list {
    display: grid;
    gap: 10px;
}

.rank-item,
.session-item,
.alert-item,
.workout-card,
.push-card,
.leaderboard-item,
.detail-list-item {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    min-width: 0;
}

.rank-top,
.session-top,
.push-top,
.leaderboard-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.rank-meta,
.session-meta,
.leaderboard-copy span,
.detail-list-copy span,
.push-meta,
.alert-item p,
.calendar-note {
    color: var(--muted);
    font-size: 0.88rem;
}

/* ─── Alert items ─── */

.alert-item {
    display: grid;
    gap: 8px;
    border-left-width: 3px;
}

.alert-item strong {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.alert-item[data-severity="positive"] {
    border-color: rgba(52, 211, 153, 0.22);
    border-left-color: var(--green);
    background: rgba(52, 211, 153, 0.07);
}

.alert-item[data-severity="warning"] {
    border-color: rgba(251, 191, 36, 0.22);
    border-left-color: var(--amber);
    background: rgba(251, 191, 36, 0.07);
}

.alert-item[data-severity="critical"] {
    border-color: rgba(251, 113, 133, 0.22);
    border-left-color: var(--rose);
    background: rgba(251, 113, 133, 0.07);
}

/* ─── Table ─── */

.table-wrap {
    overflow: auto;
    min-width: 0;
    -webkit-overflow-scrolling: touch;
}

/* Show ~5 rows, then scroll the rest (header stays pinned). */
.table-wrap.scroll-rows {
    max-height: 372px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--surface-4) transparent;
}

.table-wrap.scroll-rows thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
}

th,
td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

thead th {
    color: var(--muted-2);
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    background: var(--surface-2);
}

tbody tr:hover {
    background: rgba(56, 189, 248, 0.04);
}

tbody tr.is-selected {
    background: rgba(56, 189, 248, 0.1);
}

.ranking-row {
    cursor: pointer;
}

.ranking-row:focus-visible {
    outline: 2px solid rgba(56, 189, 248, 0.5);
    outline-offset: -2px;
}

.table-button {
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    text-align: left;
}

/* ─── Avatar + name cells ─── */

.athlete-cell,
.detail-person,
.leaderboard-item,
.workout-meta-row,
.push-completion-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(45, 212, 191, 0.22), rgba(167, 139, 250, 0.22));
    border: 1px solid var(--line-strong);
    display: grid;
    place-items: center;
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--text);
    flex: 0 0 auto;
    overflow: hidden;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.athlete-name,
.detail-copy,
.leaderboard-copy,
.detail-list-copy,
.push-copy,
.workout-copy {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.athlete-name strong,
.leaderboard-copy strong,
.detail-list-copy strong,
.detail-copy h3,
.workout-copy strong,
.push-copy strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.athlete-name span,
.detail-copy p,
.leaderboard-copy span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ─── Bar chart ─── */

.bar-chart {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 12px;
    align-items: end;
    min-height: 250px;
}

.bar-item {
    display: grid;
    gap: 8px;
    align-items: end;
}

.bar-track {
    position: relative;
    height: 180px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--line);
    overflow: hidden;
}

.bar-fill {
    position: absolute;
    inset: auto 0 0;
    border-radius: 6px 6px 0 0;
    background: linear-gradient(180deg, var(--azure-soft), rgba(56, 189, 248, 0.7));
}

.bar-value {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text);
}

.bar-label {
    color: var(--muted);
    font-size: 0.8rem;
}

/* ─── Calendar ─── */

.calendar-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.calendar-card {
    display: grid;
    gap: 12px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}

.calendar-day-label {
    color: var(--muted-2);
    font-size: 0.74rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 0 2px;
}

.calendar-cell {
    min-height: 90px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    display: grid;
    align-content: space-between;
    gap: 8px;
    transition: border-color 160ms ease;
}

.calendar-cell:hover {
    border-color: var(--line-strong);
}

.calendar-cell.is-clickable {
    cursor: pointer;
}

.calendar-cell.is-clickable:hover,
.calendar-cell.is-clickable:focus-visible {
    border-color: rgba(56, 189, 248, 0.45);
    background: rgba(56, 189, 248, 0.06);
    outline: none;
}

.calendar-cell.is-outside {
    opacity: 0.3;
}

.calendar-cell.is-empty {
    background: rgba(255, 255, 255, 0.015);
}

.calendar-day-top {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
}

.calendar-day-number {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--muted);
}

.calendar-level {
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

.calendar-level span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, rgba(125, 211, 252, 0.7), var(--azure-strong));
}

.calendar-stat {
    font-size: 0.82rem;
    color: var(--muted);
}

.calendar-legend {
    display: flex;
    justify-content: space-between;
    gap: 12px 24px;
    align-items: center;
    flex-wrap: wrap;
    padding: 6px 2px 14px;
    margin-bottom: 6px;
    line-height: 1.5;
}

.calendar-legend .calendar-note {
    flex: 1 1 220px;
    min-width: 0;
}

.legend-scale {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
}

.legend-ramp {
    width: 130px;
    height: 8px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(56, 189, 248, 0.12), rgba(56, 189, 248, 0.45), var(--azure-strong));
}

.calendar-cell-volume {
    align-content: start;
    gap: 5px;
}

.calendar-cell-volume.is-rest {
    background: rgba(255, 255, 255, 0.012);
}

.calendar-cell-volume.is-rest .calendar-day-number {
    opacity: 0.5;
}

.calendar-cell-volume.is-worked {
    box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.12) inset;
}

.calendar-cell-volume.is-worked .calendar-day-number,
.calendar-cell-volume.is-worked .calendar-stat {
    color: #f0f8ff;
}

.calendar-stat-strong {
    color: var(--text);
    font-weight: 700;
}

/* ─── Athlete detail ─── */

.detail-layout,
.leaderboard-layout {
    display: grid;
    gap: 16px;
}

.detail-hero {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, rgba(45, 212, 191, 0.07), rgba(167, 139, 250, 0.07));
}

.detail-score {
    display: grid;
    gap: 6px;
    min-width: 160px;
}

.detail-score strong {
    font-size: 2rem;
    line-height: 1;
    color: #f0f8ff;
}

.detail-score p,
.detail-stat-note {
    color: var(--muted);
    margin: 0;
}

.detail-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.detail-stat,
.detail-card,
.chart-panel,
.list-panel {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    min-width: 0;
}

.detail-stat strong {
    display: block;
    margin-top: 8px;
    font-size: 1.4rem;
    color: #f0f8ff;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 12px;
    align-items: start;
}

.detail-stack {
    display: grid;
    gap: 12px;
}

.detail-duo {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-items: start;
}

.detail-trio {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    align-items: stretch;
}

.detail-trio .detail-list {
    margin-top: 6px;
}

/* ─── Muscle activity map ─── */

.muscle-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.muscle-toggle {
    display: inline-flex;
    flex: 0 0 auto;
    padding: 3px;
    gap: 2px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--surface-2);
}

.muscle-toggle-btn {
    min-height: 28px;
    padding: 0 12px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 700;
}

.muscle-toggle-btn.is-active {
    background: var(--azure-strong);
    color: #04121f;
}

.muscle-card {
    display: flex;
    flex-direction: column;
}

.muscle-map-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 4px;
    min-height: 0;
}

.muscle-figure {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Fixed height so toggling Front/Back never changes the card height. */
.muscle-figure svg {
    height: 340px;
    width: auto;
    max-width: 100%;
    display: block;
}

.muscle-figure [data-muscle] {
    stroke: rgba(125, 170, 200, 0.18);
    stroke-width: 0.5;
    transition: fill 220ms ease;
}

.muscle-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--muted);
    font-size: 0.78rem;
    padding-bottom: 6px;
}

.muscle-ramp {
    width: 90px;
    height: 8px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(125, 170, 200, 0.15), rgba(251, 113, 133, 0.55), rgba(251, 113, 133, 0.95));
}

.detail-list-button {
    width: 100%;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 160ms ease, background 160ms ease;
}

.detail-list-button:hover,
.detail-list-button:focus-visible {
    border-color: rgba(56, 189, 248, 0.35);
    background: rgba(56, 189, 248, 0.06);
    outline: none;
}

.detail-list-item,
.leaderboard-item,
.push-completion-row,
.workout-card {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.detail-list-value,
.leaderboard-value {
    display: grid;
    gap: 3px;
    justify-items: end;
    text-align: right;
    flex: 0 0 auto;
}

/* ─── Leaderboard ─── */

.leaderboard-layout {
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
    align-items: start;
}

/* ─── Exercise combobox ─── */

.exercise-combobox {
    position: relative;
    width: min(100%, 280px);
}

.exercise-combobox input {
    width: 100%;
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-3);
    color: var(--text);
}

.exercise-combobox input:focus {
    outline: none;
    border-color: rgba(56, 189, 248, 0.45);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1);
}

.combobox-options {
    position: absolute;
    z-index: 25;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    display: grid;
    gap: 3px;
    padding: 6px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    box-shadow: var(--shadow);
    max-height: 280px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--surface-4) transparent;
}

.athlete-combobox {
    width: 300px;
    max-width: 100%;
}

.workout-combobox {
    width: 100%;
    max-width: none;
}

.combobox-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    min-height: 38px;
    padding: 0 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    text-align: left;
    font-size: 0.92rem;
}

.combobox-option:hover,
.combobox-option:focus-visible {
    background: rgba(56, 189, 248, 0.08);
    outline: none;
}

.combobox-option.is-selected {
    color: var(--azure-soft);
    background: rgba(56, 189, 248, 0.12);
}

.combobox-option svg {
    flex: 0 0 auto;
    color: var(--azure-strong);
}

.combobox-empty {
    padding: 10px;
    color: var(--muted);
    font-size: 0.9rem;
    text-align: center;
}

/* ─── Leaderboard athlete picker (right column) ─── */

.list-panel-head {
    display: grid;
    gap: 2px;
    margin-bottom: 10px;
}

.list-panel-head h3 {
    margin: 0;
    font-size: 1rem;
}

.leaderboard-athlete-search {
    width: 100%;
    min-height: 40px;
    margin-bottom: 12px;
    padding: 0 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-3);
    color: var(--text);
}

.leaderboard-athlete-search:focus {
    outline: none;
    border-color: rgba(56, 189, 248, 0.45);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1);
}

.leaderboard-list {
    max-height: 360px;
    overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--surface-4) transparent;
}

.leaderboard-pick {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    text-align: left;
}

.leaderboard-pick:hover,
.leaderboard-pick:focus-visible {
    border-color: var(--line-strong);
    outline: none;
}

.leaderboard-pick.is-active {
    border-color: var(--chip-color, var(--azure-strong));
    background: color-mix(in srgb, var(--chip-color, var(--azure-strong)) 12%, transparent);
}

.leaderboard-check {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    border-radius: 5px;
    border: 1.5px solid var(--line-strong);
    background: var(--surface);
    position: relative;
}

.leaderboard-pick.is-active .leaderboard-check {
    border-color: var(--chip-color, var(--azure-strong));
    background: var(--chip-color, var(--azure-strong));
}

.leaderboard-pick.is-active .leaderboard-check::after {
    content: '';
    position: absolute;
    left: 5.5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid #0a0f18;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.toggle-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.toggle-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--muted);
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 600;
    transition: all 160ms ease;
}

.toggle-chip:hover {
    color: var(--text);
    border-color: var(--line-strong);
    background: var(--surface-3);
}

.toggle-chip.is-active {
    color: var(--text);
    border-color: var(--chip-color, var(--line-strong));
    background: color-mix(in srgb, var(--chip-color, var(--azure-strong)) 14%, transparent);
}

.toggle-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--chip-color, var(--azure-strong));
    flex-shrink: 0;
}

.line-chart-card {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    min-height: 320px;
    padding: 10px;
}

.line-chart-card svg {
    width: 100%;
    height: 300px;
    display: block;
}

.line-chart-empty {
    min-height: 300px;
    display: grid;
    place-items: center;
    color: var(--muted);
}

.chart-axis {
    stroke: rgba(80, 148, 220, 0.1);
    stroke-width: 1;
}

.chart-label {
    fill: var(--muted);
    font-size: 11px;
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}

.chart-line {
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chart-dot {
    stroke: rgba(8, 14, 24, 0.9);
    stroke-width: 2;
}

/* ─── Pills ─── */

.rank-pill,
.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    padding: 5px 8px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 800;
    border: 1px solid var(--line-strong);
    background: rgba(255, 255, 255, 0.03);
    letter-spacing: 0.02em;
}

.status-pill.is-complete {
    border-color: rgba(56, 189, 248, 0.3);
    background: rgba(56, 189, 248, 0.1);
    color: var(--azure-soft);
}

.status-pill.is-missed {
    border-color: rgba(251, 113, 133, 0.3);
    background: rgba(251, 113, 133, 0.1);
    color: var(--rose);
}

/* ─── Push a workout form ─── */

.push-form {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 12px;
    align-items: end;
}

.push-field-workout { grid-column: span 3; }
.push-field-audience { grid-column: span 2; }
.push-field-target { grid-column: span 3; }
.push-field-date { grid-column: span 2; }
.push-submit-button { grid-column: span 2; min-width: 150px; }
.push-field-note { grid-column: 1 / -1; }

#workout-push-athlete-field {
    align-content: start;
}

/* ─── Workout builder ─── */

.workout-builder,
.builder-top-grid,
.builder-panel-grid,
.builder-search-card,
.builder-selected-card {
    display: grid;
    gap: 12px;
}

.builder-top-grid {
    grid-template-columns: minmax(220px, 1fr) 160px minmax(260px, 1.2fr);
}

.builder-panel-grid {
    grid-template-columns: minmax(300px, 0.82fr) minmax(0, 1.18fr);
    align-items: start;
}

.builder-search-card,
.builder-selected-card {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.builder-create-card {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-3);
}

.builder-create-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) repeat(2, minmax(0, 180px));
    gap: 10px;
    align-items: end;
}

.builder-create-actions {
    display: flex;
    justify-content: flex-start;
}

.builder-search-card {
    position: sticky;
    top: 92px;
}

.builder-search-row,
.builder-actions {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.builder-search-row .form-field {
    flex: 1 1 auto;
    min-width: 0;
}

.builder-search-results,
.builder-selected-list {
    display: grid;
    gap: 10px;
}

.builder-create-exercise-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    padding: 0 14px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-sm);
    background: rgba(56, 189, 248, 0.04);
    color: var(--azure-soft);
    cursor: pointer;
    font-weight: 700;
    font-size: 0.92rem;
}

.builder-create-exercise-button:hover,
.builder-create-exercise-button:focus-visible {
    border-color: rgba(56, 189, 248, 0.45);
    background: rgba(56, 189, 248, 0.1);
    color: var(--text);
}

.exercise-modal-card {
    width: min(100%, 480px);
}

.exercise-modal-form {
    display: grid;
    gap: 14px;
    margin-top: 4px;
}

.exercise-modal-form .primary-button {
    width: 100%;
    margin-top: 4px;
}

/* ─── Athlete picker ─── */

.athlete-picker-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    min-height: 40px;
    padding: 6px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-3);
    color: var(--text);
    cursor: pointer;
    text-align: left;
}

.athlete-picker-trigger:hover,
.athlete-picker-trigger:focus-visible {
    border-color: rgba(56, 189, 248, 0.45);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1);
    outline: none;
}

.athlete-picker-value {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
    font-weight: 600;
}

.athlete-picker-value.has-athlete {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--text);
}

.athlete-picker-trigger-copy {
    display: grid;
    gap: 1px;
    min-width: 0;
    line-height: 1.2;
}

.athlete-picker-trigger-copy strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.92rem;
}

.athlete-picker-trigger-copy span {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
}

.athlete-picker-trigger-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    font-size: 0.92rem;
}

.athlete-picker-caret {
    flex: 0 0 auto;
    color: var(--muted);
}

.avatar-sm {
    width: 28px;
    height: 28px;
    font-size: 0.72rem;
}

.athlete-picker-card {
    width: min(100%, 460px);
}

/* ─── Athlete day detail modal ─── */

.athlete-day-card {
    width: min(100%, 520px);
}

.athlete-day-body {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.push-detail-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 4px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.day-session-card {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.day-session-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.day-session-top strong {
    font-size: 1.02rem;
}

.day-session-top span {
    color: var(--muted);
    font-size: 0.85rem;
    flex: 0 0 auto;
}

.day-session-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.day-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 11px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 700;
}

.day-note {
    margin: 0;
    color: var(--muted-2);
    font-size: 0.82rem;
}

.day-loading {
    display: grid;
    place-items: center;
    gap: 12px;
    padding: 40px 16px;
    color: var(--muted);
}

.day-exercises {
    display: grid;
    gap: 10px;
    margin-top: 2px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.day-exercise {
    display: grid;
    gap: 8px;
}

.day-exercise-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.day-exercise-head strong {
    font-size: 0.95rem;
}

.day-exercise-head span {
    color: var(--muted-2);
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex: 0 0 auto;
}

.day-set-list {
    display: grid;
    gap: 4px;
}

.day-set-row {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 6px;
    background: var(--surface-3);
    font-size: 0.9rem;
}

.day-set-row.is-warmup {
    background: rgba(255, 255, 255, 0.02);
    color: var(--muted);
}

.day-set-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    border-radius: 6px;
    background: rgba(56, 189, 248, 0.12);
    color: var(--azure-soft);
    font-size: 0.76rem;
    font-weight: 800;
}

.day-set-row.is-warmup .day-set-index {
    background: rgba(255, 255, 255, 0.05);
    color: var(--muted);
}

.day-set-main {
    font-weight: 600;
    color: var(--text);
}

.day-set-row.is-warmup .day-set-main {
    color: var(--muted);
    font-weight: 500;
}

.day-set-tags {
    display: inline-flex;
    gap: 6px;
}

.day-tag {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 7px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
}

.athlete-picker-list {
    display: grid;
    gap: 6px;
    margin-top: 12px;
    max-height: 56vh;
    overflow: auto;
    padding-right: 2px;
    scrollbar-width: thin;
    scrollbar-color: var(--surface-4) transparent;
}

.athlete-picker-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    text-align: left;
}

.athlete-picker-item:hover,
.athlete-picker-item:focus-visible {
    border-color: rgba(56, 189, 248, 0.35);
    background: rgba(56, 189, 248, 0.06);
    outline: none;
}

.athlete-picker-item.is-selected {
    border-color: rgba(56, 189, 248, 0.5);
    background: rgba(56, 189, 248, 0.12);
}

.athlete-picker-item .athlete-name {
    flex: 1 1 auto;
}

.athlete-picker-item .athlete-name strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.athlete-picker-item .athlete-name span {
    color: var(--muted);
    font-size: 0.84rem;
}

.athlete-picker-check {
    flex: 0 0 auto;
    color: var(--azure-strong);
}

.builder-result-card,
.builder-exercise-row {
    display: grid;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    transition: border-color 160ms ease, background 160ms ease;
}

.builder-result-card:hover {
    border-color: var(--line-strong);
    background: var(--surface-3);
}

.builder-result-card {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
}

.builder-result-copy,
.builder-exercise-copy {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.builder-result-copy strong,
.builder-exercise-copy strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.builder-result-copy span,
.builder-exercise-copy span {
    color: var(--muted);
    font-size: 0.88rem;
}

.builder-row-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.builder-row-controls {
    display: grid;
    grid-template-columns: repeat(3, minmax(110px, 0.85fr)) minmax(180px, 1.45fr);
    gap: 10px;
}

.builder-row-controls .form-field input {
    min-height: 40px;
}

.builder-row-controls .form-field {
    min-width: 0;
}

.builder-inline-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.builder-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.02);
}

/* ─── Create team form ─── */

.create-team-form {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    gap: 12px;
    align-items: end;
}

/* ─── Form fields ─── */

.form-field {
    display: grid;
    gap: 7px;
}

.form-field.grow {
    min-width: 0;
}

/* ─── Workout library ─── */

.workout-library,
.push-list {
    align-content: start;
}

.workout-card {
    align-items: flex-start;
    display: grid;
    gap: 12px;
    cursor: pointer;
    transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.workout-card:hover,
.workout-card:focus-visible {
    border-color: rgba(56, 189, 248, 0.35);
    background: rgba(56, 189, 248, 0.05);
    outline: none;
}

.workout-card-main {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 0;
}

.workout-library-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-left: 24px;
}

.library-actions {
    display: flex;
    justify-content: center;
    margin-top: 14px;
}

.workout-swatch {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    flex: 0 0 auto;
    margin-top: 5px;
}

.push-card {
    display: grid;
    gap: 12px;
}

.push-card-button {
    width: 100%;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 160ms ease, background 160ms ease;
}

.push-card-button:hover,
.push-card-button:focus-visible {
    border-color: rgba(56, 189, 248, 0.35);
    background: rgba(56, 189, 248, 0.05);
    outline: none;
}

.completion-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 150px 150px auto;
    column-gap: 20px;
    row-gap: 10px;
    align-items: end;
    margin-bottom: 14px;
}

.completion-controls input {
    width: 100%;
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-3);
    color: var(--text);
}

.completion-controls input:focus {
    outline: none;
    border-color: rgba(56, 189, 248, 0.45);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1);
}

@media (max-width: 780px) {
    .completion-controls {
        grid-template-columns: 1fr 1fr;
    }
    .completion-controls .grow {
        grid-column: 1 / -1;
    }
}

.progress-track {
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
}

.progress-fill {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, rgba(125, 211, 252, 0.8), var(--azure-strong));
}

/* ─── Podium ─── */

.podium-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    align-items: end;
    min-height: 260px;
}

.podium-grid.compact {
    min-height: 230px;
}

.podium-card {
    display: grid;
    gap: 10px;
    align-items: end;
    justify-items: center;
    min-width: 0;
}

.podium-copy,
.podium-metric {
    display: grid;
    gap: 4px;
    justify-items: center;
    text-align: center;
    min-width: 0;
}

.podium-copy strong,
.podium-copy span,
.podium-metric span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.podium-avatar {
    width: 54px;
    height: 54px;
}

.podium-metric strong {
    font-size: 1.15rem;
    color: #f0f8ff;
}

.podium-metric span {
    color: var(--muted);
    font-size: 0.82rem;
}

.podium-base {
    width: 100%;
    height: var(--podium-height, 120px);
    border: 1px solid var(--line);
    border-radius: var(--radius) var(--radius) 0 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
}

.podium-card.place-1 .podium-base {
    background: linear-gradient(180deg, rgba(245, 197, 24, 0.28), rgba(245, 197, 24, 0.06));
    border-color: rgba(245, 197, 24, 0.3);
    box-shadow: 0 0 30px rgba(245, 197, 24, 0.1) inset;
}

.podium-card.place-2 .podium-base {
    background: linear-gradient(180deg, rgba(192, 204, 218, 0.22), rgba(192, 204, 218, 0.06));
    border-color: rgba(192, 204, 218, 0.2);
}

.podium-card.place-3 .podium-base {
    background: linear-gradient(180deg, rgba(205, 127, 50, 0.2), rgba(205, 127, 50, 0.06));
    border-color: rgba(205, 127, 50, 0.2);
}

.push-meta-row {
    justify-content: space-between;
    align-items: flex-start;
}

.push-completions {
    display: grid;
    gap: 8px;
}

.empty-inline {
    grid-column: 1 / -1;
    padding: 14px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-sm);
    color: var(--muted);
    text-align: center;
}

.empty-inline-text {
    display: inline-block;
    max-width: clamp(240px, 33%, 420px);
}

.podium-grid .empty-inline {
    align-self: stretch;
    display: grid;
    place-items: center;
}

.inline-feedback {
    min-height: 20px;
}

/* ─── Settings ─── */

.settings-form {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.settings-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.settings-seat-card {
    display: grid;
    gap: 8px;
    min-height: 128px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.settings-seat-card strong {
    font-size: 1.8rem;
    line-height: 1;
    color: #f0f8ff;
}

.settings-seat-card span {
    color: var(--muted);
}

.billing-panel {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.billing-summary-card {
    display: grid;
    gap: 8px;
    min-height: 128px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.billing-summary-card span,
.billing-summary-card small {
    color: var(--muted);
}

.billing-summary-card strong {
    font-size: 1.45rem;
    line-height: 1.1;
    color: #f0f8ff;
}

.billing-controls {
    display: grid;
    grid-template-columns: minmax(220px, 260px) auto;
    gap: 12px;
    align-items: end;
    margin-top: 12px;
}

.billing-seat-field {
    max-width: 260px;
}

.billing-actions {
    justify-content: flex-start;
}

.billing-actions .ghost-button,
.billing-actions .primary-button {
    min-width: 160px;
}

.settings-ok {
    color: var(--azure-soft);
}

/* ─── Member list ─── */

.member-list {
    display: grid;
    gap: 10px;
}

.member-row {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(240px, 0.9fr) auto;
    gap: 12px;
    align-items: center;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    transition: border-color 160ms ease;
}

.member-row:hover {
    border-color: var(--line-strong);
}

.member-copy {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.member-copy strong,
.member-copy span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.member-meta {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* ─── Groups ─── */

.group-grid-layout > .panel:nth-child(2) {
    grid-column: span 4;
}

.group-create-form {
    display: grid;
    gap: 12px;
}

.group-form-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 160px;
    gap: 12px;
}

.group-create-form textarea {
    width: 100%;
    min-height: 92px;
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-3);
    color: var(--text);
    font: inherit;
    line-height: 1.5;
    resize: vertical;
}

.group-create-form textarea::placeholder {
    color: var(--muted-2);
}

.group-create-form textarea:focus {
    outline: none;
    border-color: rgba(56, 189, 248, 0.45);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1);
}

.group-create-submit {
    width: 100%;
}

.primary-button.is-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.primary-button.is-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    margin: auto;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.45);
    border-top-color: #fff;
    animation: spin 700ms linear infinite;
}

.group-summary,
.group-card-grid,
.member-checklist {
    display: grid;
    gap: 10px;
}

.group-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.group-summary-card,
.group-card {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.group-summary-card {
    display: grid;
    gap: 6px;
    min-height: 108px;
}

.group-summary-card strong {
    font-size: 1.4rem;
    line-height: 1;
    color: #f0f8ff;
}

.group-card-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.group-card {
    display: grid;
    gap: 12px;
    text-align: left;
    cursor: pointer;
    transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.group-card:hover,
.group-card:focus-visible {
    border-color: rgba(56, 189, 248, 0.3);
    background: rgba(56, 189, 248, 0.06);
    transform: translateY(-1px);
}

.group-card-top,
.group-member-row,
.modal-actions,
.modal-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.modal-head {
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 4px;
}

.group-card-copy,
.group-card-copy span,
.group-member-copy,
.group-member-copy span {
    min-width: 0;
}

.group-card-copy {
    display: grid;
    gap: 4px;
}

.group-card-copy span,
.group-modal-meta,
.group-pill-row,
.group-subtle {
    color: var(--muted);
    font-size: 0.88rem;
}

.group-member-preview,
.group-pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.mini-pill {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 10px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 700;
}

.group-swatch {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    flex: 0 0 auto;
    margin-top: 4px;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

/* ─── Modal ─── */

.modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: 18px;
}

.modal.hidden {
    display: none !important;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(4, 8, 18, 0.78);
    backdrop-filter: blur(12px);
}

.modal-card {
    position: relative;
    z-index: 1;
    width: min(100%, 1080px);
    max-height: min(88vh, 920px);
    overflow: auto;
    padding: 20px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.group-modal-grid {
    display: grid;
    grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.1fr);
    gap: 14px;
}

.member-checklist {
    max-height: 62vh;
    overflow: auto;
    padding-right: 2px;
    scrollbar-width: thin;
    scrollbar-color: var(--surface-4) transparent;
}

.group-member-search {
    margin: 10px 0;
}

.group-member-row {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-3);
    align-items: center;
    transition: border-color 160ms ease;
}

.group-member-row:hover {
    border-color: var(--line-strong);
}

.group-member-row input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--azure-strong);
    flex: 0 0 auto;
}

.group-member-copy {
    display: grid;
    gap: 3px;
}

/* ─── Danger ─── */

.danger-button {
    border-color: rgba(251, 113, 133, 0.3);
    color: #ffd7db;
}

.danger-button:hover,
.danger-button:focus-visible {
    background: rgba(251, 113, 133, 0.1);
    border-color: rgba(251, 113, 133, 0.5);
}

.is-hidden {
    display: none !important;
}

/* ─── Responsive: 1100px ─── */

@media (max-width: 1100px) {
    .dash-shell {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .side-rail {
        position: static;
        padding: 5px;
    }

    .rail-label {
        display: none;
    }

    .page-nav {
        flex-direction: row;
        overflow-x: auto;
        gap: 3px;
        scrollbar-width: none;
    }

    .page-tab {
        width: auto;
        white-space: nowrap;
        min-height: 40px;
        padding: 0 14px;
        justify-content: center;
    }

    .page-tab.is-active {
        background: var(--surface-3);
        box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.18) inset;
    }

    .page-tab.is-active::before {
        display: none;
    }

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

    .panel.wide,
    .athlete-grid > .panel:nth-child(2) {
        grid-column: 1 / -1;
    }

    .leaderboard-layout,
    .detail-grid,
    .detail-duo,
    .detail-trio,
    .builder-panel-grid {
        grid-template-columns: 1fr;
    }

    .builder-search-card {
        position: static;
    }

    .push-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .push-field-workout,
    .push-field-audience,
    .push-field-target,
    .push-field-date,
    .push-submit-button {
        grid-column: span 1;
    }

    .builder-top-grid {
        grid-template-columns: 1fr 1fr;
    }

    .builder-create-grid {
        grid-template-columns: 1fr 1fr;
    }

    .builder-create-actions {
        grid-column: 1 / -1;
    }

    .builder-top-grid .grow,
    .push-field-note {
        grid-column: 1 / -1;
    }

    .builder-row-controls {
        grid-template-columns: 1fr 1fr;
    }

    .create-team-form {
        grid-template-columns: 1fr;
    }

    .settings-form {
        grid-template-columns: 1fr;
    }

    .settings-actions {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }

    .billing-panel,
    .billing-controls {
        grid-template-columns: 1fr 1fr;
    }

    .billing-seat-field,
    .billing-actions {
        grid-column: 1 / -1;
    }

    .podium-grid {
        grid-template-columns: 1fr;
        min-height: 0;
    }

    .group-card-grid,
    .group-modal-grid {
        grid-template-columns: 1fr;
    }
}

/* ─── Responsive: 780px ─── */

@media (max-width: 780px) {
    .shell {
        width: min(calc(100% - 16px), 1440px);
        padding: 10px 0 92px; /* leave room for the fixed bottom nav */
    }

    /* ── Compact topbar: brand + account on one row, team switcher below ── */
    .topbar {
        top: 6px;
        grid-template-columns: auto 1fr;
        grid-template-areas:
            "brand account"
            "team team";
        gap: 8px 10px;
        min-height: 0;
        padding: 8px 12px;
    }

    .brand { grid-area: brand; }
    .brand img { width: 106px; }
    .account { grid-area: account; justify-content: flex-end; }
    .team-switcher { grid-area: team; }

    /* ── Bottom tab bar navigation ── */
    .dash-shell {
        display: block;
        margin-top: 0;
    }

    .side-rail {
        position: fixed;
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 50;
        display: block;
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
        border: none;
        border-top: 1px solid var(--line-strong);
        border-radius: 0;
        background: rgba(10, 18, 32, 0.97);
        backdrop-filter: blur(18px) saturate(1.4);
        box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.5);
    }

    .rail-label { display: none; }

    .page-nav {
        flex-direction: row;
        justify-content: space-between;
        gap: 0;
        overflow: visible;
    }

    .page-tab {
        flex: 1 1 0;
        min-width: 0;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        min-height: 50px;
        padding: 5px 2px;
        border-radius: 9px;
        font-size: 0.6rem;
        font-weight: 700;
        text-align: center;
        color: var(--muted);
        background: transparent;
    }

    .page-tab svg { width: 21px; height: 21px; opacity: 0.7; }

    .page-tab span {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .page-tab.is-active {
        color: var(--azure-strong);
        background: rgba(56, 189, 248, 0.1);
    }

    .page-tab.is-active svg { opacity: 1; color: var(--azure-strong); }
    .page-tab.is-active::before { display: none; }

    /* ── Spacing / stacking ── */
    .panel { padding: 14px; }
    .dashboard-grid { gap: 12px; }
    .page-heading { padding: 6px 0 12px; }

    .page-heading,
    .panel-head,
    .detail-hero {
        flex-direction: column;
        align-items: stretch;
    }

    .invite-card { flex: 1 1 140px; min-width: 0; }

    .kpi-grid,
    .detail-stats,
    .activity-stat-grid {
        grid-template-columns: 1fr 1fr;
    }

    .kpi { min-height: 100px; padding: 14px; }
    .kpi strong { font-size: 1.7rem; }

    .bar-chart {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .calendar-grid { gap: 5px; }

    .calendar-cell {
        min-height: 62px;
        padding: 6px;
    }

    .calendar-cell-volume { gap: 3px; }

    th, td { padding: 10px 8px; }

    .push-form {
        grid-template-columns: 1fr;
    }

    .push-field-workout,
    .push-field-audience,
    .push-field-target,
    .push-field-date,
    .push-submit-button,
    .push-field-note {
        grid-column: 1 / -1;
    }

    .builder-top-grid,
    .builder-row-controls,
    .builder-result-card,
    .builder-create-grid {
        grid-template-columns: 1fr;
    }

    .builder-search-row,
    .builder-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .workout-library-preview {
        padding-left: 0;
    }

    .create-team-form,
    .group-summary,
    .billing-panel,
    .billing-controls {
        grid-template-columns: 1fr;
    }

    .group-form-row {
        grid-template-columns: 1fr;
    }

    .settings-form,
    .member-row {
        grid-template-columns: 1fr;
    }

    .member-meta {
        justify-content: flex-start;
    }

    .line-chart-card {
        overflow-x: auto;
    }

    .line-chart-card svg {
        min-width: 640px;
    }

    /* ── Modals: near full-screen sheets ── */
    .modal { padding: 10px; }

    .modal-card {
        padding: 16px;
        max-height: 94vh;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr 1fr; }

    /* Keep day cells legible — color + date carry the meaning, drop the cramped text */
    .calendar-cell-volume .calendar-stat { display: none; }
    .calendar-cell { min-height: 52px; }

    .page-tab span { font-size: 0.56rem; }

    .detail-stats { grid-template-columns: 1fr 1fr; }

    .muscle-figure svg { height: 300px; }
}

/* ── Gym Branding ─────────────────────────────────────── */
.branding-switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.branding-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.branding-switch-track {
    position: relative;
    width: 46px;
    height: 26px;
    border-radius: 999px;
    background: var(--surface-4);
    border: 1px solid var(--line-strong);
    transition: background 0.18s ease;
    flex: none;
}

.branding-switch-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--text);
    transition: transform 0.18s ease;
}

.branding-switch input:checked + .branding-switch-track {
    background: var(--green);
    border-color: var(--green);
}

.branding-switch input:checked + .branding-switch-track .branding-switch-thumb {
    transform: translateX(20px);
    background: #04140d;
}

.branding-switch-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}

.branding-panel {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-top: 6px;
}

.branding-panel.is-disabled {
    opacity: 0.5;
    pointer-events: none;
}

.branding-logo-field {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.branding-logo-preview {
    width: 84px;
    height: 84px;
    border-radius: var(--radius-sm);
    border: 1px dashed var(--line-strong);
    background: var(--surface-3);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex: none;
}

.branding-logo-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.branding-logo-empty {
    font-size: 11px;
    color: var(--muted-2);
}

.branding-logo-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
}

/* Buttons rendered as <label> need explicit flex centering (labels are
   inline by default, so min-height / text-centering don't apply otherwise). */
.branding-logo-actions .ghost-button {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.branding-link-field {
    max-width: 420px;
}
