/* CSS Variables */
:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #38bdf8;
    --accent-hover: #0ea5e9;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --border: #475569;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
}

[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent: #0284c7;
    --accent-hover: #0369a1;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    width: 100%;
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('pool-bg.jpg') center center / cover no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.login-overlay::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(2px);
}

.login-box {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 360px;
    width: 90%;
    position: relative;
    z-index: 1;
}

.login-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 16px;
}

.login-box h2 {
    margin-bottom: 8px;
    color: var(--text-primary);
}

.login-box p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 0.9rem;
}

.login-box form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-box input[type="text"],
.login-box input[type="password"] {
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
    width: 100%;
}

.login-box input[type="text"]:focus,
.login-box input[type="password"]:focus {
    border-color: var(--accent);
}

.login-box .btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.login-box .btn-primary:hover {
    background: var(--accent-hover);
}

.login-box .btn-primary i {
    width: 18px;
    height: 18px;
}

.login-error {
    color: var(--danger);
    font-size: 0.85rem;
    min-height: 1.2em;
    margin-top: 8px;
    margin-bottom: 0 !important;
}

.login-switch {
    margin-top: 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.login-switch a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.login-switch a:hover {
    text-decoration: underline;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.header-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logo {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
}

.header-title h1 {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, #38bdf8, #0284c7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-title .subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 4px;
    display: block;
}

/* Icons */
.icon {
    width: 24px;
    height: 24px;
}

.icon-sm {
    width: 18px;
    height: 18px;
}

/* Buttons */
.btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-icon {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px;
    border-radius: var(--radius-sm);
}

.btn-icon:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* Period Selector */
.period-selector {
    margin-bottom: 20px;
}

.period-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.period-btn {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.period-btn:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--accent);
}

.period-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.custom-date-picker {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.custom-date-picker.active {
    display: flex;
}

.custom-date-picker input[type="date"] {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    cursor: pointer;
}

.custom-date-picker input[type="date"]:focus {
    outline: none;
    border-color: var(--accent);
}

.custom-date-picker span {
    color: var(--text-muted);
}

.period-info {
    display: block;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 12px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}

.stat-icon svg {
    width: 24px;
    height: 24px;
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Comparison Section */
.comparison-section {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 30px;
    overflow: hidden;
}

.comparison-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    cursor: pointer;
    transition: background 0.2s;
}

.comparison-header:hover {
    background: var(--bg-card);
}

.comparison-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.comparison-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
}

.comparison-toggle select {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    cursor: pointer;
}

.comparison-toggle .chevron {
    transition: transform 0.3s;
    color: var(--text-muted);
}

.comparison-section.collapsed .chevron {
    transform: rotate(-90deg);
}

.comparison-body {
    padding: 0 16px 16px;
    display: block;
}

.comparison-section.collapsed .comparison-body {
    display: none;
}

.comparison-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
}

.comparison-chart-container {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 12px;
    height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.comparison-chart-container canvas {
    max-width: 100%;
    max-height: 100%;
}

.comparison-table {
    flex: 1;
}

.comparison-periods {
    display: grid;
    grid-template-columns: 110px 1fr 1fr 70px;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.comparison-periods span {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.comparison-periods span:nth-child(2),
.comparison-periods span:nth-child(3) {
    text-align: center;
}

.comparison-periods span:last-child {
    text-align: right;
}

.comparison-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.comparison-row {
    display: grid;
    grid-template-columns: 110px 1fr 1fr 70px;
    gap: 8px;
    padding: 6px 0;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.comparison-row:last-child {
    border-bottom: none;
}

.comparison-row .label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.comparison-row .value {
    text-align: center;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
}

.comparison-row .delta {
    text-align: right;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

.comparison-row .delta.positive {
    color: #22c55e;
}

.comparison-row .delta.negative {
    color: #ef4444;
}

.comparison-row .delta.neutral {
    color: var(--text-muted);
}

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

/* Personal Records */
.records-section {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    margin-bottom: 20px;
}

.records-section h3 {
    margin: 0 0 16px 0;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.records-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.record-card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
    border: 1px solid var(--border);
    transition: transform 0.2s, border-color 0.2s;
}

.record-card.clickable {
    cursor: pointer;
}

.record-card.clickable:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.2);
}

.record-card.no-data {
    opacity: 0.5;
}

.record-distance {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.record-time {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 4px;
}

.record-card.no-data .record-time {
    color: var(--text-muted);
}

.record-pace {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.record-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 8px;
}

/* Analytics Row */
.analytics-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.analytics-card {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    overflow: hidden;
}

.analytics-card h3 {
    margin: 0 0 16px 0;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Heatmap */
.heatmap-card {
    overflow: hidden;
}

.heatmap-container {
    overflow-x: auto;
    padding-bottom: 8px;
    max-width: 100%;
}

.heatmap-grid {
    display: flex;
    gap: 3px;
}

.heatmap-week {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.heatmap-day {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    background: var(--bg-card);
    cursor: pointer;
    transition: transform 0.1s;
}

.heatmap-day:hover {
    transform: scale(1.3);
}

.heatmap-day.level-0 { background: var(--bg-card); }
.heatmap-day.level-1 { background: rgba(56, 189, 248, 0.3); }
.heatmap-day.level-2 { background: rgba(56, 189, 248, 0.5); }
.heatmap-day.level-3 { background: rgba(56, 189, 248, 0.7); }
.heatmap-day.level-4 { background: rgba(56, 189, 248, 1); }

.heatmap-day.future {
    background: transparent;
    border: 1px dashed var(--border);
}

.heatmap-months {
    display: flex;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    padding-left: 2px;
}

.heatmap-months span {
    flex: 1;
    min-width: 50px;
}

.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    justify-content: flex-end;
}

.heatmap-legend .legend-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.legend-scale {
    display: flex;
    gap: 3px;
}

.legend-box {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.legend-box.level-0 { background: var(--bg-card); }
.legend-box.level-1 { background: rgba(56, 189, 248, 0.3); }
.legend-box.level-2 { background: rgba(56, 189, 248, 0.5); }
.legend-box.level-3 { background: rgba(56, 189, 248, 0.7); }
.legend-box.level-4 { background: rgba(56, 189, 248, 1); }

/* Stroke Chart */
.stroke-card {
    min-width: 0;
}

.stroke-chart-container {
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Profile & Benchmarks */
.profile-section {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    margin-bottom: 20px;
}

.profile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.profile-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.profile-age {
    font-size: 0.9rem;
    color: var(--text-muted);
    background: var(--bg-card);
    padding: 4px 12px;
    border-radius: var(--radius-sm);
}

.profile-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.profile-stats {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.profile-stat {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.profile-stat-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
}

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

.benchmarks-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.benchmark-card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 16px;
}

.benchmark-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hr-zones-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.hr-zone-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.hr-zone-item.zone-1 { background: rgba(34, 197, 94, 0.15); border-left: 3px solid #22c55e; }
.hr-zone-item.zone-2 { background: rgba(132, 204, 22, 0.15); border-left: 3px solid #84cc16; }
.hr-zone-item.zone-3 { background: rgba(234, 179, 8, 0.15); border-left: 3px solid #eab308; }
.hr-zone-item.zone-4 { background: rgba(249, 115, 22, 0.15); border-left: 3px solid #f97316; }
.hr-zone-item.zone-5 { background: rgba(239, 68, 68, 0.15); border-left: 3px solid #ef4444; }

.hr-zone-name {
    color: var(--text-secondary);
}

.hr-zone-range {
    font-weight: 600;
    color: var(--text-primary);
}

.swim-benchmarks {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.benchmark-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.benchmark-label {
    color: var(--text-secondary);
}

.benchmark-values {
    display: flex;
    gap: 12px;
    align-items: center;
}

.benchmark-target {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.benchmark-yours {
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
}

.benchmark-yours.above { background: rgba(34, 197, 94, 0.2); color: #22c55e; }
.benchmark-yours.at { background: rgba(234, 179, 8, 0.2); color: #eab308; }
.benchmark-yours.below { background: rgba(239, 68, 68, 0.2); color: #ef4444; }

.performance-level {
    text-align: center;
    padding: 12px;
}

.performance-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.performance-badge.excellent { background: rgba(34, 197, 94, 0.2); color: #22c55e; }
.performance-badge.good { background: rgba(56, 189, 248, 0.2); color: #38bdf8; }
.performance-badge.average { background: rgba(234, 179, 8, 0.2); color: #eab308; }
.performance-badge.developing { background: rgba(249, 115, 22, 0.2); color: #f97316; }

.performance-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Coaching Section */
.coaching-section {
    margin-top: 20px;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.1), rgba(34, 197, 94, 0.1));
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.coaching-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.coaching-header h4 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.coaching-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-card);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
}

.coaching-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.coaching-tip {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border-left: 3px solid;
}

.coaching-tip.strength { border-color: #22c55e; }
.coaching-tip.improve { border-color: #f97316; }
.coaching-tip.focus { border-color: #38bdf8; }
.coaching-tip.warning { border-color: #ef4444; }

.coaching-tip-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.coaching-tip-content {
    flex: 1;
}

.coaching-tip-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.coaching-tip-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.coaching-summary {
    margin-top: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-left: 3px solid var(--accent);
}

.coaching-summary strong {
    color: var(--text-primary);
}

/* User Menu */
.user-menu {
    position: absolute;
    top: 70px;
    right: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    min-width: 250px;
    z-index: 1000;
    display: none;
}

.user-menu.active {
    display: block;
}

.user-menu-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    color: var(--text-primary);
}

.user-email {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.user-menu-items {
    padding: 8px;
}

.user-menu-items button {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    text-align: left;
    transition: background 0.2s;
}

.user-menu-items button:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.user-menu-items button svg {
    width: 18px;
    height: 18px;
}

.user-menu-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 0;
}

/* User Modals */
.user-modal .modal-content {
    max-width: 420px;
}

.user-select-content {
    max-width: 360px;
}

.user-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    max-height: 300px;
    overflow-y: auto;
}

.user-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.user-list-item:hover {
    border-color: var(--accent);
}

.user-list-item .user-avatar {
    width: 40px;
    height: 40px;
    font-size: 1rem;
}

.user-list-item-info {
    flex: 1;
}

.user-list-item-name {
    font-weight: 600;
    color: var(--text-primary);
}

.user-list-item-details {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.user-list-item-actions {
    display: flex;
    gap: 4px;
}

.user-list-item-actions button {
    padding: 6px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
}

.user-list-item-actions button:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.color-picker {
    display: flex;
    gap: 8px;
}

.color-option {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: transform 0.2s, border-color 0.2s;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.selected {
    border-color: var(--text-primary);
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: var(--accent);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary:hover {
    background: #0ea5e9;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* Settings */
.settings-section {
    margin-bottom: 24px;
}

.settings-section h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.settings-profile {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
}

.settings-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.4rem;
}

.settings-profile-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.settings-name {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.settings-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.settings-option span {
    color: var(--text-secondary);
}

.settings-option select {
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
}

.danger-zone {
    padding: 16px;
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-sm);
}

.danger-zone h3 {
    color: #ef4444;
}

/* CSS & Training Zones */
.css-section {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    margin-bottom: 20px;
}

.css-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.css-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.css-info {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.css-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

.css-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.css-content {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 24px;
    align-items: start;
}

.css-tests {
    display: flex;
    align-items: center;
    gap: 12px;
}

.css-test-card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    text-align: center;
    border: 1px solid var(--border);
    min-width: 80px;
}

.css-test-card .test-distance {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.css-test-card .test-time {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.css-test-card .test-date {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.css-formula {
    color: var(--text-muted);
}

.css-result {
    background: var(--accent);
    color: white;
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    text-align: center;
}

.css-result-label {
    font-size: 0.75rem;
    opacity: 0.8;
}

.css-result-value {
    font-size: 1.2rem;
    font-weight: 700;
}

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

.zone-card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 10px;
    text-align: center;
    border-left: 3px solid;
    transition: transform 0.2s;
}

.zone-card:hover {
    transform: translateY(-2px);
}

.zone-card.zone-1 { border-color: #22c55e; }
.zone-card.zone-2 { border-color: #84cc16; }
.zone-card.zone-3 { border-color: #eab308; }
.zone-card.zone-4 { border-color: #f97316; }
.zone-card.zone-5a { border-color: #ef4444; }
.zone-card.zone-5b { border-color: #dc2626; }
.zone-card.zone-6 { border-color: #9333ea; }

.zone-name {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.zone-pace {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.zone-range {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.zones-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Info Box */
.info-box {
    margin-top: 16px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.info-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.85rem;
    transition: color 0.2s;
}

.info-toggle:hover {
    color: var(--accent);
}

.info-toggle .chevron {
    margin-left: auto;
    transition: transform 0.3s;
}

.info-box.expanded .info-toggle .chevron {
    transform: rotate(180deg);
}

.info-content {
    display: none;
    margin-top: 12px;
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.info-box.expanded .info-content {
    display: block;
}

.info-content p {
    margin: 0 0 12px 0;
}

.info-content p:last-child {
    margin-bottom: 0;
}

.info-content ul {
    margin: 8px 0 12px 0;
    padding-left: 20px;
}

.info-content li {
    margin-bottom: 4px;
}

.info-content .formula {
    background: var(--bg-secondary);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--accent);
    margin: 10px 0;
    border-left: 3px solid var(--accent);
}

.info-content strong {
    color: var(--text-primary);
}

.info-content em {
    color: var(--text-muted);
}

/* Heart Rate Section */
.hr-section {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    margin-bottom: 20px;
    overflow: hidden;
}

.hr-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.hr-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.hr-current {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

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

.hr-avg {
    font-size: 1.4rem;
    font-weight: 700;
    color: #ef4444;
}

.hr-unit {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.hr-content {
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    gap: 20px;
    align-items: start;
}

.hr-stats {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.hr-stat {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
}

.hr-stat-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hr-stat-icon.min {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.hr-stat-icon.avg {
    background: rgba(249, 115, 22, 0.2);
    color: #f97316;
}

.hr-stat-icon.max {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.hr-stat-icon svg {
    width: 18px;
    height: 18px;
}

.hr-stat-info {
    display: flex;
    flex-direction: column;
}

.hr-stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.hr-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.hr-zones-chart,
.hr-trend-chart {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 14px;
}

.hr-zones-chart h4,
.hr-trend-chart h4 {
    margin: 0 0 10px 0;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
}

.hr-zones-chart canvas,
.hr-trend-chart canvas {
    height: 140px !important;
}

/* Training Load Section */
.training-load-section {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    margin-bottom: 20px;
}

.training-load-section h3 {
    margin: 0 0 16px 0;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.load-content {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 24px;
    align-items: start;
}

.load-metrics {
    display: flex;
    gap: 16px;
}

.load-metric {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    text-align: center;
    min-width: 100px;
}

.load-metric .metric-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.load-metric .metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.load-metric .metric-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.load-metric.form-metric .metric-value.positive {
    color: #22c55e;
}

.load-metric.form-metric .metric-value.negative {
    color: #ef4444;
}

.load-chart-container {
    height: 180px;
}

/* Trends Section */
.trends-section {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    margin-bottom: 20px;
}

.trends-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.trends-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.trends-controls select {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    cursor: pointer;
}

.trends-charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.trend-chart-container {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 16px;
}

.trend-chart-container h4 {
    margin: 0 0 12px 0;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.trend-chart-container canvas {
    height: 160px !important;
}

/* Charts */
.charts-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.chart-container {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.chart-container h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-container canvas {
    max-height: 250px;
}

/* Workouts Section */
.workouts-section {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h2 {
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.filters select {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    cursor: pointer;
}

/* Workouts List */
.workouts-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 600px;
    overflow-y: auto;
}

.workout-item {
    display: grid;
    grid-template-columns: auto 1fr repeat(5, auto);
    gap: 20px;
    align-items: center;
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.workout-item:hover {
    background: var(--border);
    transform: translateX(4px);
}

.workout-date {
    display: flex;
    flex-direction: column;
    min-width: 90px;
}

.workout-date .day {
    font-weight: 600;
    font-size: 1rem;
}

.workout-date .weekday {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.workout-title {
    font-weight: 500;
}

.workout-stat {
    text-align: right;
    min-width: 70px;
}

.workout-stat .value {
    font-weight: 600;
    color: var(--text-primary);
}

.workout-stat .label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.workout-arrow {
    color: var(--text-muted);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.3rem;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

/* Modal Stats Grid */
.modal-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.modal-stat {
    background: var(--bg-card);
    padding: 16px;
    border-radius: var(--radius-sm);
    text-align: center;
}

.modal-stat .value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
}

.modal-stat .label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Laps Table */
.laps-section h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.laps-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.laps-table th,
.laps-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.laps-table th {
    background: var(--bg-card);
    font-weight: 600;
    color: var(--text-secondary);
    position: sticky;
    top: 0;
}

.laps-table tr:hover td {
    background: var(--bg-card);
}

.laps-table .fast {
    color: var(--success);
}

.laps-table .slow {
    color: var(--warning);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-card);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 12px;
    }
    
    .header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
    }
    
    .header-actions {
        display: flex;
        gap: 4px;
    }
    
    .period-buttons {
        gap: 6px;
    }
    
    .period-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
    
    .custom-date-picker {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .custom-date-picker input[type="date"] {
        flex: 1;
        min-width: 130px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .charts-section {
        grid-template-columns: 1fr;
    }
    
    .workout-item {
        grid-template-columns: auto 1fr auto;
        gap: 12px;
    }
    
    .workout-stat:nth-child(n+4) {
        display: none;
    }
    
    .modal-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .comparison-content {
        grid-template-columns: 1fr;
    }
    
    .comparison-chart-container {
        height: 220px;
    }
    
    .comparison-periods,
    .comparison-row {
        grid-template-columns: 90px 1fr 1fr 55px;
        gap: 6px;
        font-size: 0.85rem;
    }
    
    .comparison-row .label {
        font-size: 0.8rem;
    }
    
    .comparison-row .value {
        font-size: 0.85rem;
    }
    
    .records-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .analytics-row {
        grid-template-columns: 1fr;
    }
    
    .heatmap-day {
        width: 10px;
        height: 10px;
    }
    
    .css-content {
        grid-template-columns: 1fr;
    }
    
    .css-tests {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .zones-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .load-content {
        grid-template-columns: 1fr;
    }
    
    .load-metrics {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .trends-charts {
        grid-template-columns: 1fr;
    }
    
    .hr-content {
        grid-template-columns: 1fr;
    }
    
    .hr-stats {
        flex-direction: row;
        justify-content: center;
    }
    
    .hr-stat {
        flex: 1;
        min-width: 0;
        padding: 10px;
    }
    
    .benchmarks-grid {
        grid-template-columns: 1fr;
    }
    
    .profile-stats {
        justify-content: center;
    }
    
    .coaching-tip {
        flex-direction: column;
        gap: 8px;
    }
}

/* Loading State */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-muted);
}

.loading::after {
    content: '';
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 12px;
}

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

/* =====================================================
   ENHANCED MOBILE STYLES
   ===================================================== */

/* Small phones (480px and below) */
@media (max-width: 480px) {
    /* Prevent ANY horizontal overflow */
    *, *::before, *::after {
        max-width: 100%;
    }
    
    .container {
        padding: 8px;
        width: 100%;
        overflow-x: hidden;
    }
    
    /* Header */
    .header {
        padding-bottom: 12px;
        margin-bottom: 16px;
    }
    
    .header-title h1 {
        font-size: 1.4rem;
    }
    
    .header-logo {
        width: 36px;
        height: 36px;
    }
    
    .header-title .subtitle {
        display: none;
    }
    
    /* Period buttons - horizontal scroll */
    .period-buttons {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        gap: 6px;
        padding-bottom: 8px;
        margin: 0 -8px;
        padding-left: 8px;
        padding-right: 8px;
    }
    
    .period-buttons::-webkit-scrollbar {
        display: none;
    }
    
    .period-btn {
        flex-shrink: 0;
        padding: 8px 14px;
        font-size: 0.8rem;
        white-space: nowrap;
    }
    
    .period-info {
        font-size: 0.8rem;
        margin-top: 8px;
    }
    
    /* Stats grid - 2 columns */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        margin-bottom: 20px;
    }
    
    .stat-card {
        padding: 14px;
        gap: 10px;
        border-radius: 10px;
    }
    
    .stat-icon {
        width: 40px;
        height: 40px;
        border-radius: 8px;
    }
    
    .stat-icon svg {
        width: 20px;
        height: 20px;
    }
    
    .stat-value {
        font-size: 1.4rem;
    }
    
    .stat-label {
        font-size: 0.75rem;
    }
    
    /* Charts */
    .charts-section {
        gap: 16px;
    }
    
    .chart-card {
        padding: 12px;
        border-radius: 10px;
    }
    
    .chart-header h3 {
        font-size: 0.9rem;
    }
    
    .chart-container {
        height: 180px !important;
    }
    
    /* Comparison section */
    .comparison-card {
        padding: 12px;
    }
    
    .comparison-header h3 {
        font-size: 1rem;
    }
    
    .comparison-periods,
    .comparison-row {
        grid-template-columns: 70px 1fr 1fr 45px;
        gap: 4px;
        font-size: 0.75rem;
    }
    
    .comparison-row .label {
        font-size: 0.7rem;
    }
    
    .comparison-chart-container {
        height: 180px;
    }
    
    /* Workout list */
    .workouts-section h2 {
        font-size: 1.1rem;
    }
    
    .workout-item {
        padding: 12px;
        gap: 10px;
    }
    
    .workout-date .day {
        font-size: 0.9rem;
    }
    
    .workout-stat {
        min-width: 45px;
    }
    
    .workout-stat .value {
        font-size: 0.85rem;
    }
    
    .workout-stat .label {
        font-size: 0.65rem;
    }
    
    /* Hide 3rd and 4th stat on very small screens */
    .workout-stat:nth-child(n+3) {
        display: none;
    }
    
    /* Modal */
    .modal-content {
        margin: 8px;
        padding: 16px;
        max-height: calc(100vh - 16px);
    }
    
    .modal-header h2 {
        font-size: 1.1rem;
    }
    
    .modal-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .modal-stat {
        padding: 10px;
    }
    
    .modal-stat .value {
        font-size: 1.1rem;
    }
    
    /* Lap table */
    .lap-table th,
    .lap-table td {
        padding: 8px 6px;
        font-size: 0.75rem;
    }
    
    /* Records */
    .records-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .record-card {
        padding: 12px;
    }
    
    .record-value {
        font-size: 1.1rem;
    }
    
    /* Heatmap */
    .heatmap-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -8px;
        padding: 0 8px;
    }
    
    .heatmap-day {
        width: 8px;
        height: 8px;
    }
    
    .heatmap-week {
        gap: 2px;
    }
    
    /* CSS Zones */
    .zones-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    
    .zone-card {
        padding: 8px 6px;
    }
    
    .zone-name {
        font-size: 0.7rem;
    }
    
    .zone-range {
        font-size: 0.65rem;
    }
    
    /* Training Load */
    .load-metrics {
        gap: 8px;
    }
    
    .load-metric {
        padding: 10px;
        min-width: 70px;
    }
    
    .load-metric .value {
        font-size: 1.1rem;
    }
    
    .load-metric .label {
        font-size: 0.65rem;
    }
    
    /* HR section */
    .hr-stats {
        gap: 8px;
    }
    
    .hr-stat {
        padding: 8px;
    }
    
    .hr-stat .value {
        font-size: 1rem;
    }
    
    /* Coaching tips */
    .coaching-tip {
        padding: 12px;
    }
    
    .tip-icon {
        width: 32px;
        height: 32px;
    }
    
    .tip-content h4 {
        font-size: 0.85rem;
    }
    
    .tip-content p {
        font-size: 0.8rem;
    }
    
    /* Login */
    .login-box {
        padding: 24px 20px;
        margin: 12px;
    }
    
    .login-logo {
        width: 60px;
        height: 60px;
    }
    
    .login-box h2 {
        font-size: 1.3rem;
    }
    
    /* User menu */
    .user-menu {
        gap: 8px;
    }
    
    .theme-toggle,
    .logout-btn {
        padding: 8px;
    }
}

/* Touch-friendly improvements for all mobile */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .period-btn {
        min-height: 44px;
    }
    
    .btn {
        min-height: 44px;
    }
    
    .workout-item {
        min-height: 60px;
    }
    
    /* Remove hover effects that don't work well on touch */
    .stat-card:hover {
        transform: none;
    }
    
    .workout-item:hover {
        transform: none;
        background: var(--bg-secondary);
    }
    
    .chart-card:hover {
        transform: none;
    }
    
    /* Better tap feedback */
    .period-btn:active,
    .btn:active,
    .workout-item:active {
        opacity: 0.7;
        transform: scale(0.98);
    }
}

/* Landscape mode on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .chart-container {
        height: 150px !important;
    }
    
    .modal-content {
        max-height: calc(100vh - 20px);
    }
}

/* Safe area for notched phones */
@supports (padding: max(0px)) {
    .container {
        padding-left: max(8px, env(safe-area-inset-left));
        padding-right: max(8px, env(safe-area-inset-right));
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
    
    .modal-content {
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
}

/* ============================================
   APP SHELL - ADAPTIVE NAVIGATION
   ============================================ */

/* App Shell Layout */
.app-shell {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-primary);
}

.tab-content-container {
    flex: 1;
    padding: 20px;
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 20px));
    overflow-y: auto;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   SIDEBAR (DESKTOP)
   ============================================ */

.sidebar {
    display: none;
    width: 240px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
}

.sidebar-title {
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #38bdf8, #0284c7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    text-align: left;
}

.sidebar .nav-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.sidebar .nav-item.active {
    background: var(--accent);
    color: white;
}

.sidebar .nav-item.active:hover {
    background: var(--accent-hover);
}

.sidebar .nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* ============================================
   BOTTOM NAVIGATION (MOBILE)
   ============================================ */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    z-index: 1000;
}

.bottom-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: var(--radius-sm);
}

.bottom-nav .nav-item:hover {
    color: var(--text-secondary);
}

.bottom-nav .nav-item.active {
    color: var(--accent);
}

.bottom-nav .nav-item svg {
    width: 24px;
    height: 24px;
}

/* ============================================
   MOBILE HEADER
   ============================================ */

.mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.mobile-header .header-logo {
    width: 36px;
    height: 36px;
    border-radius: 8px;
}

.mobile-header h1 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ============================================
   ACCOUNT SECTION (PROFILE TAB)
   ============================================ */

.account-section {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    margin-top: 20px;
}

.account-section h3 {
    margin: 0 0 16px 0;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.account-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.account-user {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-avatar.large {
    width: 56px;
    height: 56px;
    font-size: 1.4rem;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-details .user-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.user-details .user-email {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-card);
    border-color: var(--accent);
    color: var(--accent);
}

/* ============================================
   DESKTOP BREAKPOINT (≥1024px)
   ============================================ */

@media (min-width: 1024px) {
    /* Show sidebar, hide bottom nav and mobile header */
    .sidebar {
        display: flex;
    }
    
    .bottom-nav {
        display: none;
    }
    
    .mobile-header {
        display: none;
    }
    
    /* Reset padding for desktop */
    .tab-content-container {
        padding: 30px 40px;
        padding-bottom: 40px;
    }
    
    /* Analytics row side by side on desktop */
    .analytics-row {
        grid-template-columns: 2fr 1fr;
    }
}

/* ============================================
   TABLET BREAKPOINT (768px - 1023px)
   ============================================ */

@media (min-width: 768px) and (max-width: 1023px) {
    .tab-content-container {
        padding: 24px;
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 20px));
    }
    
    .analytics-row {
        grid-template-columns: 1fr 1fr;
    }
    
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ============================================
   MOBILE BREAKPOINT (<768px)
   ============================================ */

@media (max-width: 767px) {
    .tab-content-container {
        padding: 16px;
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 20px));
    }
    
    /* Stack analytics cards */
    .analytics-row {
        grid-template-columns: 1fr;
    }
    
    /* 2 columns for stats on mobile */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .stat-card {
        padding: 16px;
    }
    
    .stat-value {
        font-size: 1.3rem;
    }
    
    /* Comparison responsive */
    .comparison-content {
        grid-template-columns: 1fr;
    }
    
    .comparison-chart-container {
        height: 180px;
    }
    
    /* Records grid */
    .records-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Period buttons scroll */
    .period-buttons {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 8px;
        -webkit-overflow-scrolling: touch;
    }
    
    .period-btn {
        flex-shrink: 0;
        padding: 8px 14px;
        font-size: 0.85rem;
    }
    
    /* Charts section */
    .charts-section {
        grid-template-columns: 1fr;
    }
    
    /* Account section mobile */
    .account-info {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .account-info .btn-secondary {
        width: 100%;
        justify-content: center;
    }
    
    /* Trends charts stack */
    .trends-charts {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   HIDE OLD ELEMENTS
   ============================================ */

/* Hide old header and user menu (replaced by new nav) */
.header,
.user-menu,
.header-actions {
    display: none !important;
}

/* Remove old container max-width (now handled by tab-content-container) */
.container {
    max-width: none;
    padding: 0;
    margin: 0;
}

/* ============================================
   ADDITIONAL FIXES
   ============================================ */

/* Ensure charts render properly in tabs */
.tab-content canvas {
    max-width: 100%;
}

/* Fix sections margin in tabs */
.tab-content section:first-child {
    margin-top: 0;
}

.tab-content section:last-child {
    margin-bottom: 0;
}

/* User avatar default style */
.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
}

/* Charts section grid */
.charts-section {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

/* Trends charts grid */
.trends-charts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

/* Safe area padding for iOS */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .bottom-nav {
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
    }
    
    .tab-content-container {
        padding-bottom: calc(80px + env(safe-area-inset-bottom));
    }
}

/* Smooth transitions */
.nav-item {
    transition: all 0.2s ease;
}

/* Active tab indicator for bottom nav */
.bottom-nav .nav-item.active {
    position: relative;
}

.bottom-nav .nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 3px;
    background: var(--accent);
    border-radius: 0 0 3px 3px;
}

/* Sidebar active indicator */
.sidebar .nav-item.active {
    position: relative;
}

.sidebar .nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: white;
    border-radius: 0 3px 3px 0;
}

/* ============================================
   MOBILE CHARTS FIX
   ============================================ */

/* Force single column for charts on mobile */
@media (max-width: 767px) {
    .charts-section {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }
    
    .chart-container {
        min-height: 250px;
    }
    
    .chart-container h3 {
        font-size: 0.95rem;
        margin-bottom: 12px;
    }
    
    /* Workouts section header */
    .section-header {
        flex-wrap: wrap;
        gap: 12px;
    }
    
    .section-header h2 {
        font-size: 1.1rem;
    }
    
    /* Comparison charts single column */
    .comparison-content {
        grid-template-columns: 1fr !important;
    }
    
    /* Trends charts single column */
    .trends-charts {
        grid-template-columns: 1fr !important;
    }
    
    .trend-chart-container {
        min-height: 200px;
    }
}

/* Tablet also needs adjustment */
@media (max-width: 1023px) {
    .charts-section {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   INTERVALS SECTION
   ============================================ */

.intervals-section {
    margin-top: 20px;
}

.intervals-section h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    font-size: 1rem;
    font-weight: 600;
}

.intervals-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.interval-tab {
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.interval-tab:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.interval-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.intervals-chart {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
}

.interval-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.interval-number {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 32px;
}

.interval-number .num {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.interval-number .style {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--accent);
    text-transform: uppercase;
}

.interval-bars {
    flex: 1;
    height: 28px;
    background: var(--bg-card);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.interval-bar {
    height: 100%;
    background: linear-gradient(90deg, rgba(56, 189, 248, 0.6), rgba(56, 189, 248, 0.9));
    border-radius: 4px;
    min-width: 4px;
    transition: width 0.3s ease;
}

.interval-bar.pace {
    background: linear-gradient(90deg, rgba(34, 197, 94, 0.6), rgba(34, 197, 94, 0.9));
}

.interval-bar.swolf {
    background: linear-gradient(90deg, rgba(168, 85, 247, 0.6), rgba(168, 85, 247, 0.9));
}

.interval-bar.hr {
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.6), rgba(239, 68, 68, 0.9));
}

.interval-bar.stroke {
    background: linear-gradient(90deg, rgba(249, 115, 22, 0.6), rgba(249, 115, 22, 0.9));
}

.interval-value {
    min-width: 70px;
    text-align: right;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Laps details (collapsible) */
.laps-details {
    margin-top: 20px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.laps-details summary {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: var(--text-secondary);
}

.laps-details summary:hover {
    color: var(--text-primary);
}

.laps-details[open] summary {
    border-bottom: 1px solid var(--border);
}

.laps-table-wrapper {
    max-height: 300px;
    overflow-y: auto;
}

.laps-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.laps-table th,
.laps-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.laps-table th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-secondary);
    position: sticky;
    top: 0;
}

.laps-table td.fast {
    color: var(--success);
    font-weight: 600;
}

.laps-table td.slow {
    color: var(--danger);
}

@media (max-width: 767px) {
    .intervals-tabs {
        gap: 2px;
    }
    
    .interval-tab {
        padding: 6px 8px;
        font-size: 0.7rem;
    }
    
    .interval-value {
        min-width: 55px;
        font-size: 0.8rem;
    }
}

/* ============================================
   WORKOUT OVERVIEW (swim.com style)
   ============================================ */

.workout-overview {
    padding: 0;
}

.workout-hr-chart {
    background: linear-gradient(180deg, rgba(56, 189, 248, 0.1) 0%, transparent 100%);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 20px;
    height: 100px;
}

.workout-stats-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.stat-row {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.stat-row.single {
    border-bottom: none;
}

.stat-item {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
}

.stat-item:first-child {
    padding-right: 20px;
    border-right: 1px solid var(--border);
}

.stat-item:last-child {
    padding-left: 20px;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.stat-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.workout-device {
    display: flex;
    gap: 20px;
    padding: 16px 0;
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.btn-block {
    width: 100%;
    margin-top: 20px;
    padding: 14px 24px;
    font-size: 1rem;
    justify-content: center;
}

/* Modal header back button */
.modal-header span[onclick] {
    color: var(--accent);
    font-weight: 500;
}

.modal-header span[onclick]:hover {
    text-decoration: underline;
}

/* ============================================
   WORKOUT DETAIL PAGE
   ============================================ */

.workout-detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.btn-back {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-back:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.btn-back svg {
    width: 18px;
    height: 18px;
}

.workout-detail-header h2 {
    flex: 1;
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

#tab-workout-detail .intervals-section {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

#tab-workout-detail .intervals-section h3 {
    margin-bottom: 16px;
}

/* Apple Fitness Style Workout Cards */
.workout-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.workout-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.workout-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.workout-card-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.workout-card-strokes {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.workout-card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.workout-card-stat {
    display: flex;
    flex-direction: column;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.workout-card-stat:nth-child(odd) {
    padding-right: 10px;
    border-right: 1px solid var(--border);
}

.workout-card-stat:nth-child(even) {
    padding-left: 10px;
}

.workout-card-stat .stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 1px;
}

.workout-card-stat .stat-value {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
}

.workout-card-single {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.workout-card-single .stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 1px;
}

.workout-card-single .stat-value {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
}

.workout-card-btn {
    display: block;
    width: 100%;
    padding: 10px;
    margin-top: 10px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.workout-card-btn:hover {
    background: var(--accent-hover);
}

.workout-card-footer {
    display: flex;
    justify-content: flex-start;
    gap: 16px;
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.workout-card-footer span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.workout-card-footer svg {
    width: 14px;
    height: 14px;
}

/* Collapsible Interval Sets */
.interval-details {
    border-bottom: 1px solid var(--border);
}

.interval-details summary {
    cursor: pointer;
    list-style: none;
}

.interval-details summary::-webkit-details-marker {
    display: none;
}

.interval-details .interval-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}

.interval-toggle {
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.interval-toggle svg {
    width: 16px;
    height: 16px;
}

.interval-details[open] .interval-toggle {
    transform: rotate(180deg);
}

.interval-laps {
    padding: 4px 0 8px 28px;
    background: var(--bg-secondary);
    border-radius: 0 0 8px 8px;
    margin-bottom: 4px;
}

.lap-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 8px;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
}

.lap-row:last-child {
    border-bottom: none;
}

.lap-num {
    width: 24px;
    font-weight: 500;
    color: var(--text-secondary);
}

.lap-style {
    width: 24px;
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 500;
}

.lap-stat {
    flex: 1;
    text-align: right;
    color: var(--text-primary);
}


/* ==================== */
/* STREAK COUNTER       */
/* ==================== */

.streak-section {
    margin-bottom: 1.5rem;
}

.streak-card {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid rgba(56, 189, 248, 0.2);
    position: relative;
    overflow: hidden;
}

.streak-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(251, 146, 60, 0.1) 0%, transparent 70%);
    pointer-events: none;
}

.streak-card.streak-safe {
    border-color: rgba(34, 197, 94, 0.3);
}

.streak-card.streak-safe::before {
    background: radial-gradient(circle, rgba(34, 197, 94, 0.1) 0%, transparent 70%);
}

.streak-card.streak-warning {
    border-color: rgba(251, 191, 36, 0.4);
}

.streak-card.streak-warning::before {
    background: radial-gradient(circle, rgba(251, 191, 36, 0.15) 0%, transparent 70%);
}

.streak-card.streak-critical {
    border-color: rgba(239, 68, 68, 0.5);
    animation: pulse-critical 2s infinite;
}

.streak-card.streak-critical::before {
    background: radial-gradient(circle, rgba(239, 68, 68, 0.2) 0%, transparent 70%);
}

.streak-card.streak-broken {
    border-color: rgba(100, 116, 139, 0.3);
    opacity: 0.8;
}

.streak-card.streak-broken::before {
    background: none;
}

@keyframes pulse-critical {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 20px 5px rgba(239, 68, 68, 0.2); }
}

.streak-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.streak-icon {
    font-size: 2rem;
    line-height: 1;
}

.streak-title {
    display: flex;
    flex-direction: column;
}

.streak-label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: #94a3b8;
    text-transform: uppercase;
}

.streak-status {
    font-size: 0.875rem;
    font-weight: 500;
    color: #22c55e;
}

.streak-card.streak-warning .streak-status {
    color: #fbbf24;
}

.streak-card.streak-critical .streak-status {
    color: #ef4444;
}

.streak-card.streak-broken .streak-status {
    color: #64748b;
}

.streak-body {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.streak-days {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.streak-number {
    font-size: 3.5rem;
    font-weight: 700;
    color: #f8fafc;
    line-height: 1;
}

.streak-unit {
    font-size: 1.25rem;
    color: #94a3b8;
    font-weight: 500;
}

.streak-sessions {
    font-size: 0.875rem;
    color: #64748b;
    padding: 0.25rem 0.75rem;
    background: rgba(100, 116, 139, 0.2);
    border-radius: 20px;
}

.streak-progress {
    margin-bottom: 1rem;
}

.streak-bar {
    height: 8px;
    background: rgba(100, 116, 139, 0.3);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.streak-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #22c55e 0%, #4ade80 100%);
    border-radius: 4px;
    transition: width 0.5s ease, background 0.3s ease;
}

.streak-card.streak-warning .streak-bar-fill {
    background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 100%);
}

.streak-card.streak-critical .streak-bar-fill {
    background: linear-gradient(90deg, #dc2626 0%, #ef4444 100%);
}

.streak-time {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #94a3b8;
}

.streak-time .icon-sm {
    width: 14px;
    height: 14px;
}

.streak-consecutive {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #94a3b8;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0;
}

.streak-consecutive .icon-sm {
    color: #38bdf8;
    width: 14px;
    height: 14px;
}

.streak-consecutive strong {
    color: #38bdf8;
    font-size: 1rem;
}

.streak-deadline {
    font-size: 0.8rem;
    color: #64748b;
    margin-bottom: 0.75rem;
}

.streak-deadline strong {
    color: #94a3b8;
}

.streak-record {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: #64748b;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(100, 116, 139, 0.2);
}

.streak-record .icon-sm {
    color: #fbbf24;
    width: 14px;
    height: 14px;
}

.streak-record strong {
    color: #fbbf24;
}

/* Light theme adjustments */
[data-theme='light'] .streak-card {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-color: rgba(56, 189, 248, 0.3);
}

[data-theme='light'] .streak-number {
    color: #1e293b;
}

[data-theme='light'] .streak-label,
[data-theme='light'] .streak-unit {
    color: #64748b;
}

[data-theme='light'] .streak-bar {
    background: rgba(100, 116, 139, 0.2);
}

[data-theme='light'] .streak-consecutive {
    color: #475569;
}

[data-theme='light'] .streak-consecutive strong {
    color: #0284c7;
}


/* ==========================================
   Triboard: Sport-Filter & Multi-Sport
   ========================================== */

:root {
    --sport-swim: #38bdf8;
    --sport-bike: #f97316;
    --sport-run: #22c55e;
    --sport-all: #818cf8;
}

.sport-selector {
    display: flex;
    gap: 8px;
    padding: 12px 24px 0;
    flex-wrap: wrap;
}

.sport-btn {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.sport-btn:hover {
    color: var(--text-primary);
    border-color: var(--accent);
}

.sport-btn.active { color: #fff; }
.sport-btn.active[data-sport="all"]  { background: var(--sport-all);  border-color: var(--sport-all); }
.sport-btn.active[data-sport="swim"] { background: var(--sport-swim); border-color: var(--sport-swim); }
.sport-btn.active[data-sport="bike"] { background: var(--sport-bike); border-color: var(--sport-bike); }
.sport-btn.active[data-sport="run"]  { background: var(--sport-run);  border-color: var(--sport-run); }

@media (max-width: 768px) {
    .sport-selector {
        padding: 10px 16px 0;
        overflow-x: auto;
        flex-wrap: nowrap;
    }
    .sport-btn { flex: 0 0 auto; }
}

/* Schwimm-spezifische Sektionen bei Rad/Lauf-Filter ausblenden */
body[data-sport="bike"] .swim-only,
body[data-sport="run"] .swim-only {
    display: none !important;
}

/* Sport-Badge in Trainingsliste & Detail */
.sport-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
    color: #fff;
}
.sport-badge.swim { background: var(--sport-swim); }
.sport-badge.bike { background: var(--sport-bike); }
.sport-badge.run  { background: var(--sport-run); }

.workout-card.sport-swim { border-left: 3px solid var(--sport-swim); }
.workout-card.sport-bike { border-left: 3px solid var(--sport-bike); }
.workout-card.sport-run  { border-left: 3px solid var(--sport-run); }

/* Split-Liste (Laufen) im Detail */
.splits-table {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
}
.split-row {
    display: grid;
    grid-template-columns: 48px 1fr 90px;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}
.split-bar {
    height: 10px;
    border-radius: 5px;
    background: var(--sport-run);
    opacity: 0.75;
}
.split-row .split-pace {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    font-weight: 600;
}

/* Varianten-Badge (Freiwasser, Indoor, Laufband) */
.variant-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 999px;
    margin-left: 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
