:root {
    --primary: #6164f1;
    --primary-rgb: 97, 100, 241;
    --primary-hover: #4f46e5;

    /* Theme-aware branding colors */
    --branding-h1: #1c1e21;
    --branding-p: #64748b;


    /* Dynamic Activity Colors */
    --run-color: #fc4c02;
    /* Strava Orange */
    --ride-color: #3b82f6;
    /* Blue */
    --strength-color: #10b981;
    /* Emerald */
    --other-color: #8b5cf6;
    /* Violet */

    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-premium: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    --radius: 16px;
    /* Slightly softer */
    --radius-lg: 24px;

    --glass: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.4);
    --nav-bg: rgba(255, 255, 255, 0.85);

    /* Semantic Colors */
    --bg-warning: #fff3e0;
    --text-warning: #e65100;
    --border-warning: #ff9800;
    --bg-info: #e3f2fd;
    --text-info: #1565c0;
    --border-info: #2196f3;
    --bg-success: #e6fffa;
    --text-success: #0694a2;
    --border-success: #319795;

    --table-header-bg: #f8fafc;
    --table-header-text: #64748b;
    --table-border: #e2e8f0;
}

[data-theme="dark"] {
    --bg-main: #020617;
    /* Slate 950 - deeper midnight */
    --bg-card: #0f172a;
    /* Slate 900 */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --branding-h1: #ffffff;
    --branding-p: #cbd5e1;

    --border: #1e293b;
    --border-light: #0f172a;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.5);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.6);
    --glass: rgba(15, 23, 42, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --nav-bg: rgba(2, 6, 23, 0.9);

    /* Semantic Dark Colors */
    --bg-warning: rgba(254, 176, 25, 0.1);
    --text-warning: #feb019;
    --border-warning: #feb019;
    --bg-info: rgba(99, 102, 241, 0.1);
    --text-info: #818cf8;
    --border-info: #818cf8;
    --bg-success: rgba(52, 211, 153, 0.1);
    --text-success: #34d399;
    --border-success: #34d399;

    --table-header-bg: #020617;
    --table-header-text: #94a3b8;
    --table-border: #1e293b;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 24px;
    min-height: 100vh;
    margin: 0;
    transition: background-color 0.3s, color 0.3s;
    padding-bottom: 100px;
    /* Space for bottom nav */
}

#app-container {
    width: 100%;
    max-width: 1000px;
    background: var(--bg-card);
    padding: 32px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    position: relative;
    border: 1px solid var(--border);
}

h1,
h2,
h3 {
    color: var(--text-main);
    border-bottom: 2px solid var(--border-light);
    padding-bottom: 12px;
    margin-top: 0;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

/* --- Simple Tab Visibility --- */
.tab-content {
    display: none;
    opacity: 1;
}

.tab-content:not(.hidden) {
    display: block;
}

/* --- Skeleton Loading System --- */
.skeleton {
    background: linear-gradient(90deg,
            var(--border-light) 25%,
            var(--bg-main) 50%,
            var(--border-light) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 8px;
    border: none !important;
}

/* --- Skeleton Loading System --- */
.key-skeleton {
    background: #e2e8f0;
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 6px;
    display: inline-block;
}

[data-theme="dark"] .key-skeleton {
    background: #1e293b;
    background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.sk-text {
    height: 1em;
    width: 70%;
    margin-bottom: 0.5em;
}

.sk-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.sk-rect {
    width: 100%;
    height: 100%;
    border-radius: 8px;
}

.sk-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.skeleton-card {
    height: 100px;
    width: 100%;
    margin-bottom: 12px;
}

.skeleton-ring {
    width: 120px;
    height: 120px;
    border-radius: 50%;
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
}

/* --- Confetti Celebration --- */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: #f2d74e;
    animation: confetti-fall 3s ease-out infinite;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-100%) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* --- Badge Reveal Modal --- */
#badge-reveal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    /* Slightly darker for better contrast */
    backdrop-filter: blur(10px);
    z-index: 10000;
    /* Ensure it's above everything */
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s;
    overflow: hidden;
    touch-action: none;
}

#badge-reveal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.confetti {
    position: absolute;
    top: -20px;
    border-radius: 2px;
    z-index: 10;
    pointer-events: none;
    animation: confetti-fall 4s linear forwards;
}

#badge-reveal-overlay {
    overflow: hidden;
}

.confetti {
    position: absolute;
    top: -10px;
    border-radius: 2px;
    z-index: 1;
    animation: confetti-fall 4s linear forwards;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

.reveal-card {
    background: var(--bg-card);
    padding: 30px 20px;
    border-radius: 24px;
    text-align: center;
    max-width: 380px;
    width: 85%;
    transform: scale(0.8);
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    position: relative;
    z-index: 100;
}

#badge-reveal-overlay.show .reveal-card {
    transform: scale(1);
}

.reveal-icon {
    font-size: 80px;
    margin-bottom: 20px;
    display: inline-block;
    animation: bounce 2s infinite;
}

.reveal-title {
    font-size: 24px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 10px;
}

.reveal-desc {
    color: var(--text-muted);
    font-size: 16px;
    margin-bottom: 30px;
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-20px);
    }

    60% {
        transform: translateY(-10px);
    }
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"],
input[type="month"],
input[type="date"],
select {
    width: 100%;
    padding: 12px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
    background: var(--bg-main);
    color: var(--text-main);
}

button {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 99px;
    /* Pill shape for all buttons for consistency */
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    transition: all 0.2s ease-in-out;
}

button:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

button:active {
    transform: translateY(0);
}

/* Keyboard accessibility: visible focus without hurting mouse users */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
    outline: 3px solid rgba(var(--primary-rgb), 0.55);
    outline-offset: 3px;
}

/* Reusable button variants (keeps existing <button> defaults working) */
button.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

button.btn-sm {
    padding: 8px 12px;
    font-size: 12px;
}

button.btn-ghost {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border);
    box-shadow: none;
}

button.btn-ghost:hover {
    background: color-mix(in srgb, var(--primary) 8%, transparent);
    border-color: color-mix(in srgb, var(--primary) 25%, var(--border));
    box-shadow: none;
}

button.btn-gradient {
    background: linear-gradient(135deg, #6366f1, #a855f7);
    border: none;
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.25);
}

button.btn-gradient:hover {
    filter: brightness(1.05);
    box-shadow: 0 10px 24px rgba(99, 102, 241, 0.32);
}

.chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.3px;
    border: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg-card) 85%, var(--bg-main));
    color: var(--text-muted);
}

.link-like {
    color: var(--primary);
    cursor: pointer;
    text-decoration: underline;
}

.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-top: 24px;
    box-shadow: var(--shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.card:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.premium-glass {
    background: var(--glass);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border) !important;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .premium-glass {
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    background: rgba(15, 23, 42, 0.6);
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.glass-card {
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
}

/* Alert & Special Cards */
.warning-card {
    background-color: var(--bg-warning) !important;
    border: 2px solid var(--border-warning) !important;
}

.warning-card h2 {
    color: var(--text-warning) !important;
    border-bottom-color: var(--border-warning) !important;
}

.warning-card p {
    color: var(--text-warning) !important;
}

.info-card {
    background-color: var(--bg-info) !important;
    border-left: 5px solid var(--border-info) !important;
}

.info-card h2 {
    color: var(--text-info) !important;
    border-bottom-color: var(--border-info) !important;
}

.info-card div {
    color: var(--text-info) !important;
}

.success-row {
    background-color: var(--bg-success) !important;
    color: var(--text-success) !important;
    font-weight: 700;
}

/* Styled Table System */
.styled-table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 0.9em;
    min-width: 400px;
}

.styled-table thead tr {
    background-color: var(--table-header-bg);
    color: var(--table-header-text);
    text-align: left;
    border-bottom: 2px solid var(--table-border);
}

.styled-table th,
.styled-table td {
    padding: 12px 15px;
    border: 1px solid var(--table-border);
}

.styled-table tbody tr {
    border-bottom: 1px solid var(--table-border);
}

.styled-table tbody tr.active-row {
    font-weight: bold;
    color: var(--primary);
}

.admin-table {
    font-size: 0.85em;
}

.admin-table th {
    background: var(--table-header-bg);
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Themed Cards */
.glass-card {
    background: var(--glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-light);
}

.success-card {
    background: var(--bg-success);
    border: 1px solid var(--border-success);
    border-top: 4px solid var(--text-success);
}

.warning-card {
    background: var(--bg-warning);
    border: 1px solid var(--border-warning);
    border-top: 4px solid var(--text-warning);
}

.info-card {
    background: var(--bg-info);
    border: 1px solid var(--border-info);
    border-top: 4px solid var(--text-info);
}

.accent-card {
    background: var(--bg-main);
    border: 1px solid var(--border-light);
    border-left: 4px solid var(--primary);
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow);
    transition: transform 0.2s, background-color 0.3s, border-color 0.3s;
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
}

.stat-card h3 {
    margin: 0 0 4px 0;
    font-size: 0.75em;
    color: var(--text-muted);
    border: none;
    padding: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .stat-value {
    font-size: 1.6em;
    font-weight: 800;
    color: var(--text-main);
    z-index: 2;
}

/* Sparkline Styles */
.sparkline-container {
    height: 30px;
    width: 100%;
    margin-top: 8px;
    opacity: 0.8;
}

.sparkline-path {
    fill: none;
    stroke: var(--primary);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    animation: sparkline-draw 2s ease-out forwards;
}

@keyframes sparkline-draw {
    from {
        stroke-dasharray: 200;
        stroke-dashoffset: 200;
    }

    to {
        stroke-dashoffset: 0;
    }
}

/* Motivation Snippet */
.motivation-snippet {
    background: rgba(var(--primary-rgb), 0.1);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 20px;
    border-left: 4px solid var(--primary);
    font-size: 0.9em;
    font-style: italic;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: fadeIn 1s ease-out;
}

.motivation-snippet .icon {
    font-size: 1.4em;
    flex-shrink: 0;
}

/* Face Pile Styles */
.face-pile {
    display: flex;
    flex-wrap: wrap;
    gap: -8px;
    margin-top: 5px;
}

.face-pile-item {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--bg-card);
    object-fit: cover;
    margin-left: -8px;
    transition: transform 0.2s, z-index 0.2s;
    background: var(--bg-main);
    cursor: help;
}

.face-pile .face-pile-item:first-child {
    margin-left: 0;
}

.face-pile-item:hover {
    transform: scale(1.2) translateY(-2px);
    z-index: 10;
}

.rsvp-location-group {
    background: var(--bg-main);
    padding: 10px 14px;
    border-radius: 14px;
    border: 1px solid var(--border-light);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Quick Actions Grid */
.quick-action-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 16px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: var(--shadow-sm);
}

.quick-action-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow);
    background: var(--bg-main);
    border-color: var(--primary);
}

.qa-icon {
    font-size: 1.8em;
}

.qa-label {
    font-size: 0.8em;
    font-weight: 700;
    color: var(--text-main);
}

/* Pulse Indicator */
.pulse-indicator {
    width: 10px;
    height: 10px;
    background: #10b981;
    border-radius: 50%;
    position: relative;
    box-shadow: 0 0 0 rgba(16, 185, 129, 0.4);
    animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

/* TPL Social Enhancements */
.flair-badge.active {
    opacity: 1 !important;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.mood-opt.active {
    border: 2px solid var(--primary) !important;
    transform: scale(1.2);
}

.honor-roll-item {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 20px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-sm);
    animation: fadeInStep 0.5s ease-out;
}

@keyframes fadeInStep {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Glassmorphism Profile */
.glass-modal {
    background: rgba(var(--bg-card-rgb), 0.7) !important;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

/* Kudos Burst Animation */
.kudos-burst {
    position: absolute;
    pointer-events: none;
    animation: kudos-burst-anim 0.8s ease-out forwards;
}

@keyframes kudos-burst-anim {
    0% {
        transform: scale(0.5);
        opacity: 1;
    }

    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

/* Post Mood Backgrounds */
.post-mood-sunset {
    background: linear-gradient(135deg, rgba(255, 81, 47, 0.1) 0%, rgba(221, 36, 118, 0.1) 100%) !important;
}

.post-mood-ocean {
    background: linear-gradient(135deg, rgba(33, 147, 176, 0.1) 0%, rgba(109, 213, 237, 0.1) 100%) !important;
}

.post-mood-forest {
    background: linear-gradient(135deg, rgba(17, 153, 142, 0.1) 0%, rgba(56, 239, 125, 0.1) 100%) !important;
}

.post-mood-night {
    background: linear-gradient(135deg, rgba(15, 12, 41, 0.1) 0%, rgba(48, 43, 99, 0.1) 100%) !important;
}

.post-mood-citrus {
    background: linear-gradient(135deg, rgba(252, 227, 138, 0.1) 0%, rgba(243, 129, 129, 0.1) 100%) !important;
}





.m-only {
    display: none !important;
}

@media (max-width: 768px) {
    .m-only {
        display: block !important;
    }

    .m-hidden {
        display: none !important;
    }
}

/* Navigation System */
.desktop-nav {
    display: flex;
    justify-content: flex-start;
    gap: 8px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .desktop-nav {
        visibility: hidden;
        height: 0;
        margin: 0;
        padding: 0;
        overflow: visible;
    }

    body {
        padding: 12px;
        padding-bottom: 90px;
    }

    #app-container {
        padding: 20px;
        border-radius: 0;
        border: none;
        box-shadow: none;
        background: transparent;
    }

    .card {
        padding: 16px;
        margin-top: 16px;
        width: 100%;
    }
}

.nav-btn {
    background: var(--bg-main);
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.nav-section-title {
    display: none;
}

/* Header layout helpers (avoids inline styles in index.html) */
.main-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.main-header-left,
.main-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.icon-btn {
    background: transparent !important;
    border: 1px solid transparent !important;
    border-radius: 12px !important;
    padding: 8px !important;
    line-height: 1 !important;
    box-shadow: none !important;
}

.icon-btn:hover {
    background: color-mix(in srgb, var(--primary) 10%, transparent) !important;
    border-color: color-mix(in srgb, var(--primary) 20%, transparent) !important;
    transform: none !important;
}

.header-warning-badge {
    background: #ef4444;
    color: white;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.app-branding {
    text-align: center;
    margin-bottom: 20px;
}

.app-branding .header-logo {
    width: 100px;
    height: auto;
    border-radius: 20px;
}

.app-branding h1 {
    font-size: 1.4em;
    margin-top: 10px;
}

.app-branding p {
    font-size: 0.9em;
    color: var(--branding-p);
    font-weight: 800;
    letter-spacing: 1px;
}

/* Mobile Bottom Nav */
/* Mobile Bottom Nav - Premium Glassmorphism */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 75px;
    /* Slightly taller for better touch targets */
    background: rgba(255, 255, 255, 0.75);
    /* More transparent */
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.08);
    justify-content: space-around;
    align-items: center;
    padding: 0 10px 10px 10px;
    /* Check for iPhone Home bar area */
    z-index: 1000;
}

[data-theme="dark"] .mobile-bottom-nav {
    background: rgba(15, 23, 42, 0.75);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .header-logo {
    background: #ffffff !important;
    padding: 10px !important;
    border-radius: 50% !important;
    box-shadow: 0 0 25px rgba(255, 255, 255, 0.4) !important;
    border: 3px solid #6366f1 !important;
    display: inline-block !important;
}

.dark-mode .app-branding h1 {
    color: #ffffff !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.dark-mode .app-branding p {
    color: #cbd5e1 !important;
}

.reactions-container {
    margin-top: 10px;
    min-height: 24px;
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex;
        justify-content: space-around;
        align-items: center;
        padding: 0 10px env(safe-area-inset-bottom, 10px) 10px;
        height: 75px;
        background: rgba(15, 23, 42, 0.9);
        backdrop-filter: blur(20px) saturate(180%);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
    }

    #m-hamburger {
        display: flex !important;
        margin-right: 10px;
        color: var(--text-main) !important;
        text-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
        transition: transform 0.3s ease;
    }

    /* Soft rotation on click */
    #m-hamburger:active {
        transform: rotate(90deg) scale(1.1);
    }
}

.m-nav-btn {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    background: none !important;
    border: none !important;
    color: var(--text-muted) !important;
    padding: 10px !important;
    flex: 1 !important;
    transition: all 0.3s ease !important;
    box-shadow: none !important;
    transform: none !important;
}

.m-nav-btn.active {
    color: var(--primary) !important;
}

.m-nav-btn.active .m-nav-icon {
    transform: scale(1.1);
    background: rgba(99, 102, 241, 0.15);
}

.m-nav-icon {
    font-size: 20px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin-bottom: 4px;
    transition: all 0.2s;
}

.m-nav-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Hub Overlay Styles */
/* Athlete Hub Performance Theme */
.hub-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #020617 url('runner_hub_bg.png') center/cover no-repeat;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    transition: all 0.5s cubic-bezier(0.19, 1, 0.22, 1);
    opacity: 1;
    visibility: visible;
}

/* Glass overlay on top of bg image */
.hub-overlay::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(2, 6, 23, 0.7), rgba(2, 6, 23, 0.95));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: -1;
}

.hub-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    transform: scale(1.1);
    pointer-events: none;
}

.hub-header {
    padding: 60px 30px 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.hub-header h3 {
    margin: 0;
    font-size: 2.2em;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: -1px;
    background: linear-gradient(135deg, #fff 0%, #fc4c02 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-style: italic;
}

.hub-close {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    font-size: 2em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.hub-close:active {
    transform: rotate(90deg) scale(0.8);
    background: rgba(252, 76, 2, 0.4);
}

.hub-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.hub-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 30px;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}

/* Athlete Medal Container */
.hub-icon {
    font-size: 2.2em;
    margin-bottom: 12px;
    width: 65px;
    height: 65px;
    background: rgba(2, 6, 23, 0.5);
    border: 2px solid rgba(252, 76, 2, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px rgba(252, 76, 2, 0.1);
    transition: all 0.4s ease;
}

.hub-item:active {
    transform: translateY(-5px);
    background: rgba(252, 76, 2, 0.15);
    border-color: rgba(252, 76, 2, 0.5);
}

.hub-item:active .hub-icon {
    border-color: #fc4c02;
    box-shadow: 0 0 30px rgba(252, 76, 2, 0.4);
    transform: scale(1.1);
}

.hub-label {
    font-size: 10px;
    font-weight: 900;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

#m-hub-logout-btn {
    background: linear-gradient(to right, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.2)) !important;
    border: 1px solid rgba(239, 68, 68, 0.2) !important;
    font-style: italic;
    letter-spacing: 2px;
}

/* Table Systems */


table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    border-bottom: 1px solid var(--border-light);
    padding: 12px 16px;
    text-align: center;
    font-size: 14px;
}

th {
    background-color: var(--bg-main);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

td:first-child,
th:first-child {
    text-align: left;
    font-weight: 600;
    background-color: var(--bg-card);
    position: sticky;
    left: 0;
    z-index: 2;
}

[data-theme="dark"] td:first-child,
[data-theme="dark"] th:first-child {
    background-color: var(--bg-card);
}

/* Dropdown */
.nav-more-dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: var(--bg-card);
    min-width: 180px;
    box-shadow: var(--shadow-lg);
    border-radius: 16px;
    /* Soft round corners */
    z-index: 50;
    right: 0;
    border: 1px solid var(--border);
    padding: 8px;
    margin-top: 10px;
    animation: fadeIn 0.2s ease-out;
}

/* Mobile Dropdown Styling */
@media (max-width: 768px) {
    .dropdown-content {
        position: fixed !important;
        bottom: 80px !important;
        left: 10px !important;
        right: 10px !important;
        top: auto !important;
        width: calc(100% - 20px) !important;
        min-width: unset !important;
        background: var(--nav-bg) !important;
        backdrop-filter: blur(15px) !important;
        -webkit-backdrop-filter: blur(15px) !important;
        border-radius: var(--radius) !important;
        box-shadow: var(--shadow-lg) !important;
        z-index: 2000 !important;
    }
}


.nav-more-dropdown:hover .dropdown-content,
.dropdown-content.show {
    display: block !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

.dropdown-content button {
    width: 100%;
    text-align: left;
    background: none;
    color: var(--text-main);
    padding: 10px 16px;
    border-radius: 99px;
    /* Pill shape consistency */
    margin-bottom: 4px;
}

.dropdown-content button:hover {
    background-color: var(--bg-main);
    color: var(--primary);
}

/* Heatmap Grid */
.heatmap-grid {
    display: grid;
    grid-template-rows: repeat(7, 12px);
    grid-auto-flow: column;
    grid-auto-columns: 12px;
    gap: 3px;
}

.heatmap-cell {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    background-color: #cbd5e1;
    transition: transform 0.2s;
}

.heatmap-cell:hover {
    transform: scale(1.4);
    z-index: 10;
}

.heatmap-cell.level-0 {
    background-color: var(--border-light);
}

.heatmap-cell.level-1 {
    background-color: #dcfce7;
}

.heatmap-cell.level-2 {
    background-color: #86efac;
}

.heatmap-cell.level-3 {
    background-color: #22c55e;
}

.heatmap-cell.level-4 {
    background-color: #166534;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    animation: fadeIn 0.4s ease-out;
}

/* Progress Ring Styles */
.progress-ring-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    margin-bottom: 24px;
    margin-top: 10px;
}

.progress-ring-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 160px;
    box-shadow: var(--shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.progress-ring-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.progress-ring-svg-container {
    position: relative;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-ring-svg {
    transform: rotate(-90deg);
}

.progress-ring-circle {
    transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1);
    stroke: var(--primary);
    stroke-linecap: round;
}

.progress-ring-bg {
    stroke: var(--border-light);
}

.progress-ring-content {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.progress-ring-text {
    font-size: 1.25em;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1;
}

.progress-ring-unit {
    font-size: 0.6em;
    color: var(--text-muted);
    font-weight: 500;
}

.progress-ring-label {
    font-size: 0.8em;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: 16px;
}

.progress-ring-subtext {
    font-size: 0.75em;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Activity Feed Card Styles */
.activity-feed {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

@media (max-width: 600px) {
    .activity-feed {
        grid-template-columns: 1fr;
    }
}

.activity-card {
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    gap: 16px;
    box-shadow: var(--shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.activity-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
    border-color: rgba(var(--primary-rgb), 0.4);
    background: rgba(var(--primary-rgb), 0.03);
}

.activity-card::after {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 70%;
    border-radius: 0 4px 4px 0;
    transition: height 0.3s ease;
}

.activity-card.is-run::after { background: var(--run-color); }
.activity-card.is-ride::after { background: var(--ride-color); }
.activity-card.is-strength::after { background: var(--strength-color); }
.activity-card.is-other::after { background: var(--other-color); }

.activity-card:hover::after {
    height: 100%;
}

.pb-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
    color: white;
    font-size: 0.65em;
    font-weight: 900;
    padding: 4px 12px;
    border-radius: 0 0 0 12px;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}


.activity-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
}

.activity-icon-container {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--bg-main);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.activity-details {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.activity-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 4px;
}

.activity-username {
    font-weight: 700;
    font-size: 1em;
    color: var(--text-main);
}

.activity-date {
    font-size: 0.75em;
    color: var(--text-muted);
}

.activity-title {
    font-size: 0.85em;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.activity-stats {
    display: flex;
    gap: 16px;
    align-items: center;
}

.activity-stat-item {
    display: flex;
    flex-direction: column;
}

.activity-stat-value {
    font-weight: 700;
    font-size: 1.1em;
    color: var(--text-main);
}

.activity-stat-label {
    font-size: 0.65em;
    color: var(--text-muted);
    text-transform: uppercase;
}

.pb-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: #fbbf24;
    color: #92400e;
    font-size: 10px;
    font-weight: 800;
    padding: 4px 12px;
    transform: rotate(45deg) translate(30%, -30%);
    width: 100px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

/* Achievement Badge Styles */
.badges-container {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
    overflow: hidden;
    /* Prevent pulses from breaking layout */
    max-width: 100%;
}

.badges-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.badges-title {
    font-size: 1.2em;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

.badges-count {
    font-size: 0.85em;
    color: var(--text-muted);
    font-weight: 600;
}

.badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
}

@media (max-width: 600px) {
    .badges-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }
}

.badge-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    background: var(--bg-main);
    border: 2px solid var(--border-light);
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
}

.badge-item:hover {
    transform: translateY(-4px) scale(1.05);
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
}

.badge-item.locked {
    opacity: 0.4;
    cursor: default;
}

.badge-item.locked:hover {
    transform: none;
    border-color: var(--border-light);
    box-shadow: none;
}

.badge-item.new {
    animation: badge-pulse 1.5s ease-in-out infinite;
}

@keyframes badge-pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.7);
        border-color: var(--primary);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(99, 102, 241, 0);
        border-color: var(--primary);
    }
}

.badge-icon {
    font-size: 2.5em;
    margin-bottom: 8px;
    filter: grayscale(0);
    transition: filter 0.3s;
}

.badge-item.locked .badge-icon {
    filter: grayscale(1);
}

.badge-name {
    font-size: 0.7em;
    font-weight: 600;
    color: var(--text-main);
    text-align: center;
    line-height: 1.2;
}

.badge-description {
    font-size: 0.65em;
    color: var(--text-muted);
    text-align: center;
    margin-top: 4px;
}

.badge-date {
    font-size: 0.6em;
    color: var(--text-muted);
    margin-top: 4px;
}

.new-badge-indicator {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    font-size: 0.6em;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Leaderboard Pulse Widget */
.leaderboard-pulse {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}

.leader-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 12px;
    flex: 1;
    min-width: 140px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.leader-card.top-1 {
    border-left: 4px solid #ffd700;
}

.leader-card.top-2 {
    border-left: 4px solid #c0c0c0;
}

.leader-card.top-3 {
    border-left: 4px solid #cd7f32;
}

.leader-rank {
    font-size: 0.8em;
    font-weight: 800;
    color: var(--text-muted);
    width: 20px;
}

.leader-pic {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.leader-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.leader-name {
    font-size: 0.85em;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80px;
}

.leader-dist {
    font-size: 0.75em;
    color: var(--primary);
    font-weight: 600;
}

/* PR Hall of Fame */
.pr-hall-fame {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-top: 15px;
}

.pr-record-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}

.pr-record-card:hover {
    transform: translateY(-3px);
    border-color: var(--primary);
}

.pr-record-label {
    font-size: 0.7em;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 5px;
}

.pr-record-value {
    font-size: 1.25em;
    font-weight: 800;
    color: var(--primary);
}

.pr-record-date {
    font-size: 0.65em;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Delta Trends */
.stat-delta {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 6px;
}

.stat-delta.up {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.stat-delta.down {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.stat-delta.neutral {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-muted);
}

/* 🎭 Captain Face Reveal Styles */
#face-reveal-overlay {
    background: radial-gradient(circle at center, #1a1b2e 0%, #000000 100%) !important;
}

.btn-reveal-link {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(168, 85, 247, 0.2);
    color: var(--text-main);
    padding: 10px;
    border-radius: 8px;
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.btn-reveal-link:hover {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.2) 0%, rgba(99, 102, 241, 0.2) 100%);
    border-color: rgba(168, 85, 247, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(168, 85, 247, 0.2);
}

.reveal-container {
    animation: reveal-glow 4s ease-in-out infinite alternate;
}

@keyframes reveal-glow {
    from {
        box-shadow: 0 0 40px rgba(168, 85, 247, 0.4);
    }

    to {
        box-shadow: 0 0 80px rgba(99, 102, 241, 0.7);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.1);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 0.8;
    }
}

#reveal-team-name {
    font-family: 'Outfit', sans-serif;
    background: linear-gradient(180deg, #fff 0%, rgba(255, 255, 255, 0.5) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Event Hero Suggestion 4 */
.event-hero {
    position: relative;
    border-radius: 20px;
    height: 180px;
    margin-bottom: 24px;
    overflow: hidden;
    background: linear-gradient(135deg, #1e1b4b 0%, #4338ca 100%);
    box-shadow: 0 10px 25px rgba(30, 27, 75, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('https://images.unsplash.com/photo-1476480862126-209bfaa8edc8?auto=format&fit=crop&q=80&w=800') center/cover;
    opacity: 0.3;
    mix-blend-mode: overlay;
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
}

.hero-title {
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-weight: 700;
    margin-bottom: 8px;
    opacity: 0.9;
}

.hero-days {
    font-size: 3.5em;
    font-weight: 900;
    line-height: 1;
    margin-bottom: 4px;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.hero-label {
    font-size: 0.8em;
    font-weight: 600;
    opacity: 0.8;
}

/* PB Timeline Suggestion 5 */
.pb-timeline {
    position: relative;
    padding: 10px 0;
}

.pb-timeline-item {
    position: relative;
    padding-left: 30px;
    padding-bottom: 25px;
}

.pb-timeline-item::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-light);
}

.pb-timeline-item:last-child::before {
    display: none;
}

.pb-timeline-marker {
    position: absolute;
    left: 0;
    top: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid var(--bg-card);
    z-index: 2;
}

.pb-timeline-content {
    background: rgba(var(--primary-rgb), 0.03);
    border-radius: 12px;
    padding: 12px 16px;
    border: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pb-timeline-info h4 {
    margin: 0;
    font-size: 0.85em;
    color: var(--text-muted);
}

.pb-timeline-info div {
    font-size: 1.1em;
    font-weight: 800;
    color: var(--text-main);
}

.pb-timeline-date {
    text-align: right;
}

.pb-timeline-date .date {
    font-size: 0.75em;
    color: var(--text-muted);
    font-weight: 600;
}

.pb-timeline-date .race {
    font-size: 0.65em;
    color: var(--primary);
    font-weight: 700;
}

/* Fix for Community Summary Overflow */
html,
body {
    overflow-x: hidden;
    width: 100%;
}



/* Ensure cards don't expand beyond viewport */
.card {
    max-width: 100%;
    box-sizing: border-box;
}

.responsive-table-card {
    padding: 16px !important;
    /* Slightly tighter padding for tables */
    overflow: visible;
    /* Allow table-wrapper to display properly */
}

/* Make sticky header more reliable */
th:first-child,
td:first-child {
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
    /* Visual separation for sticky col */
}

/* Final Fix for Community Summary Overflow & Layout */
:root {
    --primary-rgb: 99, 102, 241;
}

#app-container {
    overflow-x: hidden;
    /* Stronger containment */
}

.tab-content {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.card {
    max-width: 100% !important;
    /* overflow-x removed to allow table-wrapper to work */
}





@media (max-width: 600px) {
    #app-container {
        padding: 16px;
        /* Reduced padding for more room on mobile */
    }

    .card {
        padding: 16px;
    }
}

/* Auction Page Styles */
.auction-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 15px;
}

.auction-item {
    transition: transform 0.2s, box-shadow 0.2s;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 15px;
    text-align: center;
}

.auction-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.auction-item img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 10px;
    border: 3px solid var(--primary);
}

/* Hero Dashboard */
.hero-gradient {
    background: linear-gradient(135deg, #4f46e5 0%, #7647eb 100%) !important;
    padding: 30px !important;
    color: white !important;
    box-shadow: 0 20px 25px -5px rgba(79, 70, 229, 0.3) !important;
}

.hero-bg-shapes .shape {
    position: absolute;
    filter: blur(40px);
    z-index: 1;
    opacity: 0.4;
}

.shape-1 {
    width: 200px;
    height: 200px;
    background: #c084fc;
    top: -100px;
    right: -50px;
    border-radius: 50%;
}

.shape-2 {
    width: 150px;
    height: 150px;
    background: #60a5fa;
    bottom: -50px;
    left: -20px;
    border-radius: 40%;
}

/* Activity Feed Improvements */
.activity-card {
    border-left: 4px solid var(--border);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.activity-card.is-run {
    border-left-color: var(--run-color);
}

.activity-card.is-ride {
    border-left-color: var(--ride-color);
}

.activity-card.is-strength {
    border-left-color: var(--strength-color);
}

.activity-card:active {
    transform: scale(0.98);
}

/* AI Coach Bubble */
.coach-bubble {
    position: fixed;
    bottom: 95px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.4);
    z-index: 999;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.coach-bubble:hover {
    transform: scale(1.1) translateY(-5px);
}

.coach-bubble-ping {
    position: absolute;
    width: 100%;
    height: 100%;
    background: var(--primary);
    border-radius: 50%;
    opacity: 0.6;
    animation: ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes ping {

    75%,
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

.coach-bubble-icon {
    font-size: 28px;
    z-index: 2;
}

.coach-notif {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    border: 2px solid white;
    z-index: 3;
}

/* Chat Body */
.ai-chat-body::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-body::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

/* Suggestion Improvements */
@keyframes slideDown {
    from {
        transform: translate(-50%, -100%);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 20px);
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
    }
}

#lightbox-modal img {
    animation: zoomIn 0.3s ease-out;
}

@keyframes zoomIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* TPL Team Leaderboard Widget */
.team-leaderboard-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    margin-bottom: 25px;
    border: 1px solid var(--border-light);
}

.dark-mode .team-leaderboard-card {
    background: var(--bg-card);
    border-color: var(--border);
}

.team-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.team-rank {
    width: 24px;
    font-weight: 800;
    color: var(--text-muted);
}

.team-badge {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    font-size: 0.9em;
}

.team-name {
    flex: 1;
    font-weight: 600;
    color: var(--text-main);
}

.team-dist {
    font-weight: 700;
    color: var(--primary);
}

.team-progress-bg {
    height: 6px;
    background: var(--border-light);
    border-radius: 3px;
    margin-top: 4px;
    overflow: hidden;
}

.team-progress-inner {
    height: 100%;
    border-radius: 3px;
    transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.team-leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.team-leaderboard-header h3 {
    margin: 0;
    font-size: 1.1em;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* =============================================
   ENHANCED UX/UI - v13.67
   ============================================= */

/* Loading Skeletons */
.skeleton {
    background: linear-gradient(90deg, var(--border-light) 25%, var(--border) 50%, var(--border-light) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 12px;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Recent Runs Grid */
.recent-runs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.run-mini-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.run-mini-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

/* Social Snippet Cards */
.social-snippet-item {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 12px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.social-snippet-item:hover {
    box-shadow: var(--shadow);
    transform: scale(1.01);
}

/* Weather Forecast */
.weather-forecast-day {
    text-align: center;
    padding: 8px;
    background: var(--bg-main);
    border-radius: 10px;
}

/* Micro Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.4s ease;
}

/* Voice Recording */
.voice-recording-active {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

/* Infinite Scroll Loader */
.infinite-scroll-loader {
    text-align: center;
    padding: 20px;
}

.infinite-scroll-loader::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Search Highlight */
.search-highlight {
    background: rgba(var(--primary-rgb), 0.2);
    font-weight: 600;
    padding: 1px 2px;
    border-radius: 3px;
}

/* Pull to Refresh */
.pull-to-refresh {
    display: none;
    text-align: center;
    padding: 15px;
    color: var(--text-muted);
}

.pull-to-refresh.active {
    display: block;
}

/* Responsive */
@media (max-width: 768px) {
    .recent-runs-grid {
        grid-template-columns: 1fr;
    }
}

/* =============================================
   ACTIVITY FEED STYLES
   ============================================= */

.activity-feed {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.activity-card {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.activity-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--primary);
}

.activity-card.is-run {
    border-left: 3px solid var(--run-color);
}

.activity-card.is-ride {
    border-left: 3px solid var(--ride-color);
}

.activity-card.is-strength {
    border-left: 3px solid var(--strength-color);
}

.activity-card.is-other {
    border-left: 3px solid var(--other-color);
}

.activity-icon-container {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
    background: var(--border-light);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    overflow: hidden;
}

.activity-details {
    flex: 1;
    min-width: 0;
}

.activity-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.activity-username {
    font-weight: 700;
    font-size: 0.9em;
    color: var(--text-main);
}

.activity-date {
    font-size: 0.75em;
    color: var(--text-muted);
}

.activity-title {
    font-size: 0.85em;
    color: var(--text-main);
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.activity-stats {
    display: flex;
    gap: 15px;
}

.activity-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.activity-stat-value {
    font-weight: 700;
    font-size: 0.9em;
    color: var(--primary);
}

.activity-stat-label {
    font-size: 0.7em;
    color: var(--text-muted);
    text-transform: uppercase;
}

.pb-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    font-size: 0.6em;
    font-weight: 900;
    padding: 4px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(245, 87, 108, 0.3);
    animation: pulse-badge 2s ease-in-out infinite;
}

@keyframes pulse-badge {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

.kudos-btn:hover {
    background: rgba(0, 0, 0, 0.1) !important;
    transform: scale(1.05);
}

.skeleton-card {
    height: 80px;
    border-radius: 12px;
    background: linear-gradient(90deg, var(--border-light) 25%, var(--border) 50%, var(--border-light) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

/* Dark Mode */
[data-theme=\"dark\"] .activity-card {
    background: var(--bg-card);
    border-color: var(--border);
}

[data-theme=\"dark\"] .activity-card:hover {
    background: rgba(99, 102, 241, 0.05);
}

[data-theme=\"dark\"] .activity-icon-container {
    background: rgba(255, 255, 255, 0.05);
}

/* Responsive */
@media (max-width: 768px) {
    .activity-card {
        padding: 10px;
    }

    .activity-icon-container {
        width: 40px;
        height: 40px;
        font-size: 1.2em;
    }

    .activity-stats {
        gap: 10px;
    }
}

/* --- PREMIUM HOME PAGE ENHANCEMENTS v17.2 --- */

/* 🌌 Aether Background */
#aether-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -2;
    overflow: hidden;
    pointer-events: none;
}

.aether-blob {
    position: absolute;
    width: 60vw;
    height: 60vw;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.15;
    animation: blob-float 25s infinite alternate ease-in-out;
}

[data-theme="dark"] .aether-blob {
    opacity: 0.1;
}

.blob-1 {
    background: #6164f1;
    top: -10%;
    left: -10%;
}

.blob-2 {
    background: #e91e63;
    bottom: -10%;
    right: -10%;
    animation-delay: -5s;
}

.blob-3 {
    background: #00bcd4;
    top: 10%;
    right: 10%;
    animation-delay: -10s;
}

@keyframes blob-float {
    0% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(2vw, 5vh) scale(1.1);
    }

    66% {
        transform: translate(-3vw, 3vh) scale(0.9);
    }

    100% {
        transform: translate(1vw, -2vh) scale(1.05);
    }
}

/* 🍱 Bento Grid System */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin: 20px 0;
}

@media (max-width: 600px) {
    .bento-grid {
        grid-template-columns: 1fr;
    }
}

.bento-item {
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 24px;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: default;
    position: relative;
    overflow: hidden;
    animation: slideUpFade 0.6s ease-out both;
}

.bento-item:hover {
    transform: translateY(-8px) scale(1.02);
    border-color: rgba(var(--primary-rgb), 0.5);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .bento-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.bento-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

.bento-item:hover::before {
    transform: translateX(100%);
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bento-item.tall {
    grid-row: span 2;
}

.bento-item.wide {
    grid-column: span 2;
}

/* Status Indicator Styles */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 30px;
    font-size: 0.75em;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 10px;
}

.status-optimal {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-caution {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.status-overreaching {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.status-detraining {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

/* PR Card Styles */
.pr-badge {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: white;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.7em;
    font-weight: 900;
    margin-right: 8px;
}

/* Habits Checklist */
.habit-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.habit-row:last-child {
    border-bottom: none;
}

.habit-check {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.habit-check.done {
    background: var(--primary);
    border-color: var(--primary);
}

.habit-check.done::after {
    content: '✓';
    color: white;
    font-size: 12px;
}

.bento-item.wide {
    grid-column: span 2;
}

/* 🌤️ weather Premium Widget */
.weather-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    font-size: 0.75em;
    font-weight: 700;
    color: white;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* 🎙️ Breathing Voice UI */
.voice-indicator {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(var(--primary-rgb), 0.3);
    transition: all 0.2s;
}

.voice-indicator:hover {
    transform: scale(1.1);
}

.voice-indicator.speaking {
    animation: voice-pulse 1s infinite alternate;
}

@keyframes voice-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 5px rgba(var(--primary-rgb), 0.4);
    }

    100% {
        transform: scale(1.2);
        box-shadow: 0 0 20px rgba(var(--primary-rgb), 0.7);
    }
}

/* 🛡️ ADMIN DASHBOARD PREMIUM ENHANCEMENTS */

.permission-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(var(--primary-rgb), 0.05);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.permission-pill:hover {
    background: rgba(var(--primary-rgb), 0.1);
    border-color: var(--primary);
}

.permission-pill input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--primary);
}

.permission-pill span {
    font-size: 0.9em;
    font-weight: 600;
}

.merit-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 99px;
    cursor: pointer;
    transition: all 0.2s;
}

.merit-chip:hover {
    background: rgba(236, 72, 153, 0.05);
    border-color: #ec4899;
}

.merit-chip input[type="checkbox"] {
    margin: 0;
    accent-color: #ec4899;
}

.merit-chip span {
    font-size: 0.8em;
    font-weight: 700;
}

.loader-small {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

#admin-strava-status-list::-webkit-scrollbar {
    width: 4px;
}

#admin-strava-status-list::-webkit-scrollbar-track {
    background: transparent;
}

#admin-strava-status-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

/* Custom styles for Admin Dashboard inputs */
#tab-admin select,
#tab-admin input[type="date"],
#tab-admin textarea {
    border: 1px solid var(--border);
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}

#tab-admin select:focus,
#tab-admin input[type="date"]:focus,
#tab-admin textarea:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.admin-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    font-size: 0.8em;
}

/* Admin Sub-Tabs */
.admin-sub-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    padding: 10px;
    background: var(--bg-card);
    border-radius: 14px;
    overflow-x: auto;
    scrollbar-width: none;
    position: sticky;
    top: 80px; /* Below main-header approx height */
    z-index: 100;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

[data-theme="dark"] .admin-sub-nav {
    background: rgba(255, 255, 255, 0.05);
}

.admin-sub-btn {
    padding: 10px 20px;
    border-radius: 10px;
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9em;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    border: none;
}

.admin-sub-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    color: var(--text-main);
}

[data-theme="dark"] .admin-sub-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.admin-sub-btn.active {
    background: var(--bg-card);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.admin-section {
    display: none;
    animation: fadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.admin-section.active {
    display: block;
}

.admin-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.admin-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    transition: transform 0.2s;
}

.admin-stat-card:hover {
    transform: translateY(-3px);
    border-color: var(--primary);
}

.admin-stat-label {
    font-size: 0.75em;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.admin-stat-value {
    font-size: 1.8em;
    font-weight: 800;
    color: var(--text-main);
}

.admin-stat-icon {
    font-size: 1.5em;
    margin-bottom: 10px;
}

@keyframes hotspot-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 5px var(--primary);
    }

    100% {
        transform: scale(1.15);
        box-shadow: 0 0 20px var(--primary);
    }
}

.hotspot-active {
    animation: hotspot-pulse 1.5s infinite alternate ease-in-out;
}

/* --- PREMIUM UI v18.0 ENHANCEMENTS --- */

/* 3. Bento Focus & Depth Effects */
#tab-home:has(.bento-item:hover) .bento-item:not(:hover) {
    filter: blur(2px) grayscale(0.2);
    opacity: 0.6;
    transform: scale(0.98);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.bento-item {
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.bento-item:hover {
    z-index: 10;
    transform: scale(1.03) translateY(-5px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

/* 4. Digital Aura Varients */
#community-aura {
    transition: background 1s ease;
}

.aura-vibrant {
    --aura-color: #f97316;
    --aura-speed: 4s;
}

.aura-calm {
    --aura-color: #10b981;
    --aura-speed: 10s;
}

.aura-power {
    --aura-color: #ef4444;
    --aura-speed: 3s;
}

.aura-mystic {
    --aura-color: #6366f1;
    --aura-speed: 12s;
}

/* 5. Mesh Popover Styles */
.mesh-dot {
    cursor: pointer;
    position: relative;
    z-index: 1;
}

.mesh-dot::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 50%;
    background: transparent;
    transition: background 0.2s;
}

.mesh-dot:hover::after {
    background: rgba(255, 255, 255, 0.1);
}

#mesh-day-popover {
    position: fixed;
    z-index: 10001;
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 20px;
    box-shadow: var(--shadow-premium);
    pointer-events: none;
    opacity: 0;
    transform: translateY(10px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    width: 200px;
}

#mesh-day-popover.show {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.mesh-popover-date {
    font-size: 0.7em;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.mesh-popover-stat {
    font-size: 1.25em;
    font-weight: 800;
    color: var(--text-main);
}

.mesh-popover-type {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.7em;
    font-weight: 700;
    margin-top: 5px;
    text-transform: uppercase;
}

/* --- Desktop Sidebar Redesign --- */
@media (min-width: 769px) {
    body {
        padding: 0;
        justify-content: flex-start;
        align-items: stretch;
        overflow-x: hidden;
    }

    #app-container {
        max-width: none;
        width: 100% !important;
        padding: 0 !important;
        border-radius: 0;
        border: none;
        box-shadow: none;
        background: var(--bg-main) !important;
        display: flex;
        flex-direction: row;
        overflow-x: hidden;
        min-height: 100vh;
    }

    /* Sidebar Structure - Collapsible */
    .desktop-nav {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 76px;
        /* Collapsed width */
        background: rgba(30, 41, 59, 0.7);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-right: 1px solid rgba(255, 255, 255, 0.05);
        display: flex !important;
        flex-direction: column;
        padding: 40px 10px;
        /* Reduced padding when collapsed */
        gap: 6px;
        z-index: 1000;
        overflow-y: auto;
        overflow-x: hidden;
        margin: 0;
        flex-wrap: nowrap;
        scrollbar-width: none;
        transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s ease;
    }

    .desktop-nav:hover {
        width: 280px;
        /* Expanded width */
        padding: 40px 20px;
        /* Restore padding */
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.3);
        /* Stronger shadow on hover */
    }

    .desktop-nav::-webkit-scrollbar {
        display: none;
    }

    /* Hide text/branding when collapsed, show on hover */
    .sidebar-logo-box h2,
    .sidebar-logo-box p,
    .nav-section-title,
    .desktop-nav .nav-btn text,
    .desktop-nav .nav-btn span:not(.nav-icon):not(.m-nav-label) {
        opacity: 0;
        transition: opacity 0.2s ease;
        white-space: nowrap;
    }

    /* Reveal items when hovered */
    .desktop-nav:hover .sidebar-logo-box h2,
    .desktop-nav:hover .sidebar-logo-box p,
    .desktop-nav:hover .nav-section-title {
        opacity: 0.8;
        transition-delay: 0.1s;
        /* Slight delay to let it expand */
    }

    .nav-section-title {
        display: block;
        font-size: 0.7em;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: 1.5px;
        color: var(--text-muted);
        margin-top: 20px;
        margin-bottom: 4px;
        padding-left: 12px;
        min-height: 15px;
        /* Keep space allocated */
    }

    .desktop-nav .nav-btn {
        width: 100%;
        min-width: 240px;
        justify-content: flex-start;
        text-align: left;
        padding: 12px 16px;
        border-radius: 12px;
        font-size: 0;
        font-weight: 600;
        margin: 0;
        border: 1px solid transparent;
        background: transparent;
        color: transparent !important;
        transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        display: flex;
        align-items: center;
        gap: 0px;
        position: relative;
        overflow: hidden;
    }

    .desktop-nav:hover .nav-btn {
        color: var(--text-main) !important;
        font-size: 0.95em;
        gap: 14px;
    }

    /* Fixed width for icons ensures perfect alignment */
    .desktop-nav .nav-icon {
        width: 24px;
        text-align: center;
        font-size: 18px;
        /* Fixed px so it's immune to parent font-size: 0 */
        display: inline-block;
        transition: transform 0.3s;
        color: var(--text-main);
        flex-shrink: 0;
    }

    .desktop-nav .nav-btn.active .nav-icon {
        color: white;
    }

    /* Glassmorphism Hover */
    .desktop-nav .nav-btn:hover {
        background: rgba(255, 255, 255, 0.05);
        border-color: rgba(255, 255, 255, 0.1);
        color: white !important;
        /* Brighter text on hover */
        transform: translateY(-2px);
    }

    .desktop-nav .nav-btn:hover .nav-icon {
        transform: scale(1.15);
    }

    /* Active State Glow */
    .desktop-nav .nav-btn.active {
        background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(168, 85, 247, 0.2));
        border: 1px solid rgba(168, 85, 247, 0.4);
        box-shadow: 0 4px 15px rgba(99, 102, 241, 0.15);
    }

    .desktop-nav:hover .nav-btn.active {
        color: white !important;
    }

    .desktop-nav .nav-btn.active .nav-icon {
        filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.5));
    }

    /* Pinned sidebar behaves like hover-expanded */
    .desktop-nav.is-pinned .sidebar-logo-box h2,
    .desktop-nav.is-pinned .sidebar-logo-box p,
    .desktop-nav.is-pinned .nav-section-title,
    .desktop-nav.is-pinned .nav-btn span:not(.nav-icon):not(.m-nav-label) {
        opacity: 0.85;
    }

    .desktop-nav.is-pinned .nav-btn {
        color: var(--text-main) !important;
        font-size: 0.95em;
        gap: 14px;
    }

    .desktop-nav.is-pinned ~ #main-app:not(.hidden) {
        margin-left: 300px;
        width: calc(100% - 320px);
    }

    /* Special styling for TPL colored buttons */
    .desktop-nav .nav-btn.tpl-btn,
    .desktop-nav .nav-btn.admin-btn {
        background: transparent;
        border: 1px solid transparent;
    }

    .desktop-nav .nav-btn.tpl-btn:hover,
    .desktop-nav .nav-btn.admin-btn:hover {
        background: color-mix(in srgb, var(--btn-color) 15%, transparent);
        border-color: color-mix(in srgb, var(--btn-color) 40%, transparent);
        color: white;
    }

    .desktop-nav .nav-btn.tpl-btn.active,
    .desktop-nav .nav-btn.admin-btn.active {
        background: color-mix(in srgb, var(--btn-color) 25%, transparent);
        border-color: var(--btn-color);
        box-shadow: 0 4px 15px color-mix(in srgb, var(--btn-color) 20%, transparent);
    }

    /* Logout button styling */
    .desktop-nav .logout-btn {
        background: rgba(220, 53, 69, 0.05) !important;
        border: 1px solid rgba(220, 53, 69, 0.1) !important;
    }

    .desktop-nav:hover .logout-btn {
        color: #ef4444 !important;
    }

    .desktop-nav .logout-btn:hover {
        background: rgba(220, 53, 69, 0.15) !important;
        border-color: rgba(220, 53, 69, 0.3) !important;
        color: #f87171 !important;
    }

    /* Main Content Area - Windowed Design */
    #main-app:not(.hidden) {
        flex: 1;
        margin: 20px 20px 20px 96px;
        /* 76px sidebar + 20px gap */
        display: flex !important;
        flex-direction: column !important;
        height: calc(100vh - 40px);
        background: var(--bg-card);
        border-radius: 24px;
        box-shadow: var(--shadow-premium);
        position: relative;
        width: calc(100% - 116px);
        /* 76px sidebar + 20px gap + 20px right margin */
        min-width: 0;
        overflow-y: auto;
        overflow-x: hidden;
        border: 1px solid var(--border-light);
        transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        align-items: stretch !important;
    }

    /* Pushes main-app when sidebar is expanded on hover */
    .desktop-nav:hover ~ #main-app:not(.hidden) {
        margin-left: 300px;
        width: calc(100% - 320px);
    }

    #main-header {
        position: sticky;
        top: 0;
        z-index: 900;
        background: var(--bg-card);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        padding: 20px 40px;
        border-bottom: 1px solid var(--border-light);
        margin: 0 !important;
        width: 100% !important;
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        flex-shrink: 0;
        /* Don't shrink the header */
    }

    .tab-content {
        padding: 30px 40px;
        max-width: 100%;
        width: 100%;
        margin: 0;
        position: relative;
        overflow-y: auto;
        /* Internal scrolling */
        flex: 1;
        /* Take up remaining height */
        scrollbar-width: thin;
        scrollbar-color: var(--border) transparent;
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
    }

    /* Adjust cards inside tabs to not have double shadows necessarily, 
       but keep them for depth */
    .tab-content .card {
        margin-top: 0;
        margin-bottom: 24px;
    }

    /* Hide redundant branding on desktop */
    .app-branding {
        display: none !important;
    }

    /* Dropdown adjustment for vertical sidebar */
    .nav-more-dropdown {
        width: 100%;
        position: static;
    }

    .nav-more-dropdown .dropdown-content {
        position: static;
        display: flex;
        flex-direction: column;
        background: transparent;
        box-shadow: none;
        border: none;
        padding: 0;
        gap: 4px;
        margin-top: 5px;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: none;
    }

    .nav-more-dropdown .dropdown-content .nav-btn {
        padding-left: 30px;
        /* Indent sub-items */
        font-size: 0.85em;
        opacity: 0.8;
    }
}

/* Sidebar Logo Placeholder styling */
.sidebar-logo-box {
    padding: 0 10px 30px 10px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    overflow: hidden;
    transition: all 0.3s ease;
}

.sidebar-logo-box img {
    width: 40px;
    height: auto;
    border-radius: 10px;
    margin-bottom: 10px;
    transition: width 0.3s ease;
}

.desktop-nav:hover .sidebar-logo-box img {
    width: 60px;
}

.sidebar-logo-box h2 {
    font-size: 1.1em;
    margin: 0;
    border: none;
    padding: 0;
    color: var(--text-main);
}

.nav-pin-btn {
    margin-top: 6px;
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 999px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: none;
}

.nav-pin-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-main);
    transform: none;
    box-shadow: none;
}
