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: 16px;
    align-self: start;
    background-color: #fff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.sidebar__header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.sidebar__logo-link { display: inline-flex; }
.sidebar__logo {
    width: 100%;
    max-width: 180px;
    height: auto;
    display: block;
}
.sidebar__welcome { font-weight: 700; color: #0f172a; }
.sidebar__nav { display: flex; flex-direction: column; gap: 8px; }
.sidebar__link {
    display: block;
    text-decoration: none;
    color: #1f2a37;
    padding: 10px 12px;
    border-radius: 8px;
    font-weight: 500;
    transition: background-color 0.2s, color 0.2s;
}
.sidebar__link:hover { background-color: #f1f5f9; }
.sidebar__logout { color: #b42318; }
.sidebar__footer { margin-top: auto; }


/* 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: 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--target {
    outline: 2px solid #14b8a6;
    box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.15);
}
.calendar-date {
    font-weight: 700;
    color: #0f172a;
    font-size: 0.95em;
}
.calendar-note {
    align-self: flex-start;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid #fb923c;
    background: #fff7ed;
    color: #c2410c;
    font-weight: 700;
    font-size: 1em;
    line-height: 1;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.calendar-note--filled {
    background: #fff1e6;
    border-style: solid;
    color: #9a3412;
}
.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;
}
.calendar-workout__meta {
    font-size: 0.75em;
    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; }
.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; }
