body { font-family: 'Roboto', sans-serif; background-color: #f4f7f6; color: #333; margin: 0; padding: clamp(12px, 1.5vw, 24px); }
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 0; }
.login-page .app-shell { display: block; width: 100%; }
.login-page .container { background: none; box-shadow: none; padding: 0; max-width: 100%; }
.app-shell { display: grid; gap: 20px; align-items: start; }
.has-sidebar .app-shell { grid-template-columns: 240px minmax(0, 1fr); }
.no-sidebar .app-shell { grid-template-columns: 1fr; }
.container { width: 100%; max-width: 98vw; margin: 0 auto; background-color: #fff; padding: clamp(16px, 2vw, 30px); border-radius: 8px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); }
h1 { color: #007bff; text-align: center; margin-bottom: 30px; }
.upload-form { display: flex; flex-direction: column; align-items: center; padding: 20px; border: 2px dashed #ccc; border-radius: 8px; margin-bottom: 30px; }
.upload-form label { font-weight: bold; margin-bottom: 5px; }
.upload-form input[type="file"], .upload-form input[type="number"], .upload-form select { padding: 10px; margin-bottom: 15px; border: 1px solid #ddd; border-radius: 4px; width: 100%; max-width: 300px; box-sizing: border-box; }
.upload-form button { background-color: #28a745; color: white; padding: 10px 20px; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; transition: background-color 0.3s; }
.upload-form button:hover { background-color: #218838; }
.error { color: red; text-align: center; margin-bottom: 20px; font-weight: bold; }

.athlete-switcher {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 20px;
    border: 2px dashed #ccc;
    border-radius: 8px;
    margin-bottom: 30px;
}

.athlete-switcher__label {
    font-weight: bold;
}

.athlete-switcher__list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.athlete-pill {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid #cfd8dc;
    background-color: #f7f9fa;
    color: #2f3a3f;
    text-decoration: none;
    font-weight: 600;
    letter-spacing: 0.2px;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
}

.athlete-pill:hover {
    background-color: #e9f5ee;
    border-color: #28a745;
    color: #1f7a34;
}

.athlete-pill.is-active {
    background-color: #28a745;
    border-color: #28a745;
    color: #fff;
    box-shadow: 0 6px 12px rgba(40, 167, 69, 0.25);
}

/* Login Form Styles */
.login-form {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    padding: 30px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-form h2 {
    text-align: center;
    color: #007bff;
    margin-bottom: 10px;
}

.login-form div {
    display: flex;
    flex-direction: column;
}

.login-form label {
    font-weight: bold;
    margin-bottom: 5px;
}

.login-form input[type="text"],
.login-form input[type="password"] {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

.login-form button {
    background-color: #007bff;
    color: white;
    padding: 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

.login-form button:hover {
    background-color: #0056b3;
}

/* User Info Styles */
.user-info {
    text-align: right;
    margin-bottom: 20px;
}

.user-info span {
    font-weight: bold;
    margin-right: 10px;
}

.user-info a {
    color: #007bff;
    text-decoration: none;
}

.user-info a:hover {
    text-decoration: underline;
}

.sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    background-color: #fff;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
}
.sidebar__header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.sidebar__logo-link { display: inline-flex; }
.sidebar__logo {
    width: 100%;
    max-width: 130px;
    height: auto;
    display: block;
}
.sidebar__welcome { font-weight: 700; color: #0f172a; font-size: 0.9em; }
.sidebar__nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar__link {
    display: block;
    text-decoration: none;
    color: #1f2a37;
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 0.925em;
    font-weight: 400;
    transition: background-color 0.2s, color 0.2s;
}
.sidebar__link:hover { background-color: #f1f5f9; }
.sidebar__link--active {
    background-color: #eff6ff;
    color: #1d4ed8;
    font-weight: 700;
    border-left: 3px solid #1d4ed8;
    padding-left: 9px;
}
.sidebar__logout { color: #b42318; }
.sidebar__footer { margin-top: auto; }

/* ── Admin sidebar section ── */
.sidebar__admin-section {
    margin-top: 2px;
    background: #1e3a5f;
    border-radius: 8px;
    padding: 4px 4px 6px;
}
.sidebar__admin-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: #93c5fd;
    padding: 4px 8px 6px;
}
.sidebar__admin-label::before {
    content: '';
    display: inline-block;
    width: 6px; height: 6px;
    background: #3b82f6;
    border-radius: 50%;
}
.sidebar__admin-section .sidebar__link {
    color: #bfdbfe;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 0.9em;
}
.sidebar__admin-section .sidebar__link:hover {
    background-color: rgba(255,255,255,0.1);
    color: #fff;
}
.sidebar__admin-section .sidebar__link--active {
    background-color: rgba(59,130,246,0.3);
    color: #fff;
    border-left-color: #60a5fa;
    font-weight: 700;
}
html.dark-mode .sidebar__admin-section { background: #172554; }
html.dark-mode .sidebar__admin-section .sidebar__link { color: #93c5fd; }
html.dark-mode .sidebar__admin-section .sidebar__link:hover { background-color: rgba(255,255,255,0.08); color: #e0f2fe; }
html.dark-mode .sidebar__admin-section .sidebar__link--active { background-color: rgba(59,130,246,0.25); color: #bfdbfe; }

/* ── Coach sidebar section ── */
.sidebar__coach-section {
    margin-top: 2px;
    background: #451a03;
    border-radius: 8px;
    padding: 4px 4px 6px;
}
.sidebar__coach-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: #fcd34d;
    padding: 4px 8px 6px;
}
.sidebar__coach-label::before {
    content: '';
    display: inline-block;
    width: 6px; height: 6px;
    background: #f59e0b;
    border-radius: 50%;
}
.sidebar__coach-section .sidebar__link {
    color: #fde68a;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 0.9em;
}
.sidebar__coach-section .sidebar__link:hover {
    background-color: rgba(255,255,255,0.1);
    color: #fff;
}
.sidebar__coach-section .sidebar__link--active {
    background-color: rgba(245,158,11,0.35);
    color: #fff;
    border-left-color: #fbbf24;
    font-weight: 700;
}
html.dark-mode .sidebar__coach-section { background: #3b1a00; }
html.dark-mode .sidebar__coach-section .sidebar__link { color: #fcd34d; }
html.dark-mode .sidebar__coach-section .sidebar__link:hover { background-color: rgba(255,255,255,0.08); color: #fef3c7; }
html.dark-mode .sidebar__coach-section .sidebar__link--active { background-color: rgba(245,158,11,0.25); color: #fde68a; }


/* Tab Styles */
.tab { overflow: hidden; border-bottom: 1px solid #ccc; background-color: #f1f1f1; border-radius: 8px 8px 0 0; }
.tab button { background-color: inherit; float: left; border: none; outline: none; cursor: pointer; padding: 14px 16px; transition: 0.3s; font-size: 17px; }
.tab button:hover { background-color: #ddd; }
.tab button.active { background-color: #ccc; }
.tabcontent { display: none; padding: 20px 12px; border-top: none; }

/* Layout Styles */
.primary-visuals { display: grid; grid-template-columns: 1fr; gap: 20px; margin-bottom: 30px; }
@media (min-width: 1200px) { .primary-visuals { grid-template-columns: 2fr 1fr; } }
.main-visuals, .side-visuals { display: flex; flex-direction: column; gap: 20px; }
.map-section, .graph-section { background-color: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.map-container { height: 500px; width: 100%; border-radius: 8px; position: relative; overflow: hidden; }
.summary-metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; margin-top: 30px; }
.summary-section { border: 1px solid #ddd; border-radius: 8px; padding: 20px; }
.summary-section { min-width: 0; }
.summary-section h2 { color: #007bff; border-bottom: 2px solid #007bff; padding-bottom: 10px; margin: 0; font-size: 1.2em; }
.calendar-section {
    background: linear-gradient(135deg, rgba(224, 242, 254, 0.45), rgba(255, 255, 255, 0.95));
    border: 1px solid #dbe7f3;
}
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}
.calendar-subtitle {
    margin: 6px 0 0;
    color: #475569;
    font-size: 0.95em;
}
.calendar-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.calendar-controls button {
    border: 1px solid #cbd5f5;
    background: #fff;
    color: #1f2937;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}
.calendar-controls button:hover {
    border-color: #2563eb;
    color: #2563eb;
}
.calendar-month-picker-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}
.calendar-month-label {
    font-weight: 700;
    font-size: 1.05em;
    color: #0f172a;
    padding: 6px 10px;
    background: #eff6ff;
    border-radius: 999px;
    border: 1px solid transparent;
}
.calendar-month-label:hover {
    border-color: #2563eb;
    color: #2563eb;
}
.calendar-month-label:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}
.calendar-month-picker {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    border: 0;
    padding: 0;
    margin: 0;
    z-index: 2;
}
.ai-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.ai-tablink {
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #1f2937;
    border-radius: 999px;
    padding: 6px 12px;
    font-weight: 600;
    cursor: pointer;
}
.ai-tablink--active {
    background: #2563eb;
    color: #fff;
    border-color: #1d4ed8;
}
.ai-tabcontent {
    display: none;
}
.ai-tabcontent--active {
    display: block;
}
.calendar-grid {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr)) 170px;
    gap: 0;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #d6e4f0;
    background: #f8fafc;
}
.calendar-weekdays div {
    padding: 10px 12px;
    font-weight: 700;
    font-size: 0.9em;
    color: #334155;
    border-right: 1px solid #d6e4f0;
}
.calendar-weekdays div:last-child {
    border-right: none;
    text-align: center;
    background: #1f2937;
    color: #fff;
}
.calendar-body {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr)) 170px;
    grid-auto-rows: minmax(160px, auto);
    border: 1px solid #d6e4f0;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}
.calendar-cell,
.calendar-weekly {
    border-right: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    padding: 8px 10px;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.calendar-cell--outside {
    background: #f1f5f9;
    color: #94a3b8;
}
.calendar-cell--today {
    background: rgba(59, 130, 246, 0.08);
    border-left: 3px solid #2563eb;
}
.calendar-cell--period {
    background: rgba(244, 63, 94, 0.07);
    border-left: 3px solid #f43f5e;
}
.calendar-cell--target {
    outline: 2px solid #14b8a6;
    box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.15);
}
.calendar-date {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    color: #0f172a;
    font-size: 0.95em;
}
.calendar-note {
    border: none;
    background: transparent;
    color: #94a3b8;
    font-weight: 600;
    font-size: 0.85em;
    line-height: 1;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.15s;
}
.calendar-note:hover { color: #3b82f6; }
.calendar-note--filled { color: #3b82f6; }
.calendar-note-text {
    font-size: 0.78em;
    color: #7c2d12;
    background: #fff7ed;
    border-radius: 6px;
    padding: 4px 6px;
    line-height: 1.2;
    max-height: 48px;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.calendar-note-text--empty {
    display: none;
}
.calendar-note-content {
    flex: 1 1 auto;
    min-width: 0;
}
.calendar-note-delete {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid #f97316;
    background: #fff;
    color: #c2410c;
    font-weight: 700;
    font-size: 0.8em;
    line-height: 1;
    cursor: pointer;
    flex: 0 0 auto;
    padding: 0;
}
.calendar-note-delete--hidden {
    display: none;
}
.calendar-races {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.calendar-race {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    background: #ecfeff;
    border-left: 4px solid #06b6d4;
    color: #0e7490;
    font-size: 0.78em;
}
.calendar-race__label {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.calendar-race__details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.calendar-race__name {
    font-weight: 600;
}
.calendar-race__meta {
    color: #0f766e;
    font-size: 0.92em;
}
.calendar-race__desc {
    color: #134e4a;
    font-size: 0.9em;
}
.calendar-race-delete {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid #0891b2;
    background: #fff;
    color: #0e7490;
    font-weight: 700;
    font-size: 0.8em;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}
.calendar-workouts {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 220px;
    overflow-y: auto;
    padding-right: 4px;
}
.calendar-workout {
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-decoration: none;
    color: #0f172a;
    background: #ffffff;
    border-left: 4px solid #f97316;
    border-radius: 8px;
    padding: 6px 8px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.calendar-workout:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.12);
}
.calendar-workout__title {
    font-weight: 600;
    font-size: 0.85em;
}
.activity-icon {
    margin-right: 3px;
    font-size: 0.85em;
    line-height: 1;
}
.calendar-workout__meta {
    font-size: 0.75em;
    color: #64748b;
}
.calendar-workout__device {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.68em;
    color: #94a3b8;
    margin-top: 1px;
}
.calendar-workout__device-logo {
    height: 9px;
    width: auto;
    display: block;
    flex-shrink: 0;
    opacity: 0.7;
}
html.dark-mode .calendar-workout__device { color: #64748b; }
.calendar-weekly {
    background: #0f172a;
    color: #e2e8f0;
    align-items: flex-start;
    justify-content: center;
    gap: 12px;
}
.calendar-weekly__title {
    font-weight: 700;
    font-size: 0.9em;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #f8fafc;
}
.calendar-weekly__metric {
    display: flex;
    justify-content: space-between;
    width: 100%;
    font-size: 0.85em;
    color: #cbd5f5;
}
.calendar-weekly__metric strong {
    color: #fff;
}
.calendar-legend {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 12px;
    font-size: 0.85em;
    color: #475569;
}
.calendar-dot {
    display: inline-flex;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
}
.calendar-dot--run { background: #f97316; }
.calendar-dot--note { background: #fb923c; }
.calendar-dot--race { background: #06b6d4; }
.calendar-dot--period { background: #f43f5e; }
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}
.modal-overlay[aria-hidden="true"] {
    display: none;
}
.modal {
    width: min(520px, 92vw);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-header h3 {
    margin: 0;
    font-size: 1.15em;
}
.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid #cbd5f5;
    background: #f8fafc;
    color: #0f172a;
    font-size: 1.1em;
    cursor: pointer;
}
.modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.modal-tabs {
    display: flex;
    gap: 8px;
}
.modal-tab {
    flex: 1;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid #cbd5f5;
    background: #f8fafc;
    font-weight: 600;
    cursor: pointer;
}
.modal-tab--active {
    background: #0ea5e9;
    border-color: #0ea5e9;
    color: #fff;
}
.modal-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.modal-section label {
    font-weight: 600;
    color: #0f172a;
}
.modal-section input,
.modal-section textarea,
.modal-section select {
    padding: 8px 10px;
    border: 1px solid #cbd5f5;
    border-radius: 8px;
    font-size: 0.95em;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.modal-action {
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-weight: 600;
    cursor: pointer;
}
.modal-action--secondary {
    background: #f8fafc;
    border-color: #cbd5f5;
    color: #0f172a;
}
.modal-action--primary {
    background: #0ea5e9;
    border-color: #0ea5e9;
    color: #fff;
}
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.info-icon { flex: 0 0 auto; width: 24px; height: 24px; border-radius: 999px; border: 1px solid #007bff; background: #fff; color: #007bff; font-weight: 700; line-height: 1; cursor: pointer; }
.info-icon:hover { background: #e8f4ff; }
.info-icon:focus { outline: 2px solid #0056b3; outline-offset: 2px; }

.info-icon { position: relative; }
.info-icon[data-tooltip]:hover::after,
.info-icon[data-tooltip]:focus::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 120%;
    right: 0;
    width: min(360px, 70vw);
    background: #111827;
    color: #fff;
    padding: 10px 12px;
    border-radius: 8px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    font-weight: 400;
    text-align: left;
    white-space: pre-line;
    z-index: 1000;
}
.info-icon[data-tooltip]:hover::before,
.info-icon[data-tooltip]:focus::before {
    content: "";
    position: absolute;
    top: 108%;
    right: 10px;
    border: 6px solid transparent;
    border-bottom-color: #111827;
    z-index: 1001;
}
.info-icon[data-tooltip=""]::before,
.info-icon[data-tooltip=""]::after { display: none; content: none; }
.metric { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dotted #eee; }
.metric:last-child { border-bottom: none; }
.metric-name { font-weight: 500; }
.metric-value { font-weight: 700; color: #333; }
.splits-table { width: 100%; border-collapse: collapse; margin-top: 20px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.splits-table th, .splits-table td { padding: 12px 15px; text-align: left; border-bottom: 1px solid #ddd; }
.splits-table th { background-color: #007bff; color: white; }
.splits-table tr:nth-child(even) { background-color: #f8f9fa; }
.splits-table tr:hover { background-color: #e9ecef; }
.splits-table-container { overflow-x: auto; }
.splits-table td.split-best { font-weight: 700; background-color: #e8f4ff; }
.splits-table td.split-warn { font-weight: 700; background-color: #fff3cd; }
.alerts-note { margin: 10px 0 18px; color: #555; }
.alerts-table th { white-space: nowrap; }
.alerts-cell { min-width: 140px; vertical-align: top; }
.alerts-cell.missing { color: #6c757d; }
.alerts-cell.yellow { background-color: #fff3cd; font-weight: 600; }
.alerts-cell.red { background-color: #f8d7da; font-weight: 600; }
.alerts-value { font-size: 1.05em; font-weight: 700; }
.alerts-avg { font-size: 0.85em; color: #555; margin-top: 4px; }
.alerts-flag { font-size: 0.8em; text-transform: uppercase; margin-top: 6px; color: #7a4a00; }
.alerts-cell.red .alerts-flag { color: #7a1b1b; }
.alerts-row { cursor: pointer; }

/* Make Plotly charts responsive */
.js-plotly-plot, .plotly { width: 100% !important; }
@media (min-width: 900px) { .upload-form { flex-direction: row; gap: 20px; } }
@media (max-width: 900px) {
    .has-sidebar .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; }
    .sidebar__nav { flex-direction: row; flex-wrap: wrap; }
    .sidebar__link { flex: 1 1 auto; text-align: center; }
    .sidebar__footer { margin-top: 0; }
    .calendar-weekdays,
    .calendar-body {
        grid-template-columns: repeat(7, minmax(0, 1fr));
    }
    .calendar-weekly,
    .calendar-weekly-heading {
        display: none;
    }
}

/* ── Garmin-style stacked charts ─────────────────────────── */
.garmin-charts-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}
.garmin-charts-controls { display: flex; align-items: center; gap: 10px; }
.garmin-charts-hint { font-size: 0.85em; color: #6c757d; }
.garmin-charts-readout {
    margin-top: 8px; font-size: 0.9em; color: #333; min-height: 1.4em;
    display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: baseline;
}
.garmin-charts-readout span { white-space: nowrap; }
.garmin-charts-with-avg { display: flex; gap: 12px; align-items: flex-start; }
.garmin-charts-with-avg .garmin-charts-container { flex: 1; min-width: 0; }
.garmin-avg-box {
    width: 175px; flex-shrink: 0;
    background: #f8f9fa; border: 1px solid #e2e8f0; border-radius: 8px;
    padding: 10px 12px; font-size: 0.87em;
}
.garmin-avg-title {
    font-weight: 700; font-size: 0.82em; color: #64748b;
    text-transform: uppercase; letter-spacing: 0.05em;
    margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid #e2e8f0;
}
.garmin-avg-row {
    display: flex; justify-content: space-between; align-items: baseline;
    padding: 3px 0; border-bottom: 1px dotted #eee; gap: 6px;
}
.garmin-avg-row:last-child { border-bottom: none; }
.garmin-avg-label { font-weight: 600; white-space: nowrap; flex-shrink: 0; }
.garmin-avg-value { color: #1f2937; text-align: right; white-space: nowrap; }
.garmin-charts-container {
    display: flex; flex-direction: column; gap: 0;
    border: 1px solid #e0e0e0; border-radius: 6px; overflow: hidden;
}
.garmin-chart-row {
    display: grid;
    grid-template-columns: 88px 1fr;
    height: 120px;
    border-bottom: 1px solid #e8e8e8;
    background: #fff;
}
.garmin-chart-row:last-child { border-bottom: none; }
.garmin-chart-row[data-is-last="true"] { height: 152px; }
.garmin-chart-label {
    display: flex; flex-direction: column; justify-content: center;
    align-items: flex-start; padding: 8px 10px;
    background: #fafafa; border-right: 1px solid #e0e0e0; gap: 2px;
}
.garmin-chart-metric-name {
    font-weight: 700; font-size: 0.78em;
    text-transform: uppercase; letter-spacing: 0.04em;
}
.garmin-chart-metric-unit { font-size: 0.72em; color: #888; }
.garmin-chart-canvas-wrap { position: relative; height: 100%; min-width: 0; }
.garmin-chart-canvas-wrap canvas { display: block; }
.garmin-x-toggle { display: flex; border: 1px solid #cbd5e0; border-radius: 5px; overflow: hidden; }
.garmin-x-toggle-btn { padding: 4px 14px; border: none; background: #fff; cursor: pointer; font-size: 0.85em; color: #555; transition: background 0.15s, color 0.15s; }
.garmin-x-toggle-btn.active { background: #3182ce; color: #fff; font-weight: 600; }

/* ── Activity merged view layout ── */
.activity-layout { display: grid; grid-template-columns: 1fr 360px; gap: 16px; align-items: start; }
.activity-main { min-width: 0; }
.activity-sidebar { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 12px; }

.metric-selector-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 0 0 10px; border-bottom: 1px solid #e2e8f0; margin-bottom: 10px; }
.metric-chips { display: flex; flex-wrap: wrap; gap: 5px; flex: 1; min-width: 0; }
.metric-chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 999px;
    border: 1.5px solid #cbd5e0; background: #fff;
    font-size: 0.78em; font-weight: 600; cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    color: #555; user-select: none;
}
.metric-chip .chip-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.metric-chip.is-active { border-color: transparent; color: #fff; }
.metric-chip:not(.is-active) .chip-dot { opacity: 0.35; }
.metric-chip-save { padding: 3px 10px; border-radius: 999px; border: 1px solid #cbd5e0; background: #f8fafc; font-size: 0.78em; cursor: pointer; color: #555; white-space: nowrap; }
.metric-chip-save:hover { background: #e2e8f0; }

.activity-controls-bar { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.btn-reset-zoom { padding: 4px 12px; border: 1px solid #cbd5e0; border-radius: 5px; background: #fff; font-size: 0.85em; cursor: pointer; color: #555; }
.btn-reset-zoom:hover { background: #f1f5f9; }

.mini-map-section { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.mini-map-header { display: flex; align-items: center; justify-content: space-between; padding: 7px 10px; font-size: 0.82em; font-weight: 600; color: #374151; border-bottom: 1px solid #e2e8f0; }
.mini-map-expand-btn { background: none; border: none; cursor: pointer; color: #6b7280; padding: 2px 4px; border-radius: 4px; display: flex; align-items: center; }
.mini-map-expand-btn:hover { background: #f1f5f9; color: #374151; }
.mini-map-container { height: 360px; width: 100%; position: relative; overflow: hidden; }
.mini-map-container iframe, .mini-map-container .folium-map { width: 100%; height: 100%; border: none; }
.mini-map-container.is-fullscreen { position: fixed; inset: 0; z-index: 9999; height: 100vh !important; border-radius: 0; }
.mini-map-fullscreen-close { position: fixed; top: 12px; right: 16px; z-index: 10000; background: rgba(0,0,0,0.6); color: #fff; border: none; border-radius: 50%; width: 36px; height: 36px; font-size: 20px; cursor: pointer; display: none; align-items: center; justify-content: center; line-height: 1; }
.mini-map-fullscreen-close.is-visible { display: flex; }
/* ── Map route playback controls ─────────────────────────────────────── */
.map-playback { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-top: 1px solid #e2e8f0; background: #f8fafc; }
.map-play-btn { flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; border: none; background: #2563eb; color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background 0.15s; padding: 0; }
.map-play-btn:hover { background: #1d4ed8; }
.map-play-btn:disabled { background: #94a3b8; cursor: default; }
.map-play-scrubber { flex: 1; height: 4px; cursor: pointer; accent-color: #2563eb; min-width: 0; }
.map-play-time { flex-shrink: 0; font-size: 0.73em; font-weight: 600; color: #64748b; min-width: 36px; text-align: right; font-variant-numeric: tabular-nums; }
.map-play-speed { flex-shrink: 0; font-size: 0.72em; font-weight: 700; padding: 3px 8px; border: none; border-radius: 20px; background: #dbeafe; color: #1d4ed8; cursor: pointer; letter-spacing: 0.02em; transition: background 0.15s, color 0.15s; }
.map-play-speed:hover { background: #bfdbfe; color: #1e40af; }
html.dark-mode .map-playback { background: #1e293b; border-top-color: #334155; }
html.dark-mode .map-play-time { color: #94a3b8; }
html.dark-mode .map-play-speed { background: #1e3a5f; color: #93c5fd; }
html.dark-mode .map-play-speed:hover { background: #1d4ed8; color: #fff; }

/* ── Garmin Attribution (spec-compliant) ───────────────────────────────── */
/* Map sidebar badge — dark bar below the mini-map */
.garmin-device-badge { display: flex; align-items: center; gap: 7px; padding: 5px 10px; background: #1c1c1c; border-top: 1px solid #333; }
.garmin-device-badge__tag { height: 13px; width: auto; display: block; flex-shrink: 0; }
.garmin-device-badge__model { font-size: 0.72em; color: #bbb; font-weight: 500; }
html.dark-mode .garmin-device-badge { background: #0f0f0f; border-top-color: #222; }

/* Inline attribution tag — used in section headers and card titles */
.garmin-attr { display: inline-flex; align-items: center; gap: 5px; font-size: 0.72em; font-weight: 500; color: #475569; white-space: nowrap; }
.garmin-attr__tag { height: 11px; width: auto; display: block; flex-shrink: 0; }
.garmin-attr__model { color: #64748b; }
html.dark-mode .garmin-attr { color: #64748b; }
html.dark-mode .garmin-attr__model { color: #94a3b8; }

/* Block-level attribution line — used under chart headings or section titles */
.garmin-attribution { display: flex; align-items: center; gap: 6px; font-size: 0.75em; color: #64748b; margin-top: 6px; }
.garmin-attribution__tag { height: 12px; width: auto; display: block; flex-shrink: 0; }
html.dark-mode .garmin-attribution { color: #475569; }
/* Swap black→white logo in dark mode via content replacement trick */
html.dark-mode .garmin-tag-img { content: url('/static/garmin-tag-white.png'); }
html.dark-mode .garmin-attribution__tag { content: url('/static/garmin-tag-white.png'); }
/* Ensure wellness h1 margin is handled when nested in flex wrapper */
.wl-page h1 { margin: 0; }

/* ── Athlete Feedback: Feel + RPE widget (sidebar) ─────────────────────── */
.feel-rpe-widget { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 10px 12px; margin-top: 8px; }
.feel-rpe-title { font-weight: 700; font-size: 0.72em; color: #64748b; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; gap: 8px; }
.feel-rpe-saved { font-size: 0.85em; color: #16a34a; background: #dcfce7; border-radius: 999px; padding: 1px 7px; font-weight: 600; text-transform: none; letter-spacing: 0; opacity: 0; transition: opacity 0.3s; }
.feel-rpe-saved--visible { opacity: 1; }
.feel-rpe-body { display: flex; flex-direction: column; gap: 12px; }
/* Feel faces — compact for sidebar */
.feel-section-label { font-size: 0.75em; font-weight: 600; color: #374151; margin-bottom: 6px; }
.feel-faces { display: flex; gap: 2px; }
.feel-face { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: 1; padding: 4px 2px; border-radius: 6px; border: 2px solid transparent; cursor: pointer; transition: background 0.15s; }
.feel-face:hover { background: #f1f5f9; }
.feel-face--active { background: #eff6ff; border-color: #3b82f6; }
.feel-emoji { font-size: 1.25em; line-height: 1; filter: grayscale(0.4); transition: filter 0.15s; }
.feel-face--active .feel-emoji { filter: none; }
.feel-face-label { font-size: 0.55em; color: #6b7280; text-align: center; white-space: nowrap; font-weight: 500; }
.feel-face--active .feel-face-label { color: #1d4ed8; font-weight: 700; }
/* RPE range slider */
.rpe-section-label { font-size: 0.75em; font-weight: 600; color: #374151; }
.rpe-section-header { display: flex; align-items: center; gap: 5px; margin-bottom: 8px; flex-wrap: wrap; }
.rpe-value-display { margin-left: auto; font-size: 0.78em; color: #1e293b; }
.rpe-value-display strong { font-size: 1.1em; margin-right: 3px; }
.rpe-info-icon { position: relative; font-size: 0.95em; color: #94a3b8; cursor: pointer; outline: none; user-select: none; }
.rpe-info-icon:hover .rpe-tooltip, .rpe-info-icon:focus .rpe-tooltip { display: block; }
.rpe-tooltip { display: none; position: absolute; bottom: calc(100% + 8px); right: 0; width: 260px; background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,0.15); z-index: 200; padding: 8px 10px; }
.rpe-tooltip-title { font-weight: 700; font-size: 0.76em; color: #374151; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.rpe-tooltip-row { display: grid; grid-template-columns: 16px 90px 1fr; gap: 4px; padding: 2px 0; font-size: 0.72em; color: #6b7280; }
.rpe-tooltip-row--active { color: #1d4ed8; font-weight: 600; }
.rpe-tooltip-num { font-weight: 700; color: #374151; }
.rpe-tooltip-row--active .rpe-tooltip-num { color: #1d4ed8; }
.rpe-tooltip-name { font-weight: 600; }
.rpe-slider { -webkit-appearance: none; appearance: none; width: 100%; height: 8px; border-radius: 999px; outline: none; cursor: pointer; background: linear-gradient(to right, #22c55e 0%, #84cc16 30%, #eab308 50%, #f97316 75%, #ef4444 100%); }
.rpe-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 3px solid #3b82f6; box-shadow: 0 1px 4px rgba(0,0,0,0.25); cursor: grab; transition: border-color 0.15s, transform 0.1s; }
.rpe-slider::-webkit-slider-thumb:active { cursor: grabbing; transform: scale(1.15); }
.rpe-slider::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 3px solid #3b82f6; box-shadow: 0 1px 4px rgba(0,0,0,0.25); cursor: grab; }
.rpe-slider-labels { display: flex; justify-content: space-between; font-size: 0.62em; color: #9ca3af; padding: 1px 1px 0; margin-top: 2px; }
/* Dark mode */
html.dark-mode .feel-rpe-widget { background: #1e293b; border-color: #334155; }
html.dark-mode .feel-rpe-title { color: #94a3b8; border-bottom-color: #334155; }
html.dark-mode .feel-section-label, html.dark-mode .rpe-section-label { color: #e2e8f0; }
html.dark-mode .feel-face:hover { background: #263548; }
html.dark-mode .feel-face--active { background: #1e3a5f; border-color: #3b82f6; }
html.dark-mode .feel-face-label { color: #94a3b8; }
html.dark-mode .rpe-tooltip { background: #1e293b; border-color: #334155; color: #e2e8f0; }
html.dark-mode .rpe-tooltip-row { color: #94a3b8; }
html.dark-mode .rpe-tooltip-num { color: #e2e8f0; }
html.dark-mode .rpe-value-display { color: #e2e8f0; }
html.dark-mode .rpe-slider::-webkit-slider-thumb { background: #1e293b; border-color: #60a5fa; }
html.dark-mode .rpe-slider::-moz-range-thumb { background: #1e293b; border-color: #60a5fa; }

.activity-metrics-sidebar { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); font-size: 0.88em; }
.activity-metrics-title { font-weight: 700; font-size: 0.8em; color: #64748b; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; gap: 6px; }
.activity-metrics-zoomed-badge { background: #3182ce; color: #fff; font-size: 0.8em; padding: 1px 6px; border-radius: 999px; font-weight: 600; text-transform: none; letter-spacing: 0; }
.activity-metric-row { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 0; border-bottom: 1px dotted #f0f0f0; gap: 8px; }
.activity-metric-row:last-child { border-bottom: none; }
.activity-metric-label { color: #6b7280; white-space: nowrap; flex-shrink: 0; font-size: 0.92em; }
.activity-metric-value { font-weight: 600; color: #111; text-align: right; white-space: nowrap; }
.activity-metrics-divider { height: 1px; background: #e2e8f0; margin: 6px 0; }

@media (max-width: 900px) {
    .activity-layout { grid-template-columns: 1fr; }
    .activity-sidebar { position: static; }
    .mini-map-container { height: 340px; }
}

/* ── Dark mode: activity view ── */
html.dark-mode .metric-selector-bar { border-bottom-color: #334155; }
html.dark-mode .metric-chip { background: #1e293b; border-color: #334155; color: #cbd5e1; }
html.dark-mode .metric-chip.is-active { border-color: transparent; color: #fff; }
html.dark-mode .metric-chip-save { background: #1e293b; border-color: #334155; color: #cbd5e1; }
html.dark-mode .metric-chip-save:hover { background: #0f172a; }
html.dark-mode .btn-reset-zoom { background: #1e293b; border-color: #334155; color: #cbd5e1; }
html.dark-mode .btn-reset-zoom:hover { background: #0f172a; }
html.dark-mode .mini-map-section { background: #1e293b; border-color: #334155; }
html.dark-mode .mini-map-header { color: #e2e8f0; border-bottom-color: #334155; }
html.dark-mode .mini-map-expand-btn { color: #94a3b8; }
html.dark-mode .mini-map-expand-btn:hover { background: #0f172a; color: #e2e8f0; }
html.dark-mode .activity-metrics-sidebar { background: #1e293b; border-color: #334155; }
html.dark-mode .activity-metrics-title { color: #94a3b8; border-bottom-color: #334155; }
html.dark-mode .activity-metric-row { border-bottom-color: #334155; }
html.dark-mode .activity-metric-label { color: #94a3b8; }
html.dark-mode .activity-metric-value { color: #e2e8f0; }
html.dark-mode .activity-metrics-divider { background: #334155; }

/* ── Dark mode toggle (sidebar) ────────────────────────── */
.sidebar__dark-mode {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 8px;
}
.sidebar__dark-mode-label {
    font-size: 0.9em;
    font-weight: 500;
    color: #1f2a37;
}
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
    flex-shrink: 0;
    cursor: pointer;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-switch__track {
    position: absolute;
    inset: 0;
    background: #cbd5e1;
    border-radius: 999px;
    transition: background 0.2s;
}
.toggle-switch__track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-switch__track { background: #2563eb; }
.toggle-switch input:checked + .toggle-switch__track::after { transform: translateX(18px); }

/* ── Night / dark mode overrides ───────────────────────── */
html.dark-mode { color-scheme: dark; }
html.dark-mode body {
    background-color: #0f172a;
    color: #e2e8f0;
}
html.dark-mode .container {
    background-color: #1e293b;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    color: #e2e8f0;
}
html.dark-mode .sidebar {
    background-color: #1e293b;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
html.dark-mode .sidebar__welcome { color: #e2e8f0; }
html.dark-mode .sidebar__link { color: #cbd5e1; }
html.dark-mode .sidebar__link:hover { background-color: #334155; color: #f1f5f9; }
html.dark-mode .sidebar__link--active { background-color: #1e3a5f; color: #93c5fd; border-left-color: #3b82f6; }
html.dark-mode .sidebar__logout { color: #fca5a5; }
html.dark-mode .sidebar__dark-mode-label { color: #cbd5e1; }

/* ── Sidebar collapse toggle ── */
.sidebar__toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    background: transparent;
    cursor: pointer;
    color: #64748b;
    font-size: 18px;
    font-weight: 700;
    align-self: flex-end;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
    transition: background-color 0.15s, color 0.15s;
}
.sidebar__toggle-btn:hover { background-color: #f1f5f9; color: #1e293b; }
html.dark-mode .sidebar__toggle-btn { border-color: #334155; color: #94a3b8; }
html.dark-mode .sidebar__toggle-btn:hover { background-color: #334155; color: #e2e8f0; }

/* Collapsed sidebar state */
html.sidebar-collapsed .has-sidebar .app-shell { grid-template-columns: 48px minmax(0, 1fr); }
html.sidebar-collapsed .sidebar { overflow: hidden; padding: 12px 10px; align-items: center; }
html.sidebar-collapsed .sidebar > *:not(.sidebar__toggle-btn) { display: none; }
html.sidebar-collapsed .sidebar__toggle-btn { align-self: center; }
html.dark-mode .toggle-switch__track { background: #475569; }
html.dark-mode h1, html.dark-mode h2, html.dark-mode h3 { color: #93c5fd; }
html.dark-mode .summary-section { border-color: #334155; }
html.dark-mode .summary-section h2 { color: #60a5fa; border-bottom-color: #60a5fa; }
html.dark-mode .calendar-section {
    background: linear-gradient(135deg, rgba(30,58,138,0.35), rgba(30,41,59,0.95));
    border-color: #334155;
}
html.dark-mode .calendar-subtitle { color: #94a3b8; }
html.dark-mode .calendar-controls button {
    background: #1e293b;
    border-color: #475569;
    color: #cbd5e1;
}
html.dark-mode .calendar-controls button:hover { border-color: #60a5fa; color: #60a5fa; }
html.dark-mode .calendar-month-label {
    background: #1e3a5f;
    color: #93c5fd;
}
html.dark-mode .calendar-weekdays {
    background: #1e293b;
    border-color: #334155;
}
html.dark-mode .calendar-weekdays div { color: #94a3b8; border-right-color: #334155; }
html.dark-mode .calendar-body { background: #1e293b; border-color: #334155; }
html.dark-mode .calendar-cell,
html.dark-mode .calendar-weekly { border-color: #334155; }
html.dark-mode .calendar-cell--outside { background: #0f172a; color: #475569; }
html.dark-mode .calendar-cell--today { background: rgba(37,99,235,0.15); }
html.dark-mode .calendar-cell--period { background: rgba(244,63,94,0.12); }
html.dark-mode .calendar-date { color: #e2e8f0; }
html.dark-mode .calendar-workout { background: #0f172a; color: #e2e8f0; box-shadow: none; }
html.dark-mode .calendar-workout__meta { color: #94a3b8; }
html.dark-mode .modal { background: #1e293b; color: #e2e8f0; }
html.dark-mode .modal-close { background: #334155; border-color: #475569; color: #e2e8f0; }
html.dark-mode .modal-section label { color: #e2e8f0; }
html.dark-mode .modal-section input,
html.dark-mode .modal-section textarea,
html.dark-mode .modal-section select {
    background: #0f172a;
    border-color: #475569;
    color: #e2e8f0;
}
html.dark-mode .modal-action--secondary { background: #334155; border-color: #475569; color: #e2e8f0; }
html.dark-mode .modal-tab { background: #334155; border-color: #475569; color: #e2e8f0; }
html.dark-mode input, html.dark-mode select, html.dark-mode textarea {
    background-color: #1e293b;
    border-color: #475569;
    color: #e2e8f0;
}
html.dark-mode table th { background-color: #1e3a5f; color: #e2e8f0; }
html.dark-mode table td { border-color: #334155; color: #e2e8f0; }
html.dark-mode table tr:nth-child(even) { background-color: #1a2744; }
html.dark-mode table tr:hover { background-color: #253559; }
html.dark-mode .splits-table th { background-color: #1e3a5f; }
html.dark-mode .splits-table tr:nth-child(even) { background-color: #1a2744; }
html.dark-mode .splits-table tr:hover { background-color: #253559; }
html.dark-mode .splits-table td.split-best { background-color: #0c2d4a; color: #7dd3fc; }
html.dark-mode .splits-table td.split-warn { background-color: #3d2e00; color: #fde68a; }
html.dark-mode .tab { background-color: #1e293b; border-color: #334155; }
html.dark-mode .tab button { color: #cbd5e1; }
html.dark-mode .tab button:hover { background-color: #334155; }
html.dark-mode .tab button.active { background-color: #2563eb; color: #fff; }
html.dark-mode .tabcontent { color: #e2e8f0; }
html.dark-mode .athlete-switcher { border-color: #334155; }
html.dark-mode .athlete-pill {
    background-color: #1e293b;
    border-color: #475569;
    color: #cbd5e1;
}
html.dark-mode .athlete-pill:hover { background-color: #253559; border-color: #60a5fa; color: #93c5fd; }
html.dark-mode .athlete-pill.is-active { background-color: #1d4ed8; border-color: #1d4ed8; }
html.dark-mode .metric { border-bottom-color: #334155; }
html.dark-mode .metric-value { color: #e2e8f0; }
html.dark-mode .garmin-avg-box { background: #1e293b; border-color: #334155; }
html.dark-mode .garmin-avg-title { color: #94a3b8; border-bottom-color: #334155; }
html.dark-mode .garmin-avg-row { border-bottom-color: #334155; }
html.dark-mode .garmin-avg-value { color: #e2e8f0; }
html.dark-mode .garmin-charts-container { border-color: #334155; }
html.dark-mode .garmin-chart-row { background: #1e293b; border-bottom-color: #334155; }
html.dark-mode .garmin-chart-label { background: #0f172a; border-right-color: #334155; }
html.dark-mode .garmin-chart-metric-name { color: #e2e8f0; }
html.dark-mode .garmin-chart-metric-unit { color: #94a3b8; }
html.dark-mode .garmin-x-toggle { border-color: #475569; }
html.dark-mode .garmin-x-toggle-btn { background: #1e293b; color: #cbd5e1; }
html.dark-mode .alerts-cell.yellow { background-color: #3d3000; }
html.dark-mode .alerts-cell.red { background-color: #3d0a0a; }
html.dark-mode .alerts-value { color: #e2e8f0; }
html.dark-mode .alerts-avg { color: #94a3b8; }
html.dark-mode .alerts-cell.yellow .alerts-value { color: #fef08a; }
html.dark-mode .alerts-cell.yellow .alerts-avg { color: #ca8a04; }
html.dark-mode .alerts-cell.yellow .alerts-flag { color: #fbbf24; }
html.dark-mode .alerts-cell.red .alerts-value { color: #fca5a5; }
html.dark-mode .alerts-cell.red .alerts-avg { color: #f87171; }
html.dark-mode .alerts-cell.red .alerts-flag { color: #fca5a5; }
html.dark-mode .alerts-cell.missing { color: #475569; }
html.dark-mode .info-icon { background: #1e293b; border-color: #475569; color: #93c5fd; }
html.dark-mode .info-icon:hover { background: #253559; }
html.dark-mode .map-section, html.dark-mode .graph-section { background-color: #1e293b; }
html.dark-mode .login-form { background-color: #1e293b; box-shadow: 0 4px 12px rgba(0,0,0,0.4); }
html.dark-mode .login-form h2 { color: #60a5fa; }
html.dark-mode .login-form input { background: #0f172a; border-color: #475569; color: #e2e8f0; }
html.dark-mode .card, html.dark-mode [class*="-card"] { background-color: #1e293b; border-color: #334155; }
html.dark-mode .upload-form { border-color: #475569; }
html.dark-mode .error { color: #fca5a5; }

/* ── Masquerade Banner ── */
.masq-banner {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 10000;
    background: #f59e0b;
    color: #1c1917;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 10px 20px;
    font-size: 0.88em;
    font-weight: 600;
    box-shadow: 0 -2px 12px rgba(0,0,0,.2);
}
.masq-banner__icon { font-size: 1.1em; flex-shrink: 0; }
.masq-banner__text { flex: 1; text-align: center; }
.masq-banner__btn {
    background: #1c1917;
    color: #fef3c7;
    border: none;
    border-radius: 6px;
    padding: 6px 16px;
    font-size: 0.85em;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}
.masq-banner__btn:hover { background: #292524; }
/* Push page content up so banner doesn't cover it */
body:has(.masq-banner) .container { padding-bottom: 52px; }

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE NAVIGATION — hamburger slide-in drawer
   Overrides the old flex-wrap sidebar rules at @media (max-width: 900px)
   ═══════════════════════════════════════════════════════════════════════════ */

/* Mobile top bar: hidden on desktop */
.mobile-topbar { display: none; }

/* Backdrop: hidden until JS adds --visible class */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 250;
    background: rgba(0,0,0,0.45);
    transition: opacity 0.25s ease;
    opacity: 0;
    pointer-events: none;
}

@media (max-width: 900px) {
    /* ── Mobile top bar ── */
    .mobile-topbar {
        display: flex;
        align-items: center;
        gap: 12px;
        position: fixed;
        top: 0; left: 0; right: 0;
        height: 52px;
        z-index: 200;
        background: #fff;
        border-bottom: 1px solid #e2e8f0;
        padding: 0 16px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    }

    /* ── Hamburger button ── */
    .mobile-topbar__hamburger {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 5px;
        width: 36px;
        height: 36px;
        padding: 6px;
        border: none;
        background: transparent;
        cursor: pointer;
        border-radius: 6px;
        flex-shrink: 0;
        transition: background 0.15s;
    }
    .mobile-topbar__hamburger:hover { background: #f1f5f9; }
    .mobile-topbar__hamburger-bar {
        display: block;
        width: 100%;
        height: 2px;
        background: #1e293b;
        border-radius: 2px;
    }

    /* ── Topbar logo ── */
    .mobile-topbar__logo-link { display: inline-flex; align-items: center; }
    .mobile-topbar__logo { height: 32px; width: auto; display: block; }

    /* ── Backdrop ── */
    .sidebar-backdrop { display: block; }
    .sidebar-backdrop--visible { opacity: 1; pointer-events: all; }

    /* ── Sidebar: off-screen drawer ── */
    .sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: 270px;
        max-width: 85vw;
        z-index: 300;
        border-radius: 0;
        transform: translateX(-100%);
        transition: transform 0.27s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
        overflow-x: hidden;
        padding-top: 68px; /* 52px topbar + 16px breathing room */
    }
    .sidebar--mobile-open { transform: translateX(0); }

    /* ── Hide desktop collapse button on mobile ── */
    .sidebar__toggle-btn { display: none !important; }

    /* ── Override old broken flex-wrap nav rules ── */
    .sidebar__nav { flex-direction: column; flex-wrap: nowrap; }
    .sidebar__link { flex: unset; text-align: left; }
    .sidebar__footer { margin-top: auto; }

    /* ── Override sidebar-collapsed desktop rules on mobile ── */
    html.sidebar-collapsed .has-sidebar .app-shell { grid-template-columns: 1fr; }
    html.sidebar-collapsed .sidebar { overflow-y: auto; padding-top: 68px; align-items: unset; }
    html.sidebar-collapsed .sidebar > *:not(.sidebar__toggle-btn) { display: unset; }

    /* ── Push content below fixed topbar ── */
    .has-sidebar .app-shell { padding-top: 60px; }
}

/* ── Dark mode variants ── */
html.dark-mode .mobile-topbar {
    background: #1e293b;
    border-bottom-color: #334155;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
html.dark-mode .mobile-topbar__hamburger:hover { background: #334155; }
html.dark-mode .mobile-topbar__hamburger-bar { background: #cbd5e1; }
html.dark-mode .sidebar-backdrop { background: rgba(0,0,0,0.6); }
