:root {
    --carbon: #2f3437;
    --carbon-soft: #41484c;
    --mint: #63c7a5;
    --mint-light: #bdebdc;
    --ochre: #d6a43b;
    --background: #f5f7f6;
    --white: #ffffff;
	--mint-dark: #3fae89;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #f7f9fa;
    color: var(--text-main);
    margin: 0;
    padding: 0;
}

/* Vista Login */
/* Vista Login */
.login-body {
    min-height: 100vh;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background:
        radial-gradient(circle at top left, rgba(99, 199, 165, 0.25), transparent 35%),
        linear-gradient(135deg, var(--carbon) 0%, #1f2427 100%);
}

.login-card {
    background: rgba(255, 255, 255, 0.96);
    padding: 2.8rem;
    border-radius: 22px;
    box-shadow: 0 18px 45px rgba(0,0,0,0.35);
    width: 100%;
    max-width: 390px;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.35);
}

.login-card h2 {
    color: var(--carbon);
    letter-spacing: 2px;
    margin-bottom: 8px;
    font-weight: 900;
}

.login-card .subtitle {
    color: var(--carbon-soft);
    font-size: 0.95rem;
    margin-bottom: 2rem;
}

.login-card label {
    color: var(--carbon);
}

.login-card input {
    background: #ffffff;
    border: 1px solid #d9dfdc;
}

.login-card input:focus {
    border-color: var(--mint);
    box-shadow: 0 0 0 3px rgba(99,199,165,0.18);
}

.login-card .btn-primary {
    background: var(--mint);
    color: var(--carbon);
    font-weight: 900;
    border-radius: 12px;
    margin-top: 18px;
}

.login-card .btn-primary:hover {
    background: var(--mint-dark);
    color: white;
}

.login-card .btn-flat {
    color: var(--carbon-soft);
}

.login-card .btn-flat:hover {
    color: var(--mint-dark);
}

.login-card h2 { letter-spacing: 2px; margin-bottom: 5px; font-weight: 800; }
.subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 2rem; }

/* Componentes de Formulario */
.form-group { text-align: left; margin-bottom: 1.2rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 5px; }
input, select {
    width: 100%; padding: 10px; border: 1px solid var(--border-color);
    border-radius: 4px; box-sizing: border-box; font-size: 0.95rem; background: #fafafa;
}
input:focus, select:focus { border-color: var(--accent); outline: none; }

.btn-primary {
    width: 100%; padding: 12px; background: var(--accent); color: white;
    border: none; border-radius: 4px; font-weight: 600; cursor: pointer; margin-top: 10px;
}
.btn-primary:hover { background: #333; }
.btn-flat { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.85rem; }
.btn-flat:hover { color: #000; text-decoration: underline; }
.login-actions { display: flex; justify-content: space-between; margin-top: 1.5rem; }

/* Dashboard Navbar */
.navbar {
    display: flex; justify-content: space-between; align-items: center;
    background: #111; color: white; padding: 10px 40px;
}
.navbar h1 { font-size: 1.2rem; letter-spacing: 1px; }
.btn-logout { color: #ccc; text-decoration: none; font-size: 0.9rem; border: 1px solid #444; padding: 5px 12px; border-radius: 4px; }
.btn-logout:hover { background: white; color: black; }

/* Layout Grid Dashboard */
.dashboard-container {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 24px;
    padding: 24px;
    width: 100%;
    max-width: none;
    margin: 0;
    box-sizing: border-box;
}

.sidebar,
.main-content {
    min-width: 0;
}
.card { background: white; padding: 20px; border-radius: 6px; border: 1px solid var(--border-color); margin-bottom: 20px; }
.card h3 { margin-top: 0; font-size: 1.1rem; border-bottom: 1px solid #eee; padding-bottom: 10px; }

/* Sidebar Inputs Especiales */
#carreraForm input, #carreraForm select { margin-bottom: 10px; }
.gpx-label {
    display: block; text-align: center; border: 2px dashed #ccc; padding: 20px; cursor: pointer; border-radius: 4px; background: #fafafa;
}
.gpx-label input { display: none; }
.sync-buttons { display: flex; gap: 10px; margin-top: 15px; }
.sync-buttons button { flex: 1; padding: 8px; border: none; border-radius: 4px; color: white; font-weight: bold; cursor: pointer; }
.btn-strava { background: #FC4C02; }
.btn-garmin { background: #007CC3; }

/* Contenedores de Carreras */
.distancia-block h4 { margin: 0 0 15px 0; font-size: 1.2rem; text-transform: uppercase; border-left: 3px solid #111; padding-left: 10px; }
.carreras-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 15px; }
.carrera-item { border: 1px solid #eee; padding: 15px; border-radius: 4px; background: #fdfdfd; position: relative; }
.carrera-header { display: flex; justify-content: space-between; align-items: center; }
.trofeo { color: var(--gold); font-weight: bold; font-size: 0.85rem; }
.record-item { border-color: #ebd275; background: #fffdf5; }
.ciudad-tag { font-size: 0.85rem; color: var(--text-muted); margin: 5px 0 10px 0; }
.carrera-stats { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; }
.fecha-tag { display: block; margin-top: 10px; color: #999; font-size: 0.75rem; text-align: right; }
/* Cuadrícula para las gráficas por distancia */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.chart-box {
    height: 120px;
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 4px;
    padding: 5px;
}

/* Botón de borrar integrado en la tarjeta de carrera */
.btn-borrar {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    opacity: 0.4;
    transition: opacity 0.2s, transform 0.2s;
    padding: 2px 5px;
    z-index: 10; /* Se asegura de quedar por encima */
}

.btn-borrar:hover {
    opacity: 1;
    transform: scale(1.2);
}
/* Forzar 4 columnas y scroll en gráficas e historial */
#contenedor-graficas-dinamicas, 
#distancias-wrapper .grid-historial {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important; /* 4 columnas exactas */
    gap: 15px !important;
    overflow-x: auto !important;
    padding-bottom: 20px;
}

/* Asegurar que las tarjetas dentro no se estiren de más */
#contenedor-graficas-dinamicas > div, 
#distancias-wrapper .card-historial {
    min-width: 200px; /* Tamaño mínimo de cada columna */
    background: #fff;
    border: 1px solid #ddd;
    padding: 10px;
}
#contenedor-graficas-dinamicas {
    display: grid;
    grid-template-columns: repeat(3, minmax(280px, 320px));
    gap: 20px;
    justify-content: center;
    align-items: start;
    width: 100%;
}
.main-content > div:first-child {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 20px;
    align-items: stretch;
    width: 100%;
}

#mapa-localizacion-global {
    width: 100%;
}

#contenedor-graficas-dinamicas {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(280px, 320px));
    gap: 20px;
    justify-content: center;
    width: 100%;
}
@media (max-width: 1200px) {
    .dashboard-container {
        grid-template-columns: 280px minmax(0, 1fr);
        padding: 16px;
        gap: 16px;
    }

    .main-content > div:first-child {
        grid-template-columns: 1fr;
    }

    .main-content > div:first-child > .card:last-child {
        width: 100% !important;
    }
}

@media (max-width: 800px) {
    .dashboard-container {
        grid-template-columns: 1fr;
    }

    .sidebar {
        order: 2;
    }

    .main-content {
        order: 1;
    }

    #contenedor-graficas-dinamicas {
        grid-template-columns: 1fr;
    }
}
.avatar-opcion {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #ddd;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
}

.avatar-opcion:hover {
    transform: scale(1.08);
    border-color: #007bff;
}
.perfil-dashboard-card {
    text-align: center;
    padding: 22px 15px;
    margin-bottom: 18px;
    border-left: 5px solid #007bff;
}

.perfil-dashboard-avatar {
    width: 190px;
    height: 190px;
    border-radius: 22px;
    object-fit: cover;
    border: 4px solid #fff;
    box-shadow: 0 6px 18px rgba(0,0,0,0.25);
    background: #fff;
}

.perfil-dashboard-nombre {
    margin: 12px 0 5px;
    font-size: 1.15rem;
    font-weight: 800;
    color: #222;
}

.perfil-dashboard-link {
    font-size: 0.8rem;
    color: #007bff;
    text-decoration: none;
    font-weight: 700;
}

.perfil-dashboard-link:hover {
    text-decoration: underline;
}
.perfil-dashboard-avatar {
    cursor: pointer;
}

.modal-avatar {
    display: none;
    position: fixed;
    z-index: 9999;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    justify-content: center;
    align-items: center;
    padding: 30px;
}

.imagen-modal-avatar {
    max-width: 85vw;
    max-height: 85vh;
    border-radius: 28px;
    object-fit: contain;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.45);
    background: #fff;
}

.cerrar-modal-avatar {
    position: absolute;
    top: 25px;
    right: 35px;
    color: white;
    font-size: 42px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10000;
}

.cerrar-modal-avatar:hover {
    color: #ff4d4d;
}
.resumen-categorias-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-top: 15px;
}

.categoria-resumen-card {
    background: #ffffff;
    border-radius: 18px;
    padding: 22px;
    border-left: 6px solid #007bff;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.categoria-resumen-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.16);
}

.categoria-resumen-titulo {
    font-size: 1.4rem;
    font-weight: 900;
    color: #007bff;
    margin-bottom: 12px;
}

.categoria-resumen-dato {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    padding: 5px 0;
    border-bottom: 1px solid #f0f0f0;
}

.categoria-resumen-dato:last-child {
    border-bottom: none;
}
.tabla-ediciones {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.tabla-ediciones th {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid #222;
    color: #111;
    font-size: 1rem;
}

.tabla-ediciones td {
    padding: 9px 12px;
    border-bottom: 1px solid #ddd;
    vertical-align: middle;
}

.tabla-ediciones-numero {
    text-align: center;
    font-weight: 800;
    font-size: 1.1rem;
    width: 100px;
}

.tabla-ediciones-carrera {
    font-weight: 700;
    color: #111;
    min-width: 220px;
}

.tabla-ediciones-anios {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

.tabla-ediciones-anios span {
    font-weight: 500;
    white-space: nowrap;
}
.link-carrera-ediciones {
    color: #007bff;
    font-weight: 800;
    text-decoration: none;
}

.link-carrera-ediciones:hover {
    text-decoration: underline;
}
.brand-logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.brand-logo {
    height: 60px;
    width: auto;
    display: block;
}

.navbar {
    background: #2f3437;
}
.sidebar-profile-card {
    padding: 0;
    overflow: hidden;
    border-radius: 24px;
    border: 1px solid rgba(99, 199, 165, 0.28);
    background: var(--white);
    box-shadow: 0 14px 35px rgba(47, 52, 55, 0.12);
    margin-bottom: 22px;
}

.profile-cover {
    height: 82px;
    background:
        radial-gradient(circle at top left, rgba(214, 164, 59, 0.35), transparent 35%),
        linear-gradient(135deg, var(--carbon) 0%, var(--mint) 100%);
}

.profile-main {
    text-align: center;
    padding: 0 18px 20px;
    margin-top: -58px;
}

.perfil-dashboard-avatar {
    width: 155px;
    height: 155px;
    border-radius: 28px;
    object-fit: cover;
    border: 6px solid var(--white);
    box-shadow: 0 12px 28px rgba(47, 52, 55, 0.28);
    background: var(--white);
    cursor: pointer;
}

.perfil-dashboard-nombre {
    margin: 14px 0 3px;
    font-size: 1.25rem;
    font-weight: 900;
    color: var(--carbon);
}

.perfil-dashboard-subtitle {
    margin: 0 0 10px;
    font-size: 0.78rem;
    color: var(--carbon-soft);
}

.perfil-dashboard-link {
    display: inline-block;
    margin-top: 4px;
    padding: 7px 14px;
    border-radius: 999px;
    background: rgba(99, 199, 165, 0.14);
    color: var(--mint-dark);
    text-decoration: none;
    font-size: 0.78rem;
    font-weight: 800;
}

.perfil-dashboard-link:hover {
    background: var(--mint);
    color: var(--carbon);
    text-decoration: none;
}

.profile-stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 0 16px 16px;
}

.profile-stat {
    background: var(--background);
    border: 1px solid #dfe9e4;
    border-radius: 18px;
    padding: 14px 10px;
    text-align: center;
}

.profile-stat span {
    display: block;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--carbon-soft);
    font-weight: 800;
    margin-bottom: 6px;
}

.profile-stat strong {
    display: block;
    font-size: 1.25rem;
    color: var(--carbon);
    font-weight: 900;
}

#btn-modal-logros {
    cursor: pointer;
}

#btn-modal-logros:hover {
    border-color: var(--mint);
    box-shadow: 0 8px 20px rgba(99, 199, 165, 0.22);
}

.profile-medals-box {
    margin: 0 16px 18px;
    padding: 15px 12px;
    border-radius: 18px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbfa 100%);
    border: 1px solid #e3ebe7;
}

.profile-medals-box h4 {
    margin: 0 0 12px;
    text-align: center;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--carbon);
}

.medallas-profile-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    justify-items: center;
    align-items: center;
    min-height: 70px;
}
.modal-lista-carreras {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(47, 52, 55, 0.72);
    backdrop-filter: blur(5px);
    justify-content: center;
    align-items: center;
    padding: 30px;
}

.modal-lista-carreras-content {
    background: var(--white);
    width: 95%;
    max-width: 1100px;
    max-height: 85vh;
    overflow: hidden;
    border-radius: 24px;
    box-shadow: 0 20px 55px rgba(0,0,0,0.35);
    padding: 24px;
    position: relative;
}

.modal-lista-carreras-close {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: #f0f4f2;
    color: var(--carbon);
    font-size: 1.3rem;
    font-weight: 900;
    cursor: pointer;
}

.modal-lista-carreras-close:hover {
    background: var(--mint-light);
}

.modal-lista-carreras-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding-right: 45px;
    margin-bottom: 18px;
    border-bottom: 2px solid var(--mint-light);
    padding-bottom: 14px;
}

.modal-lista-carreras-header h2 {
    margin: 0;
    color: var(--carbon);
}

.modal-lista-carreras-header p {
    margin: 5px 0 0;
    color: var(--carbon-soft);
    font-size: 0.9rem;
}

.btn-exportar-excel {
    border: none;
    background: var(--mint);
    color: var(--carbon);
    font-weight: 900;
    border-radius: 999px;
    padding: 10px 18px;
    cursor: pointer;
}

.btn-exportar-excel:hover {
    background: var(--mint-dark);
    color: white;
}

.tabla-carreras-scroll {
    overflow: auto;
    max-height: 62vh;
    border-radius: 16px;
    border: 1px solid #dfe9e4;
}

.tabla-carreras-modal {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.tabla-carreras-modal thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.tabla-carreras-modal th {
    background: var(--carbon);
    color: white;
    text-align: left;
    padding: 11px 12px;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.tabla-carreras-modal td {
    padding: 10px 12px;
    border-bottom: 1px solid #edf2ef;
    color: var(--carbon);
}

.tabla-carreras-modal tbody tr:hover {
    background: #f6fbf9;
}
#medallas-container > div {
    transition: transform 0.2s, filter 0.2s;
}

#medallas-container > div:hover {
    transform: scale(1.08);
    filter: brightness(1.05);
}
.upload-avatar-box {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 16px 0;
    flex-wrap: wrap;
}

.btn-guardar-foto {
    display: inline-block;
    background: #111827;
    color: #ffffff;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    opacity: 1;
    visibility: visible;
}

.btn-guardar-foto:hover {
    background: #000000;
    color: #ffffff;
}

.preview-foto-box {
    margin: 16px 0;
    padding: 14px;
    background: #f8f8f8;
    border-radius: 12px;
}

.preview-foto-box p {
    margin: 0 0 10px;
    font-weight: 700;
}

.preview-foto-box img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid #ddd;
}

.mensaje-avatar {
    font-weight: 700;
    margin-top: 10px;
}
.avatar-subido-wrap {
    position: relative;
    width: 90px;
    height: 90px;
}

.avatar-subido-wrap .avatar-opcion {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    object-fit: cover;
    cursor: pointer;
}

.btn-borrar-avatar {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: #dc2626;
    color: white;
    font-weight: 800;
    cursor: pointer;
    line-height: 24px;
    padding: 0;
}

.btn-borrar-avatar:hover {
    background: #991b1b;
}