.em-dashboard {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin: 30px 0;
}

.em-dashboard-card {
    background: #ffffff;
    border-radius: 18px;
    padding: 24px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

.em-dashboard-card h2 {
    margin-top: 0;
    font-size: 22px;
    line-height: 1.3;
}

.em-dashboard-stats {
    grid-column: 1 / -1;
}

.em-kpi-period-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.em-kpi-period-card {
    background: #f6f7f8;
    border-radius: 16px;
    padding: 18px;
}

.em-kpi-period-card h3 {
    margin: 0 0 10px;
    font-size: 17px;
}

.em-kpi-main {
    font-size: 30px;
    font-weight: 800;
    line-height: 1.1;
}

.em-kpi-change {
    margin-top: 8px;
    font-size: 13px;
    opacity: 0.75;
}

.em-kpi-list {
    margin: 14px 0 0;
    padding-left: 0;
    font-size: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.em-kpi-list-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #444;
}

.em-dashboard-filter {
    margin-bottom: 22px;
    padding: 16px;
    background: #f6f7f8;
    border-radius: 16px;
}

.em-filter-title {
    font-weight: 700;
    margin-bottom: 10px;
}

.em-filter-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

.em-filter-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #ffffff;
    border-radius: 999px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
}

.em-filter-button {
    border: none;
    border-radius: 999px;
    padding: 9px 16px;
    cursor: pointer;
}

.em-filter-reset {
    margin-left: 12px;
    font-size: 14px;
}

.em-chart-wrapper {
    position: relative;
    height: 380px;
    width: 100%;
}

.em-dashboard-filter {
    margin-bottom: 24px;
    padding: 18px;
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

.em-filter-title {
    font-weight: 700;
    margin-bottom: 12px;
}

.em-filter-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

.em-filter-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f6f7f8;
    border-radius: 999px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
}

.em-filter-button {
    border: none;
    border-radius: 999px;
    padding: 9px 16px;
    cursor: pointer;
}

.em-filter-reset {
    margin-left: 12px;
    font-size: 14px;
}

.em-dashboard-training {
    grid-column: 1 / -1;
}

.em-dashboard-activities,
.em-dashboard-events {
    grid-column: auto;
}
.em-dashboard-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.em-dashboard-link {
    font-size: 14px;
    text-decoration: none;
}

.em-activity-icon {
    font-size: 20px;
    width: 42px;
}

.em-event-status.is-active {
    font-weight: 600;
}

.em-event-status.is-finished {
    color: #777777;
}

/* ===== Activity list links ===== */
.em-activity-link {
    color: inherit;
    text-decoration: none;
    font-weight: 500;
}
.em-activity-link:hover { color: var(--em-primary); }

.em-detail-link {
    color: var(--em-primary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}
.em-detail-link:hover { color: var(--em-primary-hover); }

/* ===== Ghost button variant ===== */
.em-btn-ghost {
    background: var(--em-white);
    color: var(--em-brand);
    border: 1px solid var(--em-border);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.em-btn-ghost:hover {
    background: var(--em-soft-green);
    border-color: var(--em-primary);
    color: var(--em-primary-dark);
    transform: translateY(-1px);
}

.em-btn-sm {
    padding: 8px 16px !important;
    font-size: 13px !important;
}

/* ===== Activity Detail ===== */
.em-detail {
    max-width: 920px;
    margin: 0 auto;
    padding-bottom: 56px;
}

.em-detail-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
}

.em-pager {
    display: flex;
    gap: 8px;
}

.em-detail-header {
    display: flex;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 24px;
}

.em-detail-sport-badge {
    width: 58px;
    height: 58px;
    background: var(--em-soft-green);
    border: 1px solid var(--em-border);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    flex-shrink: 0;
}

.em-detail-header-text { flex: 1; }

.em-detail-title {
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--em-brand);
    margin: 0 0 5px;
    line-height: 1.2;
}

.em-detail-meta {
    color: var(--em-muted);
    font-size: 0.875rem;
    margin: 0 0 8px;
}

.em-detail-event-line { margin: 0; }

.em-event-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--em-soft-green);
    border: 1px solid #bbf7d0;
    color: var(--em-primary-dark);
    font-size: 0.8rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 999px;
    text-decoration: none;
    transition: all 0.15s;
}
.em-event-badge:hover {
    background: #dcfce7;
    color: var(--em-primary-dark);
    text-decoration: none;
}

/* Block 1 — Core stats */
.em-core-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 12px;
}

.em-core-stat {
    background: var(--em-white);
    border: 1px solid var(--em-border);
    border-radius: 20px;
    padding: 22px 16px 18px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.em-core-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--em-brand);
    line-height: 1;
    letter-spacing: -0.03em;
}

.em-core-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--em-muted);
}

/* Block 2 — Performance + Scores */
.em-data-block {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.em-perf-card,
.em-scores-card {
    background: var(--em-white);
    border: 1px solid var(--em-border);
    border-radius: 20px;
    padding: 20px;
}

.em-card-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--em-muted);
    margin: 0 0 14px;
}

.em-perf-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 16px;
}

.em-perf-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.em-perf-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--em-brand);
    line-height: 1;
}

.em-perf-value small {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--em-muted);
}

.em-perf-label {
    font-size: 0.72rem;
    color: var(--em-muted);
    font-weight: 500;
}

/* Score cards */
.em-scores-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.em-score-card {
    border-radius: 14px;
    padding: 14px 10px 12px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    border: 1px solid transparent;
}

.em-score-icon {
    font-size: 1.1rem;
    line-height: 1;
}

.em-score-value {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.02em;
}

.em-score-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.em-score-red       { background: #fff1f2; border-color: #fecdd3; }
.em-score-red       .em-score-value, .em-score-red       .em-score-label { color: #9f1239; }
.em-score-blue      { background: #eff6ff; border-color: #bfdbfe; }
.em-score-blue      .em-score-value, .em-score-blue      .em-score-label { color: #1e40af; }
.em-score-green-load { background: var(--em-soft-green); border-color: #bbf7d0; }
.em-score-green-load .em-score-value, .em-score-green-load .em-score-label { color: var(--em-primary-dark); }
.em-score-purple    { background: #faf5ff; border-color: #e9d5ff; }
.em-score-purple    .em-score-value, .em-score-purple    .em-score-label { color: #6d28d9; }

/* Map */
.em-detail-map-wrap {
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 12px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.09);
}

.em-detail-map { height: 380px; width: 100%; }

.em-map-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2.5px solid #fff;
    box-shadow: 0 1px 6px rgba(0,0,0,0.3);
}
.em-map-start { background: #22c55e; }
.em-map-end   { background: #ef4444; }

/* Elevation card — light */
.em-elevation-card {
    background: var(--em-white);
    border: 1px solid var(--em-border);
    border-radius: 20px;
    padding: 22px 22px 18px;
    margin-bottom: 12px;
}

.em-elevation-chart-wrap {
    height: 220px;
    position: relative;
}

/* ===== Segment Analysis ===== */
.em-segments-card { margin-bottom: 12px; }

.em-seg-count {
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--em-muted);
    margin-left: 8px;
    text-transform: none;
    letter-spacing: 0;
}

.em-seg-chart-wrap {
    height: 160px;
    margin-bottom: 16px;
    position: relative;
}

.em-seg-table-wrap {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 400px;
    border-radius: 12px;
    border: 1px solid var(--em-border);
    -webkit-overflow-scrolling: touch;
}

.em-seg-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    white-space: nowrap;
}

.em-seg-table th {
    background: var(--em-soft-green);
    color: var(--em-primary-dark);
    font-weight: 700;
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 8px 10px;
    text-align: left;
    position: sticky;
    top: 0;
    z-index: 1;
}

.em-seg-table td {
    padding: 6px 10px;
    border-bottom: 1px solid rgba(15,42,87,0.05);
    color: var(--em-brand);
}

.em-seg-table tr:last-child td { border-bottom: none; }
.em-seg-table tr.em-seg-climb    { background: rgba(34,197,94,0.04); }
.em-seg-table tr.em-seg-downhill { background: rgba(239,68,68,0.04); }
.em-seg-table tr:hover td { background: rgba(15,42,87,0.03); }

.em-seg-n    { color: var(--em-muted); font-size: 0.72rem; }
.em-seg-type { font-weight: 600; }
.em-seg-table tr.em-seg-climb    .em-seg-type { color: #16a34a; }
.em-seg-table tr.em-seg-downhill .em-seg-type { color: #dc2626; }
.em-seg-table tr.em-seg-flat     .em-seg-type { color: var(--em-muted); }

.em-seg-grade.pos { color: #16a34a; font-weight: 700; }
.em-seg-grade.neg { color: #dc2626; font-weight: 700; }
.em-seg-elev-g    { color: #16a34a; }
.em-seg-elev-l    { color: #dc2626; }

/* ===== Method comparison legend badges ===== */
.em-method-legend {
    font-size: 0.82rem;
    color: var(--em-muted);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.em-method-a-badge,
.em-method-b-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1;
}

.em-method-a-badge {
    background: var(--em-soft-green);
    color: var(--em-primary-dark);
    border: 1px solid #bbf7d0;
}

.em-method-b-badge {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* ===== Belastungsprofil two-chart layout ===== */
.em-profile-wrap {
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 14px;
    background: var(--em-soft-green, #f0fdf4);
}

.em-profile-elev {
    height: 80px;
    position: relative;
    background: var(--em-soft-green, #f0fdf4);
}

.em-profile-load {
    height: 320px;
    position: relative;
    background: var(--em-white, #fff);
    border-top: 1px solid var(--em-border, #e2e8f0);
}

/* ===== Belastungsprofil legend ===== */
.em-block-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    font-size: 0.78rem;
    color: var(--em-muted);
    margin-bottom: 4px;
}

.em-bleg-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.em-bleg-bar {
    display: inline-block;
    width: 14px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.em-bleg-line {
    display: inline-block;
    width: 18px;
    height: 2.5px;
    border-radius: 2px;
    flex-shrink: 0;
}

.em-bleg-area {
    display: inline-block;
    width: 16px;
    height: 10px;
    border-radius: 3px;
    border: 1px solid;
    flex-shrink: 0;
}

@media (max-width: 700px) {
    .em-core-stats   { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .em-core-value   { font-size: 1.5rem; }
    .em-data-block   { grid-template-columns: 1fr; }
    .em-scores-grid  { grid-template-columns: repeat(4, 1fr); }
    .em-detail-map   { height: 260px; }
    .em-elevation-chart-wrap { height: 170px; }
    .em-pager        { gap: 6px; }
    .em-profile-load { height: 270px; }
}

/* ===== Training Load Widget ===== */
.em-tlw { background: #fff; border-radius: 18px; padding: 24px; box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.em-tlw-title { margin: 0 0 18px; font-size: 20px; font-weight: 700; color: #0f2a57; line-height: 1.3; }
.em-tlw-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; padding: 0; background: transparent; border-bottom: none; scrollbar-width: none; }
.em-tlw-tabs::-webkit-scrollbar { display: none; }
.em-tlw-tab { flex: 0 0 auto; padding: 8px 18px; background: transparent; border: 2px solid #dfe7e2; border-radius: 999px; font-size: .85rem; font-weight: 600; color: #647067; cursor: pointer; white-space: nowrap; transition: all .18s; }
.em-tlw-tab:hover { color: #1fbf75; border-color: #1fbf75; background: rgba(31,191,117,0.07); }
.em-tlw-tab--active { color: #fff; background: #1fbf75; border-color: #1fbf75; }
.em-tlw-body { padding: 0; }
.em-tlw-chart-wrap { height: 880px; position: relative; background: #fff; }
@media (max-width: 700px) {
    .em-tlw-chart-wrap { height: 720px; }
    .em-tlw-tab { padding: 7px 14px; font-size: .78rem; }
}

/* ===== Heatmap Widget ===== */
.em-heatmap { background: #fff; border-radius: 18px; padding: 24px; box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.em-heatmap-title { margin: 0 0 16px; font-size: 20px; font-weight: 700; color: #0f2a57; line-height: 1.3; }
.em-heatmap-meta { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.em-heatmap-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.em-heatmap-filter { padding: 7px 16px; background: transparent; border: 2px solid #dfe7e2; border-radius: 999px; font-size: .82rem; font-weight: 600; color: #647067; cursor: pointer; transition: all .15s; }
.em-heatmap-filter:hover { color: #1fbf75; border-color: #1fbf75; background: rgba(31,191,117,0.07); }
.em-heatmap-filter--active { color: #fff; background: #1fbf75; border-color: #1fbf75; }
.em-heatmap-counter { font-size: .85rem; color: #647067; font-weight: 500; white-space: nowrap; }
.em-heatmap-map { position: relative; height: 500px; border-radius: 14px; overflow: hidden; }
.em-heatmap-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: #1a1a2e; color: #94a3b8; font-size: .9rem; z-index: 1; border-radius: 14px; }
.em-heatmap-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #94a3b8; font-size: .9rem; pointer-events: none; }
@media (max-width: 700px) {
    .em-heatmap-map { height: 300px; }
    .em-heatmap-meta { flex-direction: column; align-items: flex-start; }
}

/* ── Heatmap Widget ─────────────────────────────────────────────────────── */
 
.em-heatmap {
    background: var(--color-surface, #13131e);
    border-radius: var(--border-radius, 12px);
    border: 1px solid var(--color-border, rgba(255,255,255,0.08));
    overflow: hidden;
}
 
.em-heatmap-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border, rgba(255,255,255,0.08));
    display: flex;
    flex-direction: column;
    gap: 10px;
}
 
.em-heatmap-title {
    font-size: 16px;
    font-weight: 500;
    margin: 0;
    color: var(--color-text, #e2e2ee);
}
 
.em-heatmap-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
 
.em-heatmap-filters {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
 
.em-heatmap-filter {
    padding: 5px 12px;
    border-radius: 20px;
    border: 1px solid var(--color-border, rgba(255,255,255,0.08));
    background: transparent;
    color: var(--color-text-muted, #5a5a72);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
 
.em-heatmap-filter:hover {
    border-color: rgba(255,255,255,0.2);
    color: var(--color-text, #e2e2ee);
}
 
.em-heatmap-filter--active {
    background: var(--color-primary, #ff5030);
    border-color: var(--color-primary, #ff5030);
    color: #fff;
    font-weight: 500;
}
 
.em-heatmap-counter {
    margin-left: auto;
    font-size: 12px;
    color: var(--color-text-muted, #5a5a72);
    white-space: nowrap;
}
 
/* ── Karte – WICHTIG: explizite Höhe für MapLibre ──────────────────────── */
.em-heatmap-map {
    position: relative;
    height: 500px;      /* MapLibre braucht zwingend eine feste Höhe */
    width: 100%;
    background: #0a0c14;
}
 
/* Loading-Overlay */
.em-heatmap-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0a0c14;
    z-index: 10;
    font-size: 13px;
    color: var(--color-text-muted, #5a5a72);
    pointer-events: none;
}
 
/* Fehler-Overlay */
.em-heatmap-error {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.75);
    z-index: 20;
    padding: 20px;
}
 
.em-heatmap-error-inner {
    background: #1a1a1a;
    border: 1px solid #ff5030;
    border-radius: 8px;
    padding: 16px 20px;
    max-width: 440px;
    font-size: 12px;
    color: #ff9980;
    line-height: 1.6;
}
 
.em-heatmap-error-inner strong {
    color: #ff5030;
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
}
 
.em-heatmap-error-retry {
    margin-top: 10px;
    padding: 6px 14px;
    border-radius: 5px;
    border: 1px solid #ff5030;
    background: transparent;
    color: #ff5030;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
 
.em-heatmap-error-retry:hover {
    background: #ff5030;
    color: #fff;
}
 
/* Leer-Zustand */
.em-heatmap-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: var(--color-text-muted, #5a5a72);
    pointer-events: none;
}
 
/* Responsive */
@media (max-width: 640px) {
    .em-heatmap-map {
        height: 320px;
    }
 
    .em-heatmap-meta {
        flex-direction: column;
        align-items: flex-start;
    }
 
    .em-heatmap-counter {
        margin-left: 0;
    }
}

/* ── Activity Insights ──────────────────────────────────────────────────────── */

.em-activity-insights {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 16px 0;
}

.em-insight {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--em-soft-bg, #f4f9f4);
    border: 1px solid var(--em-border, #e4e8ec);
    font-size: 0.9rem;
    line-height: 1.4;
}

.em-insight--crown {
    background: #fffbe6;
    border-color: #f5c518;
}

.em-insight-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    line-height: 1.3;
}

.em-insight-text {
    flex: 1;
    color: var(--em-text, #1a2f4a);
}

.em-insight-meta {
    color: var(--em-muted, #647067);
    font-size: 0.82em;
    margin-left: 4px;
}

.em-insight-crown {
    display: inline-block;
    margin-left: 6px;
    font-size: 0.8em;
    font-weight: 600;
    color: #b8860b;
    background: #fff8d6;
    padding: 1px 6px;
    border-radius: 6px;
    border: 1px solid #f5c518;
}

.em-insight--excluded {
    opacity: 0.55;
    background: var(--em-border, #e4e8ec);
    border-color: transparent;
}
.em-insight--excluded .em-insight-text { text-decoration: line-through; color: var(--em-muted, #647067); }
.em-insight-excluded-label { text-decoration: none !important; font-style: italic; }

.em-peak-detail-toggle {
    flex-shrink: 0;
    font-size: 11px;
    padding: 2px 8px;
    border: 1px solid var(--em-border, #e0e0e0);
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    color: var(--em-primary, #1a2f4a);
    white-space: nowrap;
    align-self: center;
}
.em-peak-detail-toggle:hover { background: var(--em-border, #e0e0e0); }
.em-peak-detail-toggle:disabled { opacity: .5; cursor: default; }
}